From dd89491a3e613507d62de874debce8ad4714d7c6 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Thu, 22 Jun 2017 13:58:05 +0200 Subject: [PATCH] Remove building of unnecessary components Remove: * askuser agent * askuser privacy plugins * askuser client plugin * askuser commons Change-Id: I4f9e0e768be6e2ea46aa830bb9a9da101ed326bc --- CMakeLists.txt | 10 -- packaging/askuser.spec | 94 +--------------- src/agent/notification-daemon/Logic.cpp | 10 -- src/agent/notification-daemon/Logic.h | 1 - src/agent/notification-daemon/event/Event.h | 59 ---------- src/agent/notification-daemon/ui/Answerable.h | 22 ---- src/agent/notification-daemon/ui/Po.cpp | 24 ---- src/agent/notification-daemon/ui/Po.h | 3 - .../notification-daemon/ui/PopupLaunchMobile.h | 97 ---------------- .../notification-daemon/ui/PopupLaunchWearable.h | 122 --------------------- src/agent/notification-daemon/ui/Popupper.cpp | 61 ----------- src/agent/notification-daemon/ui/Popupper.h | 8 -- src/agent/notification-daemon/ui/Toast.h | 55 ---------- src/plugin/CMakeLists.txt | 47 -------- src/plugin/client/ClientPlugin.cpp | 97 ---------------- src/plugin/client/PrivacyPlugin.cpp | 75 ------------- src/plugin/service/PrivacyPlugin.cpp | 95 ---------------- 17 files changed, 3 insertions(+), 877 deletions(-) delete mode 100644 src/agent/notification-daemon/ui/PopupLaunchMobile.h delete mode 100644 src/agent/notification-daemon/ui/PopupLaunchWearable.h delete mode 100644 src/agent/notification-daemon/ui/Toast.h delete mode 100644 src/plugin/client/ClientPlugin.cpp delete mode 100644 src/plugin/client/PrivacyPlugin.cpp delete mode 100644 src/plugin/service/PrivacyPlugin.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 289bd38..bd98706 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,18 +88,8 @@ ENDIF (RES_DIR) SET(ASKUSER_PATH ${PROJECT_SOURCE_DIR}/src) IF (BUILD_ASKUSER) - SET(TARGET_ASKUSER "askuser") - SET(TARGET_ASKUSER_COMMON "askuser-common") SET(TARGET_PLUGIN_SERVICE "askuser-plugin-service") - SET(TARGET_PLUGIN_CLIENT "askuser-plugin-client") - SET(TARGET_PRIVACYDENIED_PLUGIN_CLIENT "privacy-denied-plugin-client") - SET(TARGET_PRIVACYDENIED_PLUGIN_SERVICE "privacy-denied-plugin-service") - SET(TARGET_TEST "askuser-test") - SET(TARGET_TESTS "askuser-tests") - ADD_SUBDIRECTORY(src/agent) - ADD_SUBDIRECTORY(src/common) ADD_SUBDIRECTORY(src/plugin) - ADD_SUBDIRECTORY(test) ENDIF (BUILD_ASKUSER) IF (BUILD_ASKUSER_NOTIFICATION) diff --git a/packaging/askuser.spec b/packaging/askuser.spec index fe0170e..8b335ce 100644 --- a/packaging/askuser.spec +++ b/packaging/askuser.spec @@ -1,9 +1,5 @@ -%if !%{defined with_systemd_daemon} -%define with_systemd_daemon 1 -%endif - Name: askuser -Summary: Agent service for Cynara 'ask user' policy +Summary: Agent plugin for Cynara 'ask user' policy Version: 0.1.13 Release: 1 Group: Security/Access Control @@ -11,47 +7,14 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: default.manifest BuildRequires: cmake -BuildRequires: pkgconfig(cynara-agent) -%if %{with_systemd_daemon} -BuildRequires: pkgconfig(libsystemd) -%endif -BuildRequires: pkgconfig(security-manager) -BuildRequires: pkgconfig(security-privilege-manager) -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(pkgmgr-info) -BuildRequires: askuser-notification-devel +BuildRequires: pkgconfig(cynara-plugin) %if !%{defined build_type} %define build_type RELEASE %endif %description -Daemon allowing user to grant or deny acces for given application and privilege - -%package -n libaskuser-common -Summary: Askuser common library - -%description -n libaskuser-common -Askuser common library with common functionalities - -%package plugins -BuildRequires: pkgconfig(cynara-plugin) -Requires: cynara -Requires: libcynara-client -Summary: Askuser cynara plugins - -%description plugins -Askuser plugin library with cynara service and client side plugins - -%package test -BuildRequires: pkgconfig(cynara-agent) -BuildRequires: pkgconfig(cynara-client) -BuildRequires: pkgconfig(cynara-admin) -BuildRequires: pkgconfig(gmock) -Summary: Tool for testing askuser packages and unit tests for askuser - -%description test -Tool for testing askuser packages and unit tests for askuser +Plugin for supporting custom policy type "Ask user" %prep %setup -q @@ -71,73 +34,22 @@ export LDFLAGS+="-Wl,--rpath=%{_libdir}" %cmake . \ -DBUILD_ASKUSER=ON \ -DCMAKE_BUILD_TYPE=%{?build_type} \ - -DBUILD_WITH_SYSTEMD_DAEMON=%{?with_systemd_daemon} \ -DCMAKE_VERBOSE_MAKEFILE=ON make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install -rm -f %{buildroot}/%{_libdir}/libaskuser-common.so - -%if %{with_systemd_daemon} -mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants -mkdir -p %{buildroot}/%{_unitdir}/cynara.service.wants -ln -s ../askuser.service %{buildroot}/%{_unitdir}/multi-user.target.wants/askuser.service -ln -s ../askuser.service %{buildroot}/%{_unitdir}/cynara.service.wants/askuser.service -%endif %post -%if %{with_systemd_daemon} -systemctl daemon-reload - -systemctl restart askuser.service systemctl restart cynara.service -%endif %preun -%if %{with_systemd_daemon} -if [ $1 = 0 ]; then - systemctl stop askuser.service -fi -%endif %postun -%if %{with_systemd_daemon} -if [ $1 = 0 ]; then - systemctl daemon-reload -fi - systemctl restart cynara.service -%endif - -%post -n libaskuser-common -p /sbin/ldconfig - -%postun -n libaskuser-common -p /sbin/ldconfig %files %manifest default.manifest %license LICENSE -%attr(755, root, root) %{_bindir}/askuser -%if %{with_systemd_daemon} -%{_unitdir}/askuser.service -%{_unitdir}/multi-user.target.wants/* -%{_unitdir}/cynara.service.wants/* -%endif - -%files -n libaskuser-common -%manifest default.manifest -%license LICENSE -%{_libdir}/libaskuser-common.so.* - -%files plugins -%manifest default.manifest -%license LICENSE -%{_libdir}/cynara/plugin/client/* %{_libdir}/cynara/plugin/service/* - -%files test -%manifest default.manifest -%license LICENSE -%attr(755,root,root) %{_bindir}/askuser-test -%attr(755,root,root) %{_bindir}/askuser-tests diff --git a/src/agent/notification-daemon/Logic.cpp b/src/agent/notification-daemon/Logic.cpp index d333e0e..7997bdb 100644 --- a/src/agent/notification-daemon/Logic.cpp +++ b/src/agent/notification-daemon/Logic.cpp @@ -206,7 +206,6 @@ void Logic::init() { m_popupper.setLocale(); m_popupper.initialize(); m_popupper.registerPopupResponseHandler([&](int popupId, NResponseType response) { popupResponse(popupId, response);}); - m_popupper.registerToastFinishedHandler([&](int toastId) {toastFinished(toastId);}); registerSignalFd(); @@ -254,15 +253,6 @@ void Logic::popupResponse(int popupId, NResponseType response) { processEvents(); } -void Logic::toastFinished(int toastId) { - if (toastId != m_currentEventId) { - ALOGD("Got different toast id than is being processed"); - return; - } - finishCurrentEvent(); - processEvents(); -} - } // namespace Notification } // namepsace AskUser diff --git a/src/agent/notification-daemon/Logic.h b/src/agent/notification-daemon/Logic.h index 9bb0c8b..e1bec91 100644 --- a/src/agent/notification-daemon/Logic.h +++ b/src/agent/notification-daemon/Logic.h @@ -70,7 +70,6 @@ private: bool isEventProcessed(); void finishCurrentEvent(); void popupResponse(int popupId, NResponseType response); - void toastFinished(int toastId); AskUser::Protocol::ChannelPtr m_clientChannel; Popupper m_popupper; diff --git a/src/agent/notification-daemon/event/Event.h b/src/agent/notification-daemon/event/Event.h index 0aac5ec..f00cba4 100644 --- a/src/agent/notification-daemon/event/Event.h +++ b/src/agent/notification-daemon/event/Event.h @@ -61,65 +61,6 @@ private: std::string m_privilege; }; -class EventPopupLaunch : public IUIEvent { -public: - EventPopupLaunch(Popupper *popupper, int popupId, const std::string &appName, - const std::string &pkgName, const std::vector &privileges) - : IUIEvent(popupper), m_popupId(popupId), m_appName(appName), - m_pkgName(pkgName), m_privileges(privileges) - { - setId(popupId); - } - - virtual void process() { - m_popupper->popupLaunch(m_popupId, m_appName, m_pkgName, m_privileges); - } -private: - int m_popupId; - std::string m_appName; - std::string m_pkgName; - std::vector m_privileges; -}; - -class EventToastDeny : public IUIEvent { -public: - EventToastDeny(Popupper *popupper, int toastId, const std::string &appName, - const std::string &pkgName, const std::string &privilege) - : IUIEvent(popupper), m_toastId(toastId), m_appName(appName), - m_pkgName(pkgName), m_privilege(privilege) - { - setId(toastId); - } - - virtual void process() { - m_popupper->toastDeny(m_toastId, m_appName, m_pkgName, m_privilege); - } -private: - int m_toastId; - std::string m_appName; - std::string m_pkgName; - std::string m_privilege; -}; - -class EventToastFail : public IUIEvent { -public: - EventToastFail(Popupper *popupper, int toastId, const std::string &appName, - const std::string &pkgName) - : IUIEvent(popupper), m_toastId(toastId), m_appName(appName), - m_pkgName(pkgName) - { - setId(toastId); - } - - virtual void process() { - m_popupper->toastFail(m_toastId, m_appName, m_pkgName); - } -private: - int m_toastId; - std::string m_appName; - std::string m_pkgName; -}; - } //namespace AskUser } //namespace Notification diff --git a/src/agent/notification-daemon/ui/Answerable.h b/src/agent/notification-daemon/ui/Answerable.h index f610d70..3a18ed2 100644 --- a/src/agent/notification-daemon/ui/Answerable.h +++ b/src/agent/notification-daemon/ui/Answerable.h @@ -71,27 +71,5 @@ private: PopupCheck *m_popup; }; -class AnswerablePopupLaunch : public IAnswerable { -public: - AnswerablePopupLaunch(Popup *popup, AnswerHandler handler) - : IAnswerable(handler), m_popup(popup) {} - virtual void process(enum Button button) const { - NResponseType answer; - switch (button) { - case IAnswerable::Button::ALLOW: - answer = NResponseType::AllowAlways; - break; - case IAnswerable::Button::DENY: - answer = NResponseType::DenyAlways; - break; - default: - answer = NResponseType::Error; - } - m_handler(m_popup->getId(), answer); - } -private: - Popup *m_popup; -}; - } // namespace AskUser } // namespace Notification diff --git a/src/agent/notification-daemon/ui/Po.cpp b/src/agent/notification-daemon/ui/Po.cpp index 220f3bb..b984fd5 100644 --- a/src/agent/notification-daemon/ui/Po.cpp +++ b/src/agent/notification-daemon/ui/Po.cpp @@ -95,18 +95,6 @@ std::string getPkgLabel(const std::string &pkgName) { return pkgInfo.pkgLabel(); } -std::string getPrivacyList(const std::vector &privs) { - setLocale(); - std::string privacyList = ""; - for (auto &priv : privs) { - std::string privacyName = PrivilegeInfo::getPrivacyDisplayName(priv); - if (privacyList.find(privacyName) == std::string::npos) { - privacyList.append("
"); - privacyList.append(privacyName); - } - } - return privacyList; -} } // namespace anonymous namespace Notification { @@ -115,18 +103,6 @@ std::string createPopupCheckMsg(const std::string &, const std::string &pkgName, return makeFromFormat(getFormat(MsgType::MSG_POPUP_TEXT), getPkgLabel(pkgName).c_str(), PrivilegeInfo::getPrivacyDisplayName(priv).c_str()); } -std::string createPopupLaunchMsg(const std::string &, const std::string &pkgName, const std::vector &privs) { - std::string launchTextFormat = makeFromFormat(getFormat(MsgType::MSG_POPUP_LAUNCH_TEXT), getPkgLabel(pkgName).c_str()); - return makeFromFormat("%s%s", launchTextFormat.c_str(), getPrivacyList(privs).c_str()); -} - -std::string createToastDenyMsg(const std::string &, const std::string &pkgName, const std::string &priv) { - return makeFromFormat(getFormat(MsgType::MSG_TOAST_DENY_TEXT), getPkgLabel(pkgName).c_str(), - PrivilegeInfo::getPrivacyDisplayName(priv).c_str()); -} -std::string createToastFailMsg(const std::string &, const std::string &pkgName) { - return makeFromFormat(getFormat(MsgType::MSG_TOAST_FAIL_TEXT), getPkgLabel(pkgName).c_str()); -} std::string getPopupTitleMsg() { return makeFromFormat("%s", getFormat(MsgType::MSG_POPUP_TITLE)); diff --git a/src/agent/notification-daemon/ui/Po.h b/src/agent/notification-daemon/ui/Po.h index 983cbcd..0f7fab4 100644 --- a/src/agent/notification-daemon/ui/Po.h +++ b/src/agent/notification-daemon/ui/Po.h @@ -27,10 +27,7 @@ namespace Notification { namespace Po { std::string createPopupCheckMsg(const std::string &appName, const std::string &pkgName, const std::string &priv); -std::string createPopupLaunchMsg(const std::string &appName, const std::string &pkgName, const std::vector &privs); std::string createPrivilegeDescr(const std::string &priv); -std::string createToastDenyMsg(const std::string &appName, const std::string &pkgName, const std::string &priv); -std::string createToastFailMsg(const std::string &appName, const std::string &pkgName); std::string getPopupTitleMsg(); std::string getAllowButtonMsg(); diff --git a/src/agent/notification-daemon/ui/PopupLaunchMobile.h b/src/agent/notification-daemon/ui/PopupLaunchMobile.h deleted file mode 100644 index 1422ed2..0000000 --- a/src/agent/notification-daemon/ui/PopupLaunchMobile.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ -/** - * @file src/agent/notification-daemon/ui/PopupLaunchMobile.h - * @author Zofia Abramowska - * @brief Declaration of PopupLaunchMobile class - */ - -#pragma once - -#include - -#include -#include "Po.h" -#include "Popup.h" - -namespace AskUser { -namespace Notification { - -class PopupLaunchMobile : public Popup { -public: - PopupLaunchMobile(Evas_Object *parent, int popupId, const std::string &msg) - : Popup(parent, msg) - { - setId(popupId); - } - virtual ~PopupLaunchMobile() {} - - virtual void create() { - // popup - elm_popup_align_set(m_popup, ELM_NOTIFY_ALIGN_FILL, 1.0); - elm_object_part_text_set(m_popup, "title,text", Po::getPopupTitleMsg().c_str()); - evas_object_size_hint_weight_set(m_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - // layout - m_layout = elm_layout_add(m_popup); - if (m_layout == nullptr) { - ALOGE("EFL : Failed to add layout"); - throw Exception("Enlightenment failed"); - } - elm_layout_file_set(m_layout, RES_DIR"/popup_custom.edj", "popup_layout_mobile"); - evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - // content - m_content = elm_label_add(m_layout); - if (!m_content) { - ALOGE("EFL : Failed to add content"); - throw Exception("Enlightement failed"); - } - elm_object_text_set(m_content, m_msg.c_str()); - elm_object_style_set(m_content, "popup/default"); - elm_label_line_wrap_set(m_content, ELM_WRAP_MIXED); - evas_object_size_hint_weight_set(m_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_content, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_content_set(m_layout, "elm.swallow.content", m_content); - - // buttons - m_denyButton = elm_button_add(m_popup); - if (!m_denyButton) { - ALOGE("EFL : Failed to add deny button"); - throw Exception("Enlightement failed"); - } - elm_object_part_content_set(m_popup, "button1", m_denyButton); - elm_object_text_set(m_denyButton, Po::getDenyButtonMsg().c_str()); - - m_allowButton = elm_button_add(m_popup); - if (!m_allowButton) { - ALOGE("EFL : Failed to add allow button"); - throw Exception("Enlightement failed"); - } - elm_object_part_content_set(m_popup, "button2", m_allowButton); - elm_object_text_set(m_allowButton, Po::getAllowButtonMsg().c_str()); - elm_object_content_set(m_popup, m_layout); - evas_object_show(m_popup); - } -private: - Evas_Object *m_content = nullptr; - Evas_Object *m_layout = nullptr; - Evas_Object *m_layoutInner = nullptr; -}; - -} /* namespace Notification */ -} /* namespace Askuser */ - diff --git a/src/agent/notification-daemon/ui/PopupLaunchWearable.h b/src/agent/notification-daemon/ui/PopupLaunchWearable.h deleted file mode 100644 index 4ca51a2..0000000 --- a/src/agent/notification-daemon/ui/PopupLaunchWearable.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ -/** - * @file src/agent/notification-daemon/ui/PopupLaunchWearable.h - * @author Zofia Abramowska - * @brief Declaration of PopupLaunchWearableper class - */ - -#pragma once - -#include - -#include -#include "Po.h" -#include "Popup.h" - -namespace AskUser { -namespace Notification { - -class PopupLaunchWearable : public Popup { -public: - PopupLaunchWearable(Evas_Object *parent, int popupId, const std::string msg) - : Popup(parent, msg) - { - setId(popupId); - } - virtual ~PopupLaunchWearable() {} - - virtual void create() { - Evas_Object *icon; - elm_object_style_set(m_popup, "circle"); - - m_layout = elm_layout_add(m_popup); - if (m_layout == nullptr) { - ALOGE("EFL : Failed to add layout"); - throw Exception("Enlightenment failed"); - } - elm_layout_theme_set(m_layout, "layout", "popup", "content/circle/buttons2"); - elm_object_part_text_set(m_layout, "elm.text.title", Po::getPopupTitleMsg().c_str()); - elm_object_content_set(m_popup, m_layout); - - m_layoutInner = elm_layout_add(m_layout); - if (m_layoutInner == nullptr) { - ALOGE("EFL : Failed to add layout"); - throw Exception("Enlightenment failed"); - } - elm_layout_file_set(m_layoutInner, RES_DIR"/popup_custom.edj", "popup_checkview_internal"); - evas_object_size_hint_weight_set(m_layoutInner, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_part_content_set(m_layout, "elm.swallow.content", m_layoutInner); - - m_content = elm_label_add(m_layoutInner); - if (m_content == nullptr) { - ALOGE("EFL : Failed to add content"); - throw Exception("Enlightenment failed"); - } - elm_object_text_set(m_content, m_msg.c_str()); - elm_object_style_set(m_content, "popup/default"); - elm_label_line_wrap_set(m_content, ELM_WRAP_MIXED); - evas_object_size_hint_weight_set(m_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_content, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_content_set(m_layoutInner, "label", m_content); - - m_allowButton = elm_button_add(m_popup); - if (m_allowButton == nullptr) { - ALOGE("EFL : Failed to add allow button"); - throw Exception("Enlightenment failed"); - } - elm_object_style_set(m_allowButton, "popup/circle/right"); - elm_object_part_content_set(m_popup, "button2", m_allowButton); - - icon = elm_image_add(m_allowButton); - if (icon == nullptr) { - ALOGE("EFL : Failed to add allow button icon"); - throw Exception("Enlightenment failed"); - } - elm_image_file_set(icon, RES_DIR"/tw_ic_popup_btn_check.png", NULL); - evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_part_content_set(m_allowButton, "elm.swallow.content", icon); - evas_object_show(icon); - - m_denyButton = elm_button_add(m_popup); - if (m_denyButton == nullptr) { - ALOGE("EFL : Failed to add deny button"); - throw Exception("Enlightenment failed"); - } - elm_object_style_set(m_denyButton, "popup/circle/left"); - elm_object_part_content_set(m_popup, "button1", m_denyButton); - - icon = elm_image_add(m_denyButton); - if (icon == nullptr) { - ALOGE("EFL : Failed to add deny button icon"); - throw Exception("Enlightenment failed"); - } - elm_image_file_set(icon, RES_DIR"/tw_ic_popup_btn_delete.png", NULL); - elm_object_part_content_set(m_denyButton, "elm.swallow.content", icon); - evas_object_show(icon); - - evas_object_show(m_popup); - } -private: - std::vector m_privs; - Evas_Object *m_content = nullptr; - Evas_Object *m_layout = nullptr; - Evas_Object *m_layoutInner = nullptr; -}; - -} /* namespace Notification */ -} /* namespace Askuser */ - diff --git a/src/agent/notification-daemon/ui/Popupper.cpp b/src/agent/notification-daemon/ui/Popupper.cpp index 2bd70cb..ee31ec6 100644 --- a/src/agent/notification-daemon/ui/Popupper.cpp +++ b/src/agent/notification-daemon/ui/Popupper.cpp @@ -23,11 +23,8 @@ #include "Answerable.h" #include "Po.h" -#include "PopupLaunchMobile.h" -#include "PopupLaunchWearable.h" #include "PopupCheckMobile.h" #include "PopupCheckWearable.h" -#include "Toast.h" #include #include @@ -61,10 +58,6 @@ void Popupper::registerPopupResponseHandler(PopupHandler handler) { m_popupResponseHandler = handler; } -void Popupper::registerToastFinishedHandler(ToastHandler handler) { - m_toastFinishedHandler = handler; -} - void Popupper::unfocusedCb(void *data, Evas_Object *, void *) { ALOGD("Unfocused"); @@ -113,11 +106,6 @@ Eina_Bool Popupper::hwKeyClickedCb(void *data, int type, void *event) return EINA_TRUE; } -void Popupper::timeoutToastCb(void *data, Evas_Object *, void *) { - Popupper *popupper = static_cast(data); - popupper->m_toastFinishedHandler(popupper->m_elementPtr->getId()); -} - Popupper::~Popupper() {} @@ -194,55 +182,6 @@ void Popupper::popupCheck(int popupId, const std::string &appId, const std::stri show(); } -void Popupper::popupLaunch(int popupId, const std::string &appId, const std::string &pkgId, const std::vector &privs) { - std::string profileName = getProfileName(); - Popup *popup; - try { - if (profileName[0] != 'w' && profileName[0] != 'W') { - // Not wearable - popup = new PopupLaunchMobile(m_win, popupId, Po::createPopupLaunchMsg(appId, pkgId, privs)); - } else { - // Wearable - popup = new PopupLaunchWearable(m_win, popupId, Po::createPopupLaunchMsg(appId, pkgId, privs)); - } - popup->create(); - } catch (const std::exception &e) { - ALOGE("Failed to create popup launch : " << e.what()); - m_popupResponseHandler(popupId, NResponseType::Error); - return; - } - - m_answerablePtr.reset(new AnswerablePopupLaunch(popup, m_popupResponseHandler)); - evas_object_smart_callback_add(popup->getAllowButton(), "clicked", &Popupper::allowPressedCb, - m_answerablePtr.get()); - evas_object_smart_callback_add(popup->getDenyButton(), "clicked", &Popupper::denyPressedCb, - m_answerablePtr.get()); - - m_elementPtr.reset(popup); - show(); -} -void Popupper::toastDeny(int toastId, const std::string &appId, const std::string &pkgId, const std::string &priv) { - try { - Toast *toast = new Toast(m_win, toastId, Po::createToastDenyMsg(appId, pkgId, priv)); - toast->create(); - m_elementPtr.reset(toast); - } catch (const std::exception &e) { - ALOGE("Failed to create toast deny : " << e.what()); - return; - } - m_toastFinishedHandler(toastId); -} -void Popupper::toastFail(int toastId, const std::string &appId, const std::string &pkgId) { - try { - Toast *toast = new Toast(m_win, toastId, Po::createToastFailMsg(appId, pkgId)); - toast->create(); - m_elementPtr.reset(toast); - } catch (const std::exception &e) { - ALOGE("Failed to create toast fail : " << e.what()); - return; - } - m_toastFinishedHandler(toastId); -} void Popupper::start() { diff --git a/src/agent/notification-daemon/ui/Popupper.h b/src/agent/notification-daemon/ui/Popupper.h index a8e5b4e..478f682 100644 --- a/src/agent/notification-daemon/ui/Popupper.h +++ b/src/agent/notification-daemon/ui/Popupper.h @@ -30,7 +30,6 @@ #include "Answerable.h" #include "Popup.h" -#include "Toast.h" #include #include @@ -41,19 +40,14 @@ namespace Notification { class Popupper { public: typedef std::function PopupHandler; - typedef std::function ToastHandler; Popupper() = default; void initialize(); void setLocale(); void registerPopupResponseHandler(PopupHandler handler); - void registerToastFinishedHandler(ToastHandler handler); void start(); void popupCheck(int popupId, const std::string &appId, const std::string &pkgId, const std::string &priv); - void popupLaunch(int popupId, const std::string &appId, const std::string &pkgId, const std::vector &privs); - void toastDeny(int toastId, const std::string &appId, const std::string &pkgId, const std::string &priv); - void toastFail(int toastId, const std::string &appId, const std::string &pkgId); void popupClose(int popupId); void stop(); @@ -64,13 +58,11 @@ private: static void unfocusedCb(void *data, Evas_Object *, void *); static void allowPressedCb(void *data, Evas_Object *, void *); static void denyPressedCb(void *data, Evas_Object *, void *); - static void timeoutToastCb(void *data, Evas_Object *, void *); static Eina_Bool hwKeyClickedCb(void *data, int type, void *event); void show(); PopupHandler m_popupResponseHandler; - ToastHandler m_toastFinishedHandler; Evas_Object *m_win = nullptr; std::unique_ptr m_elementPtr; diff --git a/src/agent/notification-daemon/ui/Toast.h b/src/agent/notification-daemon/ui/Toast.h deleted file mode 100644 index d5602e0..0000000 --- a/src/agent/notification-daemon/ui/Toast.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ -/** - * @file src/agent/notification-daemon/ui/Toast.h - * @author Zofia Abramowska - * @brief Declaration of Toast class - */ - -#pragma once - -#include -#include - -#include -#include - -#include -#include "UIElement.h" - -namespace AskUser { -namespace Notification { - -class Toast : public UIElement { -public: - Toast(Evas_Object *m_parentWindow, int toastId, const std::string msg) : UIElement(m_parentWindow), m_msg(msg) - { - setId(toastId); - } - virtual void create() { - int ret = notification_status_message_post(m_msg.c_str()); - if (ret != NOTIFICATION_ERROR_NONE) { - ALOGE("notification_status_message_post failed with " << ret); - throw std::runtime_error("notification_status_message_post failed with " + std::to_string(ret)); - } - } -private: - std::string m_msg; -}; - -} /* namespace Notification */ -} /* namespace Askuser */ - diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 27a2f3e..508d9bf 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -33,61 +33,14 @@ SET(SERVICE_PLUGIN_SOURCES ${PLUGIN_PATH}/service/ServicePlugin.cpp ) -SET(CLIENT_PLUGIN_SOURCES - ${PLUGIN_PATH}/client/ClientPlugin.cpp - ) - ADD_DEFINITIONS("-fvisibility=default") ADD_LIBRARY(${TARGET_PLUGIN_SERVICE} SHARED ${SERVICE_PLUGIN_SOURCES}) -ADD_LIBRARY(${TARGET_PLUGIN_CLIENT} SHARED ${CLIENT_PLUGIN_SOURCES}) TARGET_LINK_LIBRARIES(${TARGET_PLUGIN_SERVICE} ${TARGET_ASKUSER_COMMON} ${TARGET_ASKUSER_COMMON_DEPS} ) -TARGET_LINK_LIBRARIES(${TARGET_PLUGIN_CLIENT} - ${TARGET_ASKUSER_COMMON} - ${TARGET_ASKUSER_COMMON_DEPS} - ) INSTALL(TARGETS ${TARGET_PLUGIN_SERVICE} DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/service/) -INSTALL(TARGETS ${TARGET_PLUGIN_CLIENT} - DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/client/) - -########################## PRIVACY DENIED PLUGINS ############################## - -PKG_CHECK_MODULES(PDP_DEP - REQUIRED - cynara-plugin - security-manager - askuser-notification - ) - -INCLUDE_DIRECTORIES( - ${ASKUSER_PATH}/common/config - SYSTEM - ${PDP_DEP_INCLUDE_DIRS} - ) - -SET(PDP_CLIENT_SOURCES - ${PLUGIN_PATH}/client/PrivacyPlugin.cpp - ) - -SET(PDP_SERVICE_SOURCES - ${PLUGIN_PATH}/service/PrivacyPlugin.cpp - ) - -LINK_DIRECTORIES(${PDP_DEP_LIBRARY_DIRS}) - -ADD_LIBRARY(${TARGET_PRIVACYDENIED_PLUGIN_SERVICE} SHARED ${PDP_SERVICE_SOURCES}) -ADD_LIBRARY(${TARGET_PRIVACYDENIED_PLUGIN_CLIENT} SHARED ${PDP_CLIENT_SOURCES}) - -TARGET_LINK_LIBRARIES(${TARGET_PRIVACYDENIED_PLUGIN_SERVICE} ${PDP_DEP_LIBRARIES}) -TARGET_LINK_LIBRARIES(${TARGET_PRIVACYDENIED_PLUGIN_CLIENT} ${PDP_DEP_LIBRARIES}) - -INSTALL(TARGETS ${TARGET_PRIVACYDENIED_PLUGIN_SERVICE} - DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/service/) -INSTALL(TARGETS ${TARGET_PRIVACYDENIED_PLUGIN_CLIENT} - DESTINATION ${LIB_INSTALL_DIR}/cynara/plugin/client/) diff --git a/src/plugin/client/ClientPlugin.cpp b/src/plugin/client/ClientPlugin.cpp deleted file mode 100644 index 5fe1e1e..0000000 --- a/src/plugin/client/ClientPlugin.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2014-2015 Samsung Electronics Co. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ -/** - * @file ClientPlugin.cpp - * @author Zofia Abramowska - * @brief Implementation of cynara client side AskUser plugin. - */ - -#include -#include -#include - -#include -#include -#include -#include - -using namespace Cynara; - -namespace AskUser { -const std::vector clientDescriptions = { - { SupportedTypes::Client::ALLOW_ONCE, "Allow once" }, - { SupportedTypes::Client::ALLOW_PER_SESSION, "Allow per session" }, - - { SupportedTypes::Client::DENY_ONCE, "Deny once" }, - { SupportedTypes::Client::DENY_PER_SESSION, "Deny per session" } -}; - -class ClientPlugin : public ClientPluginInterface { -public: - const std::vector &getSupportedPolicyDescr() { - return clientDescriptions; - } - - bool isCacheable(const ClientSession &session UNUSED, const PolicyResult &result) { - return (result.policyType() == SupportedTypes::Client::ALLOW_PER_SESSION - || result.policyType() == SupportedTypes::Client::DENY_PER_SESSION); - } - - bool isUsable(const ClientSession &session, - const ClientSession &prevSession, - bool &updateSession, - PolicyResult &result) - { - updateSession = false; - - switch (result.policyType()) { - case SupportedTypes::Client::ALLOW_PER_SESSION: - case SupportedTypes::Client::DENY_PER_SESSION: - if (session == prevSession) { - return true; - } - LOGD("Previous session <" << prevSession << "> does not match current session <" - << session << ">"); - return false; - default: - return false; - } - } - - void invalidate() {} - - virtual int toResult(const ClientSession &session UNUSED, PolicyResult &result) { - switch (result.policyType()) { - case SupportedTypes::Client::ALLOW_ONCE: - case SupportedTypes::Client::ALLOW_PER_SESSION: - return CYNARA_API_ACCESS_ALLOWED; - default: - return CYNARA_API_ACCESS_DENIED; - } - } -}; - -} // namespace AskUser - -extern "C" { -ExternalPluginInterface *create(void) { - return new AskUser::ClientPlugin(); -} - -void destroy(ExternalPluginInterface *ptr) { - delete ptr; -} -} // extern "C" diff --git a/src/plugin/client/PrivacyPlugin.cpp b/src/plugin/client/PrivacyPlugin.cpp deleted file mode 100644 index f1722e7..0000000 --- a/src/plugin/client/PrivacyPlugin.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ -/** - * @file PrivacyPlugin.cpp - * @author - * @brief Implementation of cynara client side PrivacyDenied plugin. - */ - -#include -#include -#include - -#include -#include - -using namespace Cynara; - -namespace PrivacyDeniedPlugin { -const std::vector clientDescriptions = { - { Config::ASK_USER_LEGACY, "ASK_USER_LEGACY" }, - { Config::PRIVACY_DENY, "PRIVACY_DENY" } -}; - -class ClientPlugin : public ClientPluginInterface { -public: - const std::vector &getSupportedPolicyDescr() { - return clientDescriptions; - } - - bool isCacheable(const ClientSession &session UNUSED, const PolicyResult &result UNUSED) { - return true; - } - - bool isUsable(const ClientSession &session, - const ClientSession &prevSession, - bool &updateSession, - PolicyResult &result UNUSED) - { - updateSession = false; - return (session.compare(prevSession) == 0); - } - - void invalidate() {} - - int toResult(const ClientSession &session UNUSED, PolicyResult &result UNUSED) { - return CYNARA_API_ACCESS_DENIED; - } -}; - -} // namespace PrivacyDeniedPlugin - -extern "C" { - -ExternalPluginInterface *create(void) { - return new PrivacyDeniedPlugin::ClientPlugin(); -} - -void destroy(ExternalPluginInterface *ptr) { - delete ptr; -} - -} // extern "C" diff --git a/src/plugin/service/PrivacyPlugin.cpp b/src/plugin/service/PrivacyPlugin.cpp deleted file mode 100644 index 2478814..0000000 --- a/src/plugin/service/PrivacyPlugin.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017 Samsung Electronics Co. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ -/** - * @file PrivacyPlugin.cpp - * @author - * @brief Implementation of cynara service side PrivacyDenied plugin. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -using namespace Cynara; - -namespace PrivacyDeniedPlugin { - -const std::vector serviceDescriptions = { - { Config::ASK_USER_LEGACY, "ASK_USER_LEGACY" }, - { Config::PRIVACY_DENY, "PRIVACY_DENY" } -}; - -class ServicePlugin : public ServicePluginInterface { -public: - ServicePlugin() {} - - const std::vector &getSupportedPolicyDescr() { - return serviceDescriptions; - } - - PluginStatus check(const std::string &client, - const std::string &user, - const std::string &privilege, - PolicyResult &result UNUSED, - AgentType &requiredAgent UNUSED, - PluginData &pluginData UNUSED) noexcept - { - toast(client, user, privilege); - return PluginStatus::ANSWER_READY; - } - - PluginStatus update(const std::string &client UNUSED, - const std::string &user UNUSED, - const std::string &privilege UNUSED, - const PluginData &agentData UNUSED, - PolicyResult &result UNUSED) noexcept - { - // This function should be never called - return PluginStatus::ERROR; - } - - void invalidate() {} - -private: - void toast(const std::string &client, const std::string &user, const std::string &privilege) { - char *pkgName = nullptr, *appName = nullptr; - int ret = security_manager_identify_app_from_cynara_client(client.c_str(), &pkgName, &appName); - if (ret != SECURITY_MANAGER_SUCCESS || pkgName == nullptr) - return; - - std::unique_ptr pkgNamePtr(pkgName, free); - std::unique_ptr appNamePtr(appName, free); - AskUser::Protocol::toast_deny(pkgName, (appName ? appName : ""), std::stoi(user), privilege); - } -}; - -} // namespace PrivacyDeniedPlugin - -extern "C" { -ExternalPluginInterface *create(void) { - return new PrivacyDeniedPlugin::ServicePlugin(); -} - -void destroy(ExternalPluginInterface *ptr) { - delete ptr; -} -} // extern "C" -- 2.7.4