From 473de0fb27052aff62e4b391feb1b6447f83ec41 Mon Sep 17 00:00:00 2001 From: Janusz Kozerski Date: Fri, 25 Sep 2015 14:47:34 +0200 Subject: Add popup Since Notification framework doesn't support system daemons, the cert-checker's internal popup should be provided. Add implementation of popup binary - /usr/bin/cert-checker-popup Cert-checker forks(), execs a popup binary, waits for popup termination, and then reads user response from pipe. Change-Id: Ie2e70f661feb1f262841d59a1b4c6a7ec49901f9 --- src/include/cchecker/UIBackend.h | 21 ++++++++-------- src/include/cchecker/popup-runner.h | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 src/include/cchecker/popup-runner.h (limited to 'src/include/cchecker') diff --git a/src/include/cchecker/UIBackend.h b/src/include/cchecker/UIBackend.h index e59f0d7..6133078 100644 --- a/src/include/cchecker/UIBackend.h +++ b/src/include/cchecker/UIBackend.h @@ -21,24 +21,25 @@ #pragma once -#include - #include namespace CCHECKER { namespace UI { -enum response_e { - DONT_UNINSTALL, - UNINSTALL, - ERROR +enum popup_status : int { + NO_ERROR = 0, + EXIT_ERROR = 1 }; -// FIXME: notification framework is corrupted and it doesn't work as it should +enum response_e : int { + DONT_UNINSTALL = 2, + UNINSTALL = 3, + RESPONSE_ERROR = 4 +}; class UIBackend { public: - explicit UIBackend(int timeout = 60); //timeout in seconds + explicit UIBackend(int timeout = 60); //timeout in seconds (zero or less means infinity) virtual ~UIBackend(); // Displays popup with question, and - if needed - app_control for removing application. @@ -48,10 +49,8 @@ public: bool call_popup(const app_t &app); private: - response_e run(); - bool create_ui(const std::string &app_id, const std::string &pkg_id); + response_e run(const app_t &app); - notification_h m_notification; const int m_responseTimeout; // seconds }; diff --git a/src/include/cchecker/popup-runner.h b/src/include/cchecker/popup-runner.h new file mode 100644 index 0000000..addaa3b --- /dev/null +++ b/src/include/cchecker/popup-runner.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 popup-runner.h + * @author Janusz Kozerski (j.kozerski@samsung.com) + * @version 1.0 + */ + +#include + +#include + +namespace CCHECKER{ +namespace UI{ + +class BinaryStream : public CCHECKER::IStream { + public: + void Read (size_t num, void * bytes); + void Write(size_t num, const void * bytes); + + BinaryStream(); + ~BinaryStream(); + + const unsigned char* char_pointer() const; + size_t size() const; + + private: + std::vector m_data; + size_t m_readPosition; +}; + +response_e run_popup( + const app_t &app, + int timeout); // zero or negative timeout means infinity + +} // UI +} // CCHECKER -- cgit v1.2.3