summaryrefslogtreecommitdiff
path: root/src/ui/popup-bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/popup-bin')
-rw-r--r--src/ui/popup-bin/CMakeLists.txt4
-rw-r--r--src/ui/popup-bin/main.cpp59
-rw-r--r--src/ui/popup-bin/popup-service.cpp103
-rw-r--r--src/ui/popup-bin/popup-service.h47
-rw-r--r--src/ui/popup-bin/popup.cpp363
-rw-r--r--src/ui/popup-bin/popup.h83
6 files changed, 365 insertions, 294 deletions
diff --git a/src/ui/popup-bin/CMakeLists.txt b/src/ui/popup-bin/CMakeLists.txt
index a9e7e14..6d434ae 100644
--- a/src/ui/popup-bin/CMakeLists.txt
+++ b/src/ui/popup-bin/CMakeLists.txt
@@ -22,13 +22,15 @@
PKG_CHECK_MODULES(CERT_CHECKER_POPUP_DEP
elementary
libtzplatform-config
+ capi-appfw-application
REQUIRED)
set(CERT_CHECKER_POPUP_SRC_DIR ${PROJECT_SOURCE_DIR}/src/ui/popup-bin)
set(CERT_CHECKER_POPUP_SOURCES
+ ${CERT_CHECKER_POPUP_SRC_DIR}/main.cpp
${CERT_CHECKER_POPUP_SRC_DIR}/popup.cpp
- ${CERT_CHECKER_UI_PATH}/popup-runner.cpp
+ ${CERT_CHECKER_POPUP_SRC_DIR}/popup-service.cpp
${CERT_CHECKER_SERVICE_PATH}/app.cpp
# dpl
${DPL_CORE_SRC_PATH}/assert.cpp
diff --git a/src/ui/popup-bin/main.cpp b/src/ui/popup-bin/main.cpp
new file mode 100644
index 0000000..8075612
--- /dev/null
+++ b/src/ui/popup-bin/main.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016 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 main.cpp
+ * @author Sangwan Kwon (sangwan.kwon@samsung.com)
+ * @version 1.0
+ * @brief Popup service main
+ */
+#include <stdexcept>
+
+#include <Elementary.h>
+
+#include "common/log.h"
+#include "popup-service.h"
+
+using namespace CCHECKER::UI;
+
+namespace {
+struct ElmRaii {
+ ElmRaii(int argc, char **argv) { elm_init(argc, argv); }
+ ~ElmRaii() { elm_shutdown(); }
+};
+} // Anonymous namespace
+
+int main(int argc, char **argv)
+{
+ try {
+ LogDebug("Start to run cert-checker popup program.");
+ setlocale(LC_ALL, "");
+
+ ElmRaii er(argc, argv);
+
+ PopupService service(POPUP_STREAM);
+ service.setTimeout(10);
+ service.start();
+
+ LogDebug("Finish running cert-checker popup successfully.");
+ return 0;
+ } catch (const std::exception &e) {
+ LogError("Exception occured in popup main : " << e.what());
+ return -1;
+ } catch (...) {
+ LogError("Unhandled exception occured in popup main.");
+ return -1;
+ }
+}
diff --git a/src/ui/popup-bin/popup-service.cpp b/src/ui/popup-bin/popup-service.cpp
new file mode 100644
index 0000000..0fec83e
--- /dev/null
+++ b/src/ui/popup-bin/popup-service.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2016 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-service.cpp
+ * @author Sangwan Kwon (sangwan.kwon@samsung.com)
+ * @version 1.0
+ * @brief Popup ui service for cert-checker
+ */
+#include "popup-service.h"
+
+#include <memory>
+
+#include <app_control.h>
+
+#include "popup.h"
+#include "service/app.h"
+#include "common/binary-queue.h"
+#include "common/log.h"
+
+namespace CCHECKER {
+namespace UI {
+
+namespace {
+struct AppControl {
+ AppControl() { app_control_create(&handle); }
+ ~AppControl() { app_control_destroy(handle); }
+
+ app_control_h handle;
+};
+
+bool launchSettingManager(const std::string &pkgId)
+{
+ LogDebug("Start to launch setting manager about pkg : " << pkgId);
+ std::unique_ptr<AppControl> ac(new AppControl);
+ app_control_set_operation(ac->handle, APP_CONTROL_OPERATION_DEFAULT);
+ app_control_set_app_id(ac->handle, "setting-manage-applications-efl");
+ app_control_add_extra_data(ac->handle, "viewtype", "application-info");
+ app_control_add_extra_data(ac->handle, "pkgname", pkgId.c_str());
+ auto ret = app_control_send_launch_request(ac->handle, NULL, NULL);
+ return ret == APP_CONTROL_ERROR_NONE;
+}
+} // Anonymous namespace
+
+PopupService::PopupService(const std::string &address) :
+ Service(address)
+{
+}
+
+void PopupService::onMessageProcess(const ConnShPtr &connection)
+{
+ LogDebug("Start to process message on popup service.");
+ auto in = connection->receive();
+ connection->send(this->process(connection, in));
+}
+
+RawBuffer PopupService::process(const ConnShPtr &, RawBuffer &data)
+{
+ LogDebug("Start to receive data from connection.");
+ BinaryQueue q;
+ q.push(data);
+
+ app_t app;
+ q.Deserialize(app);
+
+ LogDebug("Processing popup-service. [" << app.str() << "]");
+ Popup popup(app);
+ auto response = popup.run();
+
+ switch (response) {
+ case ResponseType::UNINSTALL : {
+ LogDebug("User decide to uninstall package.");
+ if(launchSettingManager(app.pkg_id))
+ LogDebug("Success to launch setting manager.");
+ else
+ LogError("Failed to launch setting manager.");
+ return BinaryQueue::Serialize(true).pop();
+ }
+ case ResponseType::KEEP : {
+ LogDebug("User decide to keep package.");
+ return BinaryQueue::Serialize(true).pop();
+ }
+ default : {
+ LogError("Protocol broken on popup-service.");
+ return BinaryQueue::Serialize(false).pop();
+ }
+ }
+}
+
+} // namespace UI
+} // namespace CCHECKER
diff --git a/src/ui/popup-bin/popup-service.h b/src/ui/popup-bin/popup-service.h
new file mode 100644
index 0000000..93501a7
--- /dev/null
+++ b/src/ui/popup-bin/popup-service.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 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-service.h
+ * @author Sangwan Kwon (sagnwan.kwon@samsung.com)
+ * @version 1.0
+ * @brief Popup ui service for cert-checker
+ */
+#pragma once
+
+#include <string>
+
+#include "common/service.h"
+
+namespace CCHECKER {
+namespace UI {
+
+class PopupService : public Service {
+public:
+ PopupService(const std::string &address);
+ virtual ~PopupService() = default;
+
+ PopupService(const PopupService &) = delete;
+ PopupService &operator=(const PopupService &) = delete;
+ PopupService(PopupService &&) = delete;
+ PopupService &operator=(PopupService &&) = delete;
+
+private:
+ virtual void onMessageProcess(const ConnShPtr &) override;
+ RawBuffer process(const ConnShPtr &, RawBuffer &);
+};
+
+} // namespace UI
+} // namespace CCHECKER
diff --git a/src/ui/popup-bin/popup.cpp b/src/ui/popup-bin/popup.cpp
index 23003ab..9c5cc92 100644
--- a/src/ui/popup-bin/popup.cpp
+++ b/src/ui/popup-bin/popup.cpp
@@ -1,311 +1,134 @@
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 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
+ * 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
+ * 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.
+ * 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.cpp
* @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @author Sangwan Kwon (sangwan.kwon@samsung.com)
* @version 1.0
+ * @brief
*/
+#include "popup.h"
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <vector>
-#include <libintl.h>
-#include <sys/select.h>
-#include <time.h>
+#include <memory>
+#include <exception>
-#include <Elementary.h>
-
-#include <popup.h>
#include "common/log.h"
-#include <cchecker/UIBackend.h>
-#include <cchecker/popup-runner.h>
-#include <cchecker/dpl/serialization.h>
-#include <cchecker/dpl/errno_string.h>
-#include <cchecker/dpl/exception.h>
-#ifndef FD_SETSIZE
-#define FD_SETSIZE 1024
-#endif
+#define __(str) dgettext(SERVICE_NAME, str)
using namespace CCHECKER::UI;
-namespace { // anonymous
-
-void on_done(void)
-{
- // Quit the efl-mainloop
- LogDebug("elm_exit()");
- elm_exit();
-}
-
-void keep_answer(void *data, Evas_Object * /* obj */, void * /* event_info */)
-{
- LogDebug("keep_answer");
-
- if (NULL == data) {
- LogError("data is NULL; return");
- return;
- }
-
- struct cert_checker_popup_data *pdp = static_cast <struct cert_checker_popup_data *>(data);
-
- pdp->result = response_e::DONT_UNINSTALL;
-
- on_done();
-}
-
-void uninstall_answer(void *data, Evas_Object * /* obj */, void * /* event_info */)
+Popup::Popup(const app_t &app) : m_app(app)
{
- LogDebug("uninstall_answer");
-
- if (NULL == data) {
- LogError("data is NULL; return");
- return;
- }
-
- struct cert_checker_popup_data *pdp = static_cast <struct cert_checker_popup_data *>(data);
+ m_win = elm_win_add(nullptr, "Cert Checker Popup", ELM_WIN_NOTIFICATION);
+ elm_win_indicator_opacity_set(m_win, ELM_WIN_INDICATOR_TRANSLUCENT);
+ elm_win_borderless_set(m_win, EINA_TRUE);
+ elm_win_alpha_set(m_win, EINA_TRUE);
- pdp->result = response_e::UNINSTALL;
+ m_popup = elm_popup_add(m_win);
+ this->setDefaultProperties(m_popup);
- on_done();
-}
+ m_box = elm_box_add(m_popup);
+ this->setDefaultProperties(m_box);
+ evas_object_show(m_box);
-void show_popup(struct cert_checker_popup_data *pdp)
-{
- LogDebug("show_popup()");
+ m_title = elm_label_add(m_box);
+ setDefaultProperties(m_title);
+ elm_object_part_text_set(m_popup, "title,text",
+ __("SID_TITLE_OCSP_VERIFICATION_FAILED"));
+ elm_box_pack_end(m_box, m_title);
+ evas_object_show(m_title);
- if (NULL == pdp) {
- LogError("pdp is NULL; return");
- return;
- }
+ m_content = elm_label_add(m_box);
+ this->setDefaultProperties(m_content);
- pdp->win = elm_win_add(NULL,
- dgettext(SERVICE_NAME, "SID_TITLE_OCSP_VERIFICATION_FAILED"),
- ELM_WIN_NOTIFICATION);
- elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
- elm_win_autodel_set(pdp->win, EINA_TRUE);
- evas_object_show(pdp->win);
- elm_win_indicator_opacity_set(pdp->win, ELM_WIN_INDICATOR_TRANSLUCENT);
- pdp->popup = elm_popup_add(pdp->win);
- pdp->box = elm_box_add(pdp->popup);
- evas_object_size_hint_weight_set(pdp->box, EVAS_HINT_EXPAND, 0);
- evas_object_size_hint_align_set(pdp->box, EVAS_HINT_FILL, 0.0);
- pdp->title = elm_label_add(pdp->popup);
- elm_object_style_set(pdp->title, "elm.text.title");
- elm_object_text_set(pdp->title, dgettext(SERVICE_NAME, "SID_TITLE_OCSP_VERIFICATION_FAILED"));
- evas_object_show(pdp->title);
- elm_box_pack_end(pdp->box, pdp->title);
- pdp->content = elm_label_add(pdp->popup);
- elm_object_style_set(pdp->content, "elm.swallow.content");
- elm_label_line_wrap_set(pdp->content, ELM_WRAP_MIXED);
char *buff = NULL;
- int ret;
-
- // Set message
- // App ID may be absent, so in that case we need to use only package ID
- if (pdp->app_id == std::string(CCHECKER::TEMP_APP_ID)) {
- char *content = dgettext(SERVICE_NAME, "SID_CONTENT_OCSP_PACKAGE VERIFICATION_FAILED");
- ret = asprintf(&buff, content, pdp->pkg_id.c_str());
+ if (m_app.app_id == std::string(CCHECKER::TEMP_APP_ID)) {
+ auto content = __("SID_CONTENT_OCSP_PACKAGE VERIFICATION_FAILED");
+ if (-1 == asprintf(&buff, content, m_app.pkg_id.c_str()))
+ throw std::bad_alloc();
} else {
- char *content = dgettext(SERVICE_NAME, "SID_CONTENT_OCSP_VERIFICATION_FAILED");
- ret = asprintf(&buff, content, pdp->app_id.c_str(), pdp->pkg_id.c_str());
+ auto content = __("SID_CONTENT_OCSP_VERIFICATION_FAILED");
+ if (-1 == asprintf(&buff, content, m_app.app_id.c_str(),
+ m_app.pkg_id.c_str()))
+ throw std::bad_alloc();
}
-
- if (-1 == ret) {
- LogError("asprintf failed - returned -1");
- evas_object_del(pdp->content);
- evas_object_del(pdp->popup);
- evas_object_del(pdp->win);
- return;
- }
-
- elm_object_text_set(pdp->content, buff);
- LogDebug("Popup label: " << buff);
+ this->setText(m_content, buff);
free(buff);
- evas_object_size_hint_weight_set(pdp->content, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(pdp->content, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(pdp->content);
- elm_box_pack_end(pdp->box, pdp->content);
- elm_object_part_content_set(pdp->popup, "default", pdp->box);
- pdp->keep_button = elm_button_add(pdp->popup);
- elm_object_style_set(pdp->keep_button, "elm.swallow.content.button1");
- elm_object_text_set(pdp->keep_button, dgettext(SERVICE_NAME, "SID_BTN_OCSP_KEEP_APP"));
- elm_object_part_content_set(pdp->popup, "button1", pdp->keep_button);
- evas_object_smart_callback_add(pdp->keep_button, "clicked", keep_answer, pdp);
- pdp->uninstall_button = elm_button_add(pdp->popup);
- elm_object_style_set(pdp->uninstall_button, "elm.swallow.content.button2");
- elm_object_text_set(pdp->uninstall_button, dgettext(SERVICE_NAME, "SID_BTN_OCSP_UNINSTALL_APP"));
- elm_object_part_content_set(pdp->popup, "button2 ", pdp->uninstall_button);
- evas_object_smart_callback_add(pdp->uninstall_button, "clicked", uninstall_answer, pdp);
- evas_object_show(pdp->popup);
- // Showing the popup window
- evas_object_show(pdp->win);
- // Run the efl mainloop
- elm_run();
- // Shutdown elementary
- LogDebug("elm_shutdown()");
- elm_shutdown();
+ elm_box_pack_end(m_box, m_content);
+ evas_object_show(m_content);
+
+ elm_object_part_content_set(m_popup, "default", m_box);
+
+ m_keepBtn = elm_button_add(m_popup);
+ elm_object_style_set(m_keepBtn, "bottom");
+ elm_object_text_set(m_keepBtn, __("SID_BTN_OCSP_KEEP_APP"));
+ elm_object_part_content_set(m_popup, "button1", m_keepBtn);
+ m_keepType = ResponseType::KEEP;
+ this->callbackRegister(m_keepBtn, &m_keepType);
+ evas_object_show(m_keepBtn);
+
+ m_uninstallBtn = elm_button_add(m_popup);
+ elm_object_style_set(m_uninstallBtn, "bottom");
+ elm_object_text_set(m_uninstallBtn, __("SID_BTN_OCSP_UNINSTALL_APP"));
+ elm_object_part_content_set(m_popup, "button2", m_uninstallBtn);
+ m_uninstallType = ResponseType::UNINSTALL;
+ this->callbackRegister(m_uninstallBtn, &m_uninstallType);
+ evas_object_show(m_uninstallBtn);
+
+ evas_object_show(m_popup);
+ evas_object_show(m_win);
}
-static int wait_for_parent_info(int pipe_in)
+Popup::~Popup()
{
- // wait for parameters from pipe_in
- // timeout is set for 10 seconds
- struct timeval timeout = {10L, 0L};
- fd_set readfds;
- FD_ZERO(&readfds);
- FD_SET(pipe_in, &readfds);
- int sel = select(pipe_in + 1, &readfds, NULL, NULL, &timeout);
+ evas_object_del(m_win);
+}
- if (sel == -1) {
- int error = errno;
- LogError("Cannot get info from parent. Exit popup");
- LogError("Error: " << CCHECKER::GetErrnoString(error));
- close(pipe_in);
- return -1;
- } else if (sel == 0) {
- LogError("Timeout reached! Exit popup - ERROR");
- close(pipe_in);
- return -1;
- }
+int Popup::response = -1;
- return 0;
+ResponseType Popup::run(void) noexcept
+{
+ elm_run();
+ return static_cast<ResponseType>(response);
}
-void deserialize(cert_checker_popup_data *pdp, char *line, ssize_t line_length)
+void Popup::setDefaultProperties(Evas_Object *obj) noexcept
{
- BinaryStream stream;
- stream.Write(line_length, static_cast <void *>(line));
- std::string app_id;
- std::string pkg_id;
- LogDebug("------- Deserialization -------");
- // Deserialization order:
- // app_id, pkg_id
- CCHECKER::Deserialization::Deserialize(stream, app_id);
- LogDebug("app_id : " << app_id.c_str());
- pdp->app_id = app_id.c_str();
- CCHECKER::Deserialization::Deserialize(stream, pkg_id);
- LogDebug("pkg_id : " << pkg_id.c_str());
- pdp->pkg_id = pkg_id.c_str();
+ // Set width as maximum, height as minimum.
+ evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, 0);
+ // Set width as fill parent, height as center.
+ evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, 0.5);
}
-} // anonymous
-
-EAPI_MAIN int
-elm_main(int argc, char **argv)
+void Popup::setText(Evas_Object *obj, const std::string &text) noexcept
{
- try {
- // int pipe_in and int pipe_out should be passed to Popup via args.
- // These parameters should be passed to Popup via pipe_in:
- // std::string app_id
- // std::string pkg_id
- struct cert_checker_popup_data pd;
- struct cert_checker_popup_data *pdp = &pd;
- LogDebug("############################ popup binary ################################");
- setlocale(LC_ALL, "");
-
- if (argc < 3) {
- LogError("To few args passed in exec to popup-bin - should be at least 3:");
- LogError("(binary-name, pipe_in, pipe_out)");
- LogError("return ERROR");
- return popup_status::EXIT_ERROR;
- }
-
- LogDebug("Passed args: " << argv[0] << ", " << argv[1] << ", " << argv[2]);
- int pipe_in;
- int pipe_out;
-
- // Parsing args (pipe_in, pipe_out)
- if (0 == sscanf(argv[1], "%d", &pipe_in)) {
- LogError("Error while parsing pipe_in; return ERROR");
- return popup_status::EXIT_ERROR;
- }
-
- if (pipe_in < 0 || pipe_in > FD_SETSIZE) {
- LogError("fb about pipe_in is in invalid.");
- return popup_status::EXIT_ERROR;
- }
-
- if (0 == sscanf(argv[2], "%d", &pipe_out)) {
- LogError("Error while parsing pipe_out; return ERROR");
- return popup_status::EXIT_ERROR;
- }
-
- if (pipe_out < 0 || pipe_out > FD_SETSIZE) {
- LogError("fb about pipe_out is in invalid.");
- close(pipe_in);
- return popup_status::EXIT_ERROR;
- }
-
- LogDebug("Parsed pipes: IN: " << pipe_in << ", OUT: " << pipe_out);
-
- if (wait_for_parent_info(pipe_in) == -1) {
- close(pipe_out);
- return popup_status::EXIT_ERROR;
- }
-
- int buff_size = 1024;
- char line[buff_size];
- ssize_t count = 0;
-
- do {
- count = TEMP_FAILURE_RETRY(read(pipe_in, line, buff_size));
- } while (0 == count);
-
- if (count < 0) {
- int error = errno;
- close(pipe_in);
- close(pipe_out);
- LogError("read returned a negative value (" << count << ")");
- LogError("error: " << CCHECKER::GetErrnoString(error));
- LogError("Exit popup - ERROR");
- return popup_status::EXIT_ERROR;
- }
-
- LogDebug("Read bytes : " << count);
- close(pipe_in); // cleanup
- deserialize(pdp, line, count);
- pdp->result = response_e::RESPONSE_ERROR;
- show_popup(pdp); // Showing popup
- // sending validation_result to popup-runner
- BinaryStream stream_out;
- LogDebug("pdp->result : " << pdp->result);
- CCHECKER::Serialization::Serialize(stream_out, pdp->result);
+ // Enable text line-break automatically.
+ elm_label_line_wrap_set(obj, ELM_WRAP_WORD);
+ elm_object_text_set(obj, text.c_str());
+}
- if (-1 == TEMP_FAILURE_RETRY(write(pipe_out, stream_out.char_pointer(), stream_out.size()))) {
- LogError("Write to pipe failed!");
- close(pipe_out);
- return popup_status::EXIT_ERROR;
- }
+void Popup::callbackRegister(Evas_Object *obj, ResponseType *type) noexcept
+{
+ evas_object_smart_callback_add(obj, "clicked", btnClickedCb, type);
+}
- close(pipe_out);
- LogDebug("############################ /popup binary ################################");
- LogDebug("Return: " << popup_status::NO_ERROR);
- return popup_status::NO_ERROR;
- } catch (const CCHECKER::Exception &e) {
- LogError("Exception occured in popup main.");
- return popup_status::EXIT_ERROR;
- } catch (const std::exception &e) {
- LogError("Exception occured in popup main : " << e.what());
- return popup_status::EXIT_ERROR;
- } catch (...) {
- LogError("Unhandled exception occured in popup main.");
- return popup_status::EXIT_ERROR;
- }
+void Popup::btnClickedCb(void *data, Evas_Object *, void *) noexcept
+{
+ response = *(reinterpret_cast<int *>(data));
+ LogDebug("Response : " << response);
+ elm_exit();
}
-ELM_MAIN()
diff --git a/src/ui/popup-bin/popup.h b/src/ui/popup-bin/popup.h
index a9b88b4..3245694 100644
--- a/src/ui/popup-bin/popup.h
+++ b/src/ui/popup-bin/popup.h
@@ -1,38 +1,75 @@
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016 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
+ * 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
+ * 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.
+ * 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.h
- * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @author Sangwan Kwon (sangwan.kwon@samsung.com)
* @version 1.0
+ * @brief
*/
+#pragma once
#include <Elementary.h>
+#include <string>
+#include <vector>
+#include <memory>
-#include <cchecker/UIBackend.h>
+#include "service/app.h"
-struct cert_checker_popup_data {
- std::string app_id;
- std::string pkg_id;
- CCHECKER::UI::response_e result;
+namespace CCHECKER {
+namespace UI {
- Evas_Object *popup = NULL;
- Evas_Object *win = NULL;
- Evas_Object *box = NULL;
- Evas_Object *title = NULL;
- Evas_Object *content = NULL;
- Evas_Object *keep_button = NULL;
- Evas_Object *uninstall_button = NULL;
+enum class ResponseType : int {
+ KEEP = 0x01,
+ UNINSTALL = 0x02,
};
+
+class Popup {
+public:
+ explicit Popup(const app_t &app);
+ virtual ~Popup();
+
+ Popup(const Popup &) = delete;
+ Popup &operator=(const Popup &) = delete;
+ Popup(Popup &&) = delete;
+ Popup &operator=(Popup &&) = delete;
+
+ ResponseType run(void) noexcept;
+
+private:
+ void callbackRegister(Evas_Object *obj, ResponseType *type) noexcept;
+ static void btnClickedCb(void *data, Evas_Object *, void *) noexcept;
+
+ void setDefaultProperties(Evas_Object *obj) noexcept;
+ void setText(Evas_Object *obj, const std::string &text) noexcept;
+
+ Evas_Object *m_win;
+ Evas_Object *m_popup;
+ Evas_Object *m_box;
+ Evas_Object *m_title;
+ Evas_Object *m_content;
+ Evas_Object *m_keepBtn;
+ Evas_Object *m_uninstallBtn;
+
+ static int response;
+
+ ResponseType m_keepType;
+ ResponseType m_uninstallType;
+
+ app_t m_app;
+};
+
+} // namespace UI
+} // namespace CCHECKER