summaryrefslogtreecommitdiff
path: root/src/wrt-popup
diff options
context:
space:
mode:
Diffstat (limited to 'src/wrt-popup')
-rwxr-xr-xsrc/wrt-popup/CMakeLists.txt2
-rwxr-xr-xsrc/wrt-popup/ace/CMakeLists.txt2
-rw-r--r--src/wrt-popup/ace/popup-bin/CMakeLists.txt67
-rw-r--r--src/wrt-popup/ace/popup-bin/Popup.cpp456
-rw-r--r--src/wrt-popup/ace/popup-bin/Popup.h39
-rw-r--r--src/wrt-popup/ace/popup-runner/CMakeLists.txt68
-rw-r--r--src/wrt-popup/ace/popup-runner/popup-runner.cpp290
-rw-r--r--src/wrt-popup/ace/popup-runner/popup-runner.h55
-rwxr-xr-xsrc/wrt-popup/wrt/CMakeLists.txt9
-rw-r--r--src/wrt-popup/wrt/PopupEnum.h29
-rw-r--r--src/wrt-popup/wrt/PopupSerializer.cpp57
-rw-r--r--src/wrt-popup/wrt/PopupSerializer.h33
-rw-r--r--src/wrt-popup/wrt/popup-bin/CMakeLists.txt58
-rw-r--r--src/wrt-popup/wrt/popup-bin/InfoPopup.cpp77
-rw-r--r--src/wrt-popup/wrt/popup-bin/InfoPopup.h45
-rw-r--r--src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.cpp71
-rw-r--r--src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.h52
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/evas_object.cpp234
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/evas_object.h654
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup.h70
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup_controller.cpp111
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup_controller.h216
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup_manager.cpp58
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup_manager.h117
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup_object.h170
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.cpp423
-rw-r--r--src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.h127
-rw-r--r--src/wrt-popup/wrt/popup-bin/wrt-popup.cpp189
-rw-r--r--src/wrt-popup/wrt/popup-bin/wrt-popup.h87
-rw-r--r--src/wrt-popup/wrt/popup-runner/CMakeLists.txt69
-rw-r--r--src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp203
-rw-r--r--src/wrt-popup/wrt/popup-runner/PopupInvoker.h74
32 files changed, 4212 insertions, 0 deletions
diff --git a/src/wrt-popup/CMakeLists.txt b/src/wrt-popup/CMakeLists.txt
new file mode 100755
index 0000000..13a79cc
--- /dev/null
+++ b/src/wrt-popup/CMakeLists.txt
@@ -0,0 +1,2 @@
+ADD_SUBDIRECTORY(ace)
+ADD_SUBDIRECTORY(wrt)
diff --git a/src/wrt-popup/ace/CMakeLists.txt b/src/wrt-popup/ace/CMakeLists.txt
new file mode 100755
index 0000000..2ecd23d
--- /dev/null
+++ b/src/wrt-popup/ace/CMakeLists.txt
@@ -0,0 +1,2 @@
+ADD_SUBDIRECTORY(popup-bin)
+ADD_SUBDIRECTORY(popup-runner)
diff --git a/src/wrt-popup/ace/popup-bin/CMakeLists.txt b/src/wrt-popup/ace/popup-bin/CMakeLists.txt
new file mode 100644
index 0000000..30a635c
--- /dev/null
+++ b/src/wrt-popup/ace/popup-bin/CMakeLists.txt
@@ -0,0 +1,67 @@
+# Copyright (c) 2011 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 CMakeLists.txt
+# @author Janusz Kozerski (j.kozerski@samsung.com)
+#
+# @version 1.0
+#
+
+PKG_CHECK_MODULES(WRT_POPUP_DEP
+ dpl-efl
+ elementary
+ security-client
+ security-popup-validation
+ REQUIRED)
+
+SET(WRT_POPUP_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/ace/popup-bin)
+
+SET(WRT_POPUP_SOURCES
+ ${WRT_POPUP_SRC_DIR}/Popup.cpp
+)
+
+ADD_DEFINITIONS(${WRT_POPUP_DEP_CFLAGS})
+
+INCLUDE_DIRECTORIES(
+ ${WRT_POPUP_SRC_DIR}
+ ${WRT_POPUP_DEP_INCLUDE_DIRS}
+)
+
+ADD_EXECUTABLE(${TARGET_POPUP_ACE}
+ ${WRT_POPUP_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE} PROPERTIES
+ COMPILE_DEFINITIONS LOG_TAG="${LOG_TAG}")
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE} PROPERTIES
+ COMPILE_FLAGS -fPIC
+)
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE} PROPERTIES
+ #LINK_FLAGS "-Wl,--as-needed -Wl"
+ SOVERSION ${PROJECT_API_VERSION}
+ VERSION ${PROJECT_VERSION}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_POPUP_ACE}
+ ${WRT_POPUP_DEP_LIBRARIES}
+ ${TARGET_POPUP_ACE_RUNNER_LIB}
+ ${WRT_POPUP_DEP_LDFLAGS}
+)
+
+INSTALL(TARGETS ${TARGET_POPUP_ACE}
+ DESTINATION bin
+)
diff --git a/src/wrt-popup/ace/popup-bin/Popup.cpp b/src/wrt-popup/ace/popup-bin/Popup.cpp
new file mode 100644
index 0000000..130cf3c
--- /dev/null
+++ b/src/wrt-popup/ace/popup-bin/Popup.cpp
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2011 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.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ */
+
+/*
+ * This is just a example pop-up that shows how to use a new C-API in
+ * wrt-security.
+ * This pop-up should be re-implemented by members of NGWAP.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <vector>
+#include <ctime>
+
+#include <Elementary.h>
+
+#include <dpl/log/wrt_log.h>
+#include <dpl/exception.h>
+#include <dpl/serialization.h>
+#include <ace_api_common.h>
+#include <ace_api_popup_validation.h>
+
+#include "popup-runner.h"
+#include "Popup.h"
+
+namespace { // anonymous
+static void set_validity_from_checkbox(struct ace_popup_data *pdp)
+{
+ if (NULL == pdp) {
+ WrtLogE("pdp is NULL; return");
+ return;
+ }
+
+ if (pdp->always) {
+ WrtLogD("Remember ALWAYS");
+ pdp->remember_choice = ACE_ALWAYS;
+ return;
+ }
+ if (pdp->per_session) {
+ WrtLogD("Remember PER_SESSION");
+ pdp->remember_choice = ACE_PER_SESSION;
+ return;
+ }
+ WrtLogD("Remember ONCE");
+ pdp->remember_choice = ACE_ONCE;
+ return;
+}
+
+static void on_done(void)
+{
+ // Quit the efl-mainloop
+ WrtLogD("elm_exit()");
+ elm_exit();
+}
+
+static void grant_answer(void *data,
+ Evas_Object * /* obj */,
+ void * /* event_info */)
+{
+ WrtLogD("grant_answer");
+ if (NULL == data) {
+ WrtLogE("data is NULL; return");
+ return;
+ }
+ struct ace_popup_data *pdp = static_cast <struct ace_popup_data *>(data);
+
+ set_validity_from_checkbox(pdp);
+
+ ace_popup_validation_initialize();
+ pdp->validation_return = ace_validate_answer(
+ ACE_TRUE,
+ pdp->remember_choice,
+ pdp->resource_name,
+ pdp->session_id,
+ &(pdp->param_list),
+ pdp->handle,
+ &(pdp->validation_result));
+ ace_popup_validation_shutdown();
+
+ on_done();
+}
+
+static void deny_answer(void *data,
+ Evas_Object * /* obj */,
+ void * /* event_info */)
+{
+ WrtLogD("deny_answer");
+ if (NULL == data) {
+ WrtLogE("data is NULL; return");
+ return;
+ }
+ struct ace_popup_data *pdp = static_cast <struct ace_popup_data *>(data);
+
+ set_validity_from_checkbox(pdp);
+
+ ace_popup_validation_initialize();
+ pdp->validation_return = ace_validate_answer(
+ ACE_FALSE,
+ pdp->remember_choice,
+ pdp->resource_name,
+ pdp->session_id,
+ &(pdp->param_list),
+ pdp->handle,
+ &(pdp->validation_result));
+ ace_popup_validation_shutdown();
+
+ on_done();
+}
+
+static int _ace_params_deserializer(ace_param_list_t* ace_param_list,
+ Wrt::Popup::BinaryStream *stream)
+{
+ WrtLogD("_ace_params_deserializer");
+
+ if (NULL == ace_param_list || NULL == stream) {
+ WrtLogE("ace_param_list or stream is NULL; return -1");
+ return -1;
+ }
+
+ // deserialize ace_param_list->count;
+ size_t count = 0;
+ DPL::Deserialization::Deserialize(*stream, count);
+ ace_param_list->count = count;
+ WrtLogD("count : %d", count);
+
+ std::string name;
+ std::string value;
+ if (count == 0) {
+ ace_param_list->items = NULL;
+ return 0;
+ }
+ ace_param_list->items =
+ static_cast <ace_param_t *>(malloc(count * sizeof(ace_param_t)));
+ memset(ace_param_list->items, 0, count * sizeof(ace_param_t));
+
+ for (size_t i = 0; i < count; ++i) {
+ DPL::Deserialization::Deserialize(*stream, name);
+ ace_param_list->items[i].name =
+ strdup(const_cast <char *>(name.c_str()));
+
+ DPL::Deserialization::Deserialize(*stream, value);
+ ace_param_list->items[i].value =
+ strdup(const_cast <char *>(value.c_str()));
+ }
+ return 0;
+}
+
+static void _ace_params_finalize(ace_param_list_t* ace_param_list)
+{
+ if (!ace_param_list || !ace_param_list->items) {
+ WrtLogD("List is null, nothing to do");
+ return;
+ }
+ for (size_t i = 0; i < ace_param_list->count; ++i) {
+ free(ace_param_list->items[i].name);
+ free(ace_param_list->items[i].value);
+ }
+ free(ace_param_list->items);
+ ace_param_list->items = NULL;
+ ace_param_list->count = 0;
+}
+
+static void show_popup(struct ace_popup_data *pdp)
+{
+ WrtLogD("show_popup()");
+
+ if (NULL == pdp) {
+ WrtLogE("pdp is NULL; return");
+ return;
+ }
+
+ const char *resource_type = static_cast <char *>(pdp->resource_name);
+
+ Evas_Object *win = NULL;
+ Evas_Object *box = NULL;
+ Evas_Object *label = NULL;
+ Evas_Object *grant_button = NULL;
+ Evas_Object *deny_button = NULL;
+ pdp->per_session = EINA_FALSE;
+ pdp->always = EINA_FALSE;
+
+ win = elm_win_add(NULL, "The wrt-client popup", ELM_WIN_NOTIFICATION);
+ elm_win_autodel_set(win, EINA_TRUE);
+ elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+ evas_object_show(win);
+ elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_TRANSLUCENT);
+
+ pdp->popup = elm_popup_add(win);
+
+ box = elm_box_add(pdp->popup);
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
+ evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
+
+ label = elm_label_add(pdp->popup);
+ elm_object_style_set(label, "popup_description/default");
+ elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+ char *buff = NULL;
+ if (-1 ==
+ asprintf(&buff, "Application need an access to %s.<br>Grant or deny?",
+ resource_type))
+ {
+ WrtLogE("asprintf failed - returned -1");
+ evas_object_del(label);
+ evas_object_del(pdp->popup);
+ evas_object_del(win);
+ return;
+ }
+ elm_object_text_set(label, buff);
+ free(buff);
+ evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(label);
+ elm_box_pack_end(box, label);
+
+ WrtLogD("popup_type == %d", pdp->popup_type);
+ if (pdp->popup_type == ACE_SESSION || pdp->popup_type == ACE_BLANKET) {
+ WrtLogD("popup_type == ACE_SESSION || ACE_BLANKET");
+ Evas_Object *cb_session = elm_check_add(pdp->popup);
+ elm_object_text_set(cb_session, "Remember choice for this session");
+ elm_check_state_pointer_set(cb_session, &(pdp->per_session));
+ evas_object_smart_callback_add(cb_session, "changed", NULL, NULL);
+ evas_object_size_hint_align_set(cb_session,
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(cb_session,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_show(cb_session);
+ elm_box_pack_end(box, cb_session);
+
+ if (pdp->popup_type == ACE_BLANKET) {
+ WrtLogD("popup_type == ACE_BLANKET");
+ Evas_Object *cb_always = elm_check_add(pdp->popup);
+ elm_object_text_set(cb_always, "Remember choice forever");
+ elm_check_state_pointer_set(cb_always, &(pdp->always));
+ evas_object_smart_callback_add(cb_always, "changed", NULL, NULL);
+ evas_object_size_hint_align_set(cb_always,
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(cb_always,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_show(cb_always);
+ elm_box_pack_end(box, cb_always);
+ }
+ }
+
+ elm_object_part_content_set(pdp->popup, "default", box);
+
+ grant_button = elm_button_add(pdp->popup);
+ elm_object_style_set(grant_button, "popup");
+ elm_object_text_set(grant_button, "Grant");
+ elm_object_part_content_set(pdp->popup, "button1", grant_button);
+ evas_object_smart_callback_add(grant_button, "clicked", grant_answer, pdp);
+
+ deny_button = elm_button_add(pdp->popup);
+ elm_object_style_set(deny_button, "popup");
+ elm_object_text_set(deny_button, "Deny");
+ elm_object_part_content_set(pdp->popup, "button2", deny_button);
+ evas_object_smart_callback_add(deny_button, "clicked", deny_answer, pdp);
+
+ evas_object_show(pdp->popup);
+
+ // Showing the popup window
+ evas_object_show(win);
+
+ // Run the efl mainloop
+ elm_run();
+}
+} // anonymous
+
+EAPI_MAIN int
+elm_main(int argc, char ** argv)
+{
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
+ {
+ // int pipe_in and int pipe_out should be passed to Popup via args.
+
+ // These parameters should be passed to Popup via pipe:
+ // ace_popup_t popup_type
+ // const ace_resource_t resource_name
+ // const ace_session_id_t session_id
+ // ace_widget_handle_t handle
+ // const ace_param_list_t param_list
+
+ WrtLogD("######################## popup binary ############################");
+
+ if (argc < 3) {
+ WrtLogE("To few args passed in exec to popup-bin - should be at least 3:");
+ WrtLogE("(binary-name, pipe_in, pipe_out)");
+ WrtLogE("return ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ WrtLogD("Passed args: %s, %s, %s", argv[0], argv[1], argv[2]);
+
+ int pipe_in;
+ int pipe_out;
+ std::stringstream parsing_stream;
+
+ // Parsing args (pipe_in, pipe_out)
+ parsing_stream.str(argv[1]);
+ parsing_stream >> pipe_in;
+ if ( parsing_stream.fail() ) {
+ WrtLogE("Error while parsing pipe_in; return ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ parsing_stream.clear();
+ parsing_stream.str(argv[2]);
+ parsing_stream >> pipe_out;
+ if ( parsing_stream.fail() ) {
+ WrtLogE("Error while parsing pipe_out; return ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ parsing_stream.clear();
+ WrtLogD("Parsed pipes: IN: %d, OUT: %d", pipe_in, pipe_out);
+
+ int buff_size = 1024;
+ char line[buff_size];
+
+ struct ace_popup_data pd;
+ struct ace_popup_data *pdp = &pd;
+
+ pdp->popup = NULL;
+
+ ssize_t count = 0;
+ time_t time_start;
+ time(&time_start); // now
+ double timeout = 10.0;
+ // try to read parameters from pipe_in
+ // timeout is set for 10 seconds
+ do {
+ count = TEMP_FAILURE_RETRY(read(pipe_in, line, buff_size));
+ if (timeout < difftime(time(NULL), time_start) ) {
+ WrtLogE("Timeout reached! Exit popup - ACE_INTERNAL_ERROR");
+ close(pipe_in);
+ close(pipe_out);
+ return ACE_INTERNAL_ERROR;
+ }
+ } while (0 == count);
+ if (count < 0) {
+ close(pipe_in);
+ close(pipe_out);
+ WrtLogE("read returned a negative value (%d)", count);
+ WrtLogE("errno: %s", strerror(errno));
+ WrtLogE("Exit popup - ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ WrtLogD("Read bytes : %d (in %f seconds)",
+ count, difftime(time_start, time(NULL)));
+ close(pipe_in); // cleanup
+
+ Wrt::Popup::BinaryStream stream;
+ stream.Write(count, static_cast <void *>(line));
+ int popup_type = ACE_ONESHOT;
+ std::string resource_name_str;
+ std::string session_id_str;
+ int handle = 0;
+
+ WrtLogD("------- Deserialization -------");
+ // Deserialization order:
+ // popup_type, resource_name, session_id, handle, param_list
+
+ DPL::Deserialization::Deserialize(stream, popup_type);
+ WrtLogD("popup_type_int : %d", popup_type);
+ pdp->popup_type = static_cast <ace_popup_t>(popup_type);
+
+ DPL::Deserialization::Deserialize(stream, resource_name_str);
+ WrtLogD("resource_name_char : %s", resource_name_str.c_str());
+ pdp->resource_name =
+ strdup(const_cast <ace_resource_t>(resource_name_str.c_str()));
+
+ DPL::Deserialization::Deserialize(stream, session_id_str);
+ WrtLogD("session_id_char : %s", session_id_str.c_str());
+ pdp->session_id =
+ strdup(const_cast <ace_session_id_t>(session_id_str.c_str()));
+
+ DPL::Deserialization::Deserialize(stream, handle);
+ WrtLogD("handle_int : %d", handle);
+ pdp->handle = static_cast <ace_widget_handle_t>(handle);
+
+ if (_ace_params_deserializer(&(pdp->param_list), &stream)) {
+ return ACE_INTERNAL_ERROR;
+ }
+
+ pdp->per_session = EINA_FALSE;
+ pdp->always = EINA_FALSE;
+ pdp->validation_return = ACE_ACE_UNKNOWN_ERROR;
+
+ show_popup(pdp); // Showing popup
+
+ // sending validation_result to popup-runner
+ Wrt::Popup::BinaryStream stream_out;
+
+ WrtLogD("pdp->validation_result : %d", pdp->validation_result);
+ int validation_result_int = (int) pdp->validation_result;
+ WrtLogD("validation_result_int : %d", validation_result_int);
+ DPL::Serialization::Serialize(stream_out, validation_result_int);
+ if (-1 ==
+ TEMP_FAILURE_RETRY(write(pipe_out, stream_out.char_pointer(),
+ stream_out.size())))
+ {
+ WrtLogE("Write to pipe failed!");
+ close(pipe_out);
+ return ACE_INTERNAL_ERROR;
+ }
+ close(pipe_out);
+
+ if (pdp->validation_return == ACE_OK) {
+ WrtLogD("ACE_OK");
+ } else if (pdp->validation_return == ACE_INVALID_ARGUMENTS) {
+ WrtLogE("ACE_INVALID_ARGUMENTS");
+ } else if (pdp->validation_return == ACE_INTERNAL_ERROR) {
+ WrtLogE("ACE_INTERNAL_ERROR");
+ } else if (pdp->validation_return == ACE_ACE_UNKNOWN_ERROR) {
+ WrtLogE("ACE_ACE_UNKNOWN_ERROR");
+ } else {
+ WrtLogE("Really unknown error!!!");
+ }
+
+ WrtLogD("###################### /popup binary ########################");
+
+ // Shutdown elementary
+ //WrtLogD("elm_shutdown()");
+ //elm_shutdown();
+ // This is commented because, it causes that popup exits with 139 code
+ // (Segmentatation violation).
+ // Not calling elm_shutdown() should not have any negative consequences
+ // because this binary ends
+ // in next line, and system should clear the memory.
+
+ _ace_params_finalize(&(pdp->param_list));
+ return pdp->validation_return;
+ }
+ UNHANDLED_EXCEPTION_HANDLER_END
+}
+ELM_MAIN()
diff --git a/src/wrt-popup/ace/popup-bin/Popup.h b/src/wrt-popup/ace/popup-bin/Popup.h
new file mode 100644
index 0000000..388c921
--- /dev/null
+++ b/src/wrt-popup/ace/popup-bin/Popup.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011 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.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ */
+
+#include <Elementary.h>
+#include <ace_api_common.h>
+
+struct ace_popup_data {
+ ace_popup_t popup_type;
+ ace_resource_t resource_name;
+ ace_session_id_t session_id;
+ ace_param_list_t param_list;
+ ace_widget_handle_t handle;
+ ace_bool_t validation_result;
+ ace_return_t validation_return;
+
+ Evas_Object *popup;
+ Eina_Bool per_session;
+ Eina_Bool always;
+
+ ace_validity_t remember_choice;
+};
diff --git a/src/wrt-popup/ace/popup-runner/CMakeLists.txt b/src/wrt-popup/ace/popup-runner/CMakeLists.txt
new file mode 100644
index 0000000..519303c
--- /dev/null
+++ b/src/wrt-popup/ace/popup-runner/CMakeLists.txt
@@ -0,0 +1,68 @@
+# Copyright (c) 2011 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 CMakeLists.txt
+# @author Janusz Kozerski (j.kozerski@samsung.com)
+#
+# @version 1.0
+#
+
+PKG_CHECK_MODULES(WRT_POPUP_RUNNER_LIB_DEP
+ dpl-efl
+ elementary
+ security-client
+ REQUIRED)
+
+SET(WRT_POPUP_RUNNER_LIB_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/ace/popup-runner)
+
+SET(WRT_POPUP_RUNNER_LIB_SOURCES
+ ${WRT_POPUP_RUNNER_LIB_SRC_DIR}/popup-runner.cpp
+)
+
+ADD_DEFINITIONS(${WRT_POPUP_RUNNER_LIB_DEP_CFLAGS})
+
+INCLUDE_DIRECTORIES(
+ ${WRT_POPUP_RUNNER_LIB_SRC_DIR}
+ ${WRT_POPUP_RUNNER_LIB_DEP_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(${TARGET_POPUP_ACE_RUNNER_LIB} SHARED
+ ${WRT_POPUP_RUNNER_LIB_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE_RUNNER_LIB} PROPERTIES
+ COMPILE_DEFINITIONS LOG_TAG="${LOG_TAG}")
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE_RUNNER_LIB} PROPERTIES
+ COMPILE_FLAGS -fPIC
+)
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE_RUNNER_LIB} PROPERTIES
+ SOVERSION ${CMAKE_PROJECT_API_VERSION}
+ VERSION ${CMAKE_PROJECT_VERSION}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_POPUP_ACE_RUNNER_LIB}
+ ${WRT_POPUP_RUNNER_LIB_DEP_LIBRARIES}
+ ${WRT_POPUP_RUNNER_LIB_DEP_LDFLAGS}
+)
+
+INSTALL(TARGETS ${TARGET_POPUP_ACE_RUNNER_LIB}
+ DESTINATION lib
+)
+
+INSTALL(FILES ${WRT_POPUP_RUNNER_LIB_SRC_DIR}/popup-runner.h
+ DESTINATION ${DESTINATION_HEADERS_WRT_POPUP_RUNNER}
+)
diff --git a/src/wrt-popup/ace/popup-runner/popup-runner.cpp b/src/wrt-popup/ace/popup-runner/popup-runner.cpp
new file mode 100644
index 0000000..4877876
--- /dev/null
+++ b/src/wrt-popup/ace/popup-runner/popup-runner.cpp
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2011 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.cpp
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ */
+
+/*
+ * This is just a example pop-up that shows how to use a new C-API in
+ * wrt-security.
+ * This pop-up should be re-implemented by members of NGWAP.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <iostream>
+#include <sstream>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <dpl/log/wrt_log.h>
+
+#include "popup-runner.h"
+
+namespace { // anonymous
+const char *POPUP_EXEC = "/usr/bin/wrt-popup-ace-runtime";
+
+void _ace_params_serializer (const ace_param_list_t* ace_param_list,
+ Wrt::Popup::BinaryStream *stream)
+{
+ WrtLogD("_ace_params_serializer");
+
+ if (NULL == ace_param_list || NULL == stream) {
+ WrtLogE("*ace_param_list or *stream is NULL; return");
+ return;
+ }
+ WrtLogD("Param count : %d", ace_param_list->count);
+
+ // serialize ace_param_list->count;
+ size_t count = static_cast <size_t>(ace_param_list->count);
+ DPL::Serialization::Serialize(*stream, count);
+
+ for (size_t i = 0; i < count; ++i) {
+ std::string name(ace_param_list->items[i].name);
+ DPL::Serialization::Serialize(*stream, name);
+
+ std::string value(ace_param_list->items[i].value);
+ DPL::Serialization::Serialize(*stream, value);
+ }
+}
+} // anonymous namespace
+
+namespace Wrt {
+namespace Popup {
+// BinaryStream class implementation
+void BinaryStream::Read(size_t num, void * bytes)
+{
+ size_t max_size = m_data.size();
+ for (size_t i = 0; i < num; ++i) {
+ if (i + m_readPosition >= max_size) {
+ return;
+ }
+ static_cast <unsigned char*>(bytes)[i] = m_data[i + m_readPosition];
+ }
+ m_readPosition += num;
+}
+
+void BinaryStream::Write(size_t num, const void * bytes)
+{
+ for (size_t i = 0; i < num; ++i) {
+ m_data.push_back(static_cast <const unsigned char*>(bytes)[i]);
+ }
+}
+
+BinaryStream::BinaryStream()
+{
+ m_readPosition = 0;
+}
+
+BinaryStream::~BinaryStream() {}
+
+const unsigned char* BinaryStream::char_pointer() const
+{
+ return &m_data[0];
+}
+
+size_t BinaryStream::size() const
+{
+ return m_data.size();
+}
+// BinaryStream
+
+ace_return_t run_popup(
+ ace_popup_t popup_type,
+ const ace_resource_t resource_name,
+ const ace_session_id_t session_id,
+ const ace_param_list_t* ace_param_list,
+ ace_widget_handle_t handle,
+ ace_bool_t* validation_result)
+{
+ if (NULL == resource_name ||
+ NULL == session_id ||
+ NULL == ace_param_list ||
+ NULL == validation_result)
+ {
+ WrtLogE("run_popup : ACE_INVALID_ARGUMENTS");
+ return ACE_INVALID_ARGUMENTS;
+ }
+ WrtLogD("popup_type : %d", popup_type);
+ WrtLogD("resource_name : %s", resource_name);
+ WrtLogD("session_id : %s", session_id);
+ WrtLogD("widget handle : %d", handle);
+
+ int popup_type_int = static_cast <int>(popup_type);
+ char *resource_name_char = static_cast <char *>(resource_name);
+ char *session_id_char = static_cast <char *>(session_id);
+ int handle_int = static_cast <int>(handle);
+
+ // serialization
+ Wrt::Popup::BinaryStream stream;
+ DPL::Serialization::Serialize(stream, popup_type_int);
+
+ std::string resource_name_str(resource_name_char);
+ DPL::Serialization::Serialize(stream, resource_name_str);
+
+ std::string session_id_str(session_id_char);
+ DPL::Serialization::Serialize(stream, session_id_str);
+
+ DPL::Serialization::Serialize(stream, handle_int);
+
+ _ace_params_serializer(ace_param_list, &stream);
+
+ int fd_send_to_child[2];
+ int fd_send_to_parent[2];
+ pid_t childpid;
+
+ if (0 != pipe(fd_send_to_child)) {
+ WrtLogE("Cannot create pipes!");
+ return ACE_INTERNAL_ERROR;
+ }
+ if (0 != pipe(fd_send_to_parent)) {
+ WrtLogE("Cannot create pipes!");
+ return ACE_INTERNAL_ERROR;
+ }
+
+ if ((childpid = fork()) == -1) {
+ WrtLogE("Fork() ERROR");
+ return ACE_ACE_UNKNOWN_ERROR;
+ }
+
+ if (childpid == 0) { // Child process
+ WrtLogD("Child");
+
+ // read data from parent
+ close(fd_send_to_child[1]);
+
+ // send data to parent
+ close(fd_send_to_parent[0]);
+
+ std::stringstream pipe_in_buff;
+ std::stringstream pipe_out_buff;
+ pipe_in_buff << fd_send_to_parent[1];
+ pipe_out_buff << fd_send_to_child[0];
+ std::string pipe_in = pipe_in_buff.str();
+ std::string pipe_out = pipe_out_buff.str();
+
+ WrtLogD("Passed file descriptors: %d, %d",
+ fd_send_to_child[0],
+ fd_send_to_parent[1]);
+
+ if (execl(POPUP_EXEC, POPUP_EXEC, pipe_out.c_str(), pipe_in.c_str(),
+ NULL) < 0)
+ {
+ WrtLogE("execlp FAILED");
+ }
+
+ WrtLogE("This should not happened!!!");
+ } // end of child process - from now you can use DEBUG LOGS
+ else { // Parent process
+ WrtLogD("Parent");
+
+ int buff_size = 1024;
+ char result[buff_size];
+ // send data to child
+ close(fd_send_to_child[0]);
+
+ //writing to child
+ WrtLogD("Sending message to popup-bin process");
+ if (-1 ==
+ TEMP_FAILURE_RETRY(write(fd_send_to_child[1], stream.char_pointer(),
+ stream.size())))
+ {
+ WrtLogE("Write to pipe failed!");
+ return ACE_INTERNAL_ERROR;
+ }
+ close(fd_send_to_child[1]); // cleanup
+ WrtLogD("Message has been sent");
+
+ // read data from child
+ close(fd_send_to_parent[1]);
+
+ int status;
+ wait(&status);
+ WrtLogD("STATUS EXIT ON POPUP (CHILD): %d", status);
+ switch (status) {
+ case ACE_OK:
+ WrtLogD("ACE_OK");
+ break;
+
+ case ACE_INVALID_ARGUMENTS:
+ WrtLogD("ACE_INVALID_ARGUMENTS");
+ close(fd_send_to_parent[0]);
+ return static_cast <ace_return_t>(status);
+ break;
+
+ case ACE_INTERNAL_ERROR:
+ WrtLogD("ACE_INTERNAL_ERROR");
+ close(fd_send_to_parent[0]);
+ return static_cast <ace_return_t>(status);
+ break;
+
+ case ACE_ACE_UNKNOWN_ERROR:
+ WrtLogD("ACE_ACE_UNKNOWN_ERROR");
+ close(fd_send_to_parent[0]);
+ return static_cast <ace_return_t>(status);
+ break;
+
+ default:
+ WrtLogD("UNKNOWN_ERROR");
+ close(fd_send_to_parent[0]);
+ status = (int) ACE_ACE_UNKNOWN_ERROR;
+ return static_cast <ace_return_t>(status);
+ break;
+ }
+
+ int count;
+ count = TEMP_FAILURE_RETRY(read(fd_send_to_parent[0], result, buff_size));
+ close(fd_send_to_parent[0]); // cleanup
+
+
+ if (0 < count) {
+ BinaryStream stream_in;
+ int validation_result_int;
+ stream_in.Write(count, result);
+ WrtLogD("RESULT FROM POPUP (CHILD) : [ %d ]", count);
+ DPL::Deserialization::Deserialize(stream_in, validation_result_int);
+ *validation_result = static_cast <ace_bool_t>(validation_result_int);
+
+ WrtLogD("validation_result :");
+ switch (*validation_result) {
+ case ACE_FALSE:
+ WrtLogD("ACE_FALSE");
+ break;
+ case ACE_TRUE:
+ WrtLogD("ACE_TRUE");
+ break;
+ default:
+ WrtLogD("UNKNOWN - DEFAULT");
+ break;
+ }
+ } else {
+ WrtLogD("count = %d", count);
+ WrtLogD("UNKNOWN_ERROR");
+ return ACE_ACE_UNKNOWN_ERROR;
+ }
+
+ WrtLogD("popup-runner: EXIT");
+ return (ace_return_t) status;
+ }
+
+ WrtLogE("This should not happend!!!");
+ return ACE_ACE_UNKNOWN_ERROR;
+}
+} // Popup
+} // Wrt
diff --git a/src/wrt-popup/ace/popup-runner/popup-runner.h b/src/wrt-popup/ace/popup-runner/popup-runner.h
new file mode 100644
index 0000000..d136fb1
--- /dev/null
+++ b/src/wrt-popup/ace/popup-runner/popup-runner.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 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 <ace_api_client.h>
+#include <vector>
+
+#include <dpl/serialization.h>
+
+namespace Wrt {
+namespace Popup {
+class BinaryStream : public DPL::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<unsigned char> m_data;
+ size_t m_readPosition;
+};
+
+ace_return_t run_popup(
+ ace_popup_t popup_type,
+ const ace_resource_t resource_name,
+ const ace_session_id_t session_id,
+ const ace_param_list_t* ace_param_list,
+ ace_widget_handle_t handle,
+ ace_bool_t* validation_result
+ );
+} // Popup
+} // Wrt
diff --git a/src/wrt-popup/wrt/CMakeLists.txt b/src/wrt-popup/wrt/CMakeLists.txt
new file mode 100755
index 0000000..0d89bfd
--- /dev/null
+++ b/src/wrt-popup/wrt/CMakeLists.txt
@@ -0,0 +1,9 @@
+
+SET(WRT_POPUP_COMMON_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/wrt)
+
+SET(WRT_POPUP_COMMON_SRCS
+ ${WRT_POPUP_COMMON_DIR}/PopupSerializer.cpp
+)
+
+ADD_SUBDIRECTORY(popup-bin)
+ADD_SUBDIRECTORY(popup-runner)
diff --git a/src/wrt-popup/wrt/PopupEnum.h b/src/wrt-popup/wrt/PopupEnum.h
new file mode 100644
index 0000000..3200ef4
--- /dev/null
+++ b/src/wrt-popup/wrt/PopupEnum.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+#ifndef WRT_POPUP_ENUM_H
+#define WRT_POPUP_ENUM_H
+
+namespace Wrt {
+enum PopupType {
+ INFO_PROMPT = 1,
+ YES_NO_PROMPT,
+ YES_NO_CHECK_PROMPT
+};
+}
+
+#endif
+
diff --git a/src/wrt-popup/wrt/PopupSerializer.cpp b/src/wrt-popup/wrt/PopupSerializer.cpp
new file mode 100644
index 0000000..e9dd99f
--- /dev/null
+++ b/src/wrt-popup/wrt/PopupSerializer.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+#include "PopupSerializer.h"
+
+#include <memory>
+
+namespace Wrt {
+namespace PopupSerializer {
+void appendArg(int arg, DPL::BinaryQueue &buffer)
+{
+ size_t argSize = sizeof(arg);
+ buffer.AppendCopy(&argSize, sizeof(argSize));
+ buffer.AppendCopy(&arg, sizeof(arg));
+}
+
+void appendArg(const std::string &arg, DPL::BinaryQueue &buffer)
+{
+ size_t argSize = arg.size();
+ buffer.AppendCopy(&argSize, sizeof(argSize));
+ buffer.AppendCopy(arg.c_str(), argSize);
+}
+
+int getIntArg(DPL::BinaryQueue &buffer)
+{
+ int result;
+ size_t argSize;
+ buffer.FlattenConsume(&argSize, sizeof(argSize));
+ buffer.FlattenConsume(&result, argSize);
+ //TODO: what if argSize != sizeof(int)
+ //This should not be problem if this is run on the same machine.
+ return result;
+}
+
+std::string getStringArg(DPL::BinaryQueue &buffer)
+{
+ std::string::size_type size;
+ buffer.FlattenConsume(&size, sizeof(size));
+ std::unique_ptr<char[]> str(new char[size]);
+ buffer.FlattenConsume(str.get(), size);
+ return std::string(str.get(), str.get() + size);
+}
+}
+} // Wrt
diff --git a/src/wrt-popup/wrt/PopupSerializer.h b/src/wrt-popup/wrt/PopupSerializer.h
new file mode 100644
index 0000000..70407ec
--- /dev/null
+++ b/src/wrt-popup/wrt/PopupSerializer.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+#ifndef WRT_POPUP_SERIALIZER_H
+#define WRT_POPUP_SERIALIZER_H
+
+#include <string>
+#include <dpl/binary_queue.h>
+
+namespace Wrt {
+namespace PopupSerializer {
+void appendArg(int arg, DPL::BinaryQueue &buffer);
+void appendArg(const std::string &arg, DPL::BinaryQueue &buffer);
+
+int getIntArg(DPL::BinaryQueue &buffer);
+std::string getStringArg(DPL::BinaryQueue &buffer);
+}
+} // Wrt
+
+#endif \ No newline at end of file
diff --git a/src/wrt-popup/wrt/popup-bin/CMakeLists.txt b/src/wrt-popup/wrt/popup-bin/CMakeLists.txt
new file mode 100644
index 0000000..ff393d1
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/CMakeLists.txt
@@ -0,0 +1,58 @@
+# Copyright (c) 2011 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.
+#
+
+PKG_CHECK_MODULES(WRT_POPUP_DEPS
+ ecore-x
+ dpl-efl
+ dpl-event-efl
+ REQUIRED
+)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/renderer
+ ${WRT_POPUP_DEPS_INCLUDE_DIRS}
+ ${WRT_POPUP_COMMON_DIR}
+)
+
+SET(WRT_POPUP_SRCS
+ ${WRT_POPUP_COMMON_SRCS}
+ wrt-popup.cpp
+ YesNoCheckPopup.cpp
+ InfoPopup.cpp
+ renderer/evas_object.cpp
+ renderer/popup_controller.cpp
+ renderer/popup_manager.cpp
+ renderer/popup_renderer.cpp
+)
+
+ADD_EXECUTABLE(${TARGET_POPUP_WRT}
+ ${WRT_POPUP_SRCS}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_POPUP_WRT}
+ ${WRT_POPUP_DEPS_LIBRARIES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_WRT} PROPERTIES
+ COMPILE_DEFINITIONS LOG_TAG="${LOG_TAG}")
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_WRT} PROPERTIES
+ LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
+ BUILD_WITH_INSTALL_RPATH ON
+ INSTALL_RPATH_USE_LINK_PATH ON
+)
+
+INSTALL(TARGETS ${TARGET_POPUP_WRT} DESTINATION bin)
diff --git a/src/wrt-popup/wrt/popup-bin/InfoPopup.cpp b/src/wrt-popup/wrt/popup-bin/InfoPopup.cpp
new file mode 100644
index 0000000..489c320
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/InfoPopup.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011 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 InfoPopup.cpp
+ * @author Lukasz Marek(l.marek@samsung.com)
+ * @version 1.0
+ * @brief Popup that displays information. Inplementation
+ */
+
+#include "InfoPopup.h"
+#include <memory>
+#include <string.h>
+#include "popup_manager.h"
+#include "popup.h"
+#include "PopupSerializer.h"
+
+namespace Wrt {
+namespace Popup {
+InfoPopup::InfoPopup() :
+ m_parent(NULL)
+{}
+
+void InfoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
+{
+ WrtLogD("Entered");
+ std::string title = PopupSerializer::getStringArg(*data);
+ std::string message = PopupSerializer::getStringArg(*data);
+ std::string button = PopupSerializer::getStringArg(*data);
+ Assert(data->Empty());
+ WrtLogD("title: %s message: %s", title.c_str(), message.c_str());
+
+ m_parent = parent;
+
+ Renderer::CtrlPopupPtr popup =
+ Renderer::PopupControllerSingleton::Instance().CreatePopup();
+
+ popup->SetTitle(title);
+ popup->Append(new Renderer::PopupObject::Label(message));
+
+ popup->Append(new Renderer::PopupObject::Button(button, 0));
+
+ ListenForAnswer(popup);
+
+ Renderer::ShowPopupEventShort event(popup,
+ MakeAnswerCallback(
+ this,
+ &InfoPopup::responseCallback));
+
+ CONTROLLER_POST_EVENT(Renderer::PopupController,
+ event);
+
+ WrtLogD("Exited");
+ return;
+}
+
+void InfoPopup::responseCallback(const Renderer::AnswerCallbackData &answer)
+{
+ DPL::BinaryQueue retValue;
+ PopupSerializer::appendArg(true, retValue);
+ PopupSerializer::appendArg(answer.buttonAnswer, retValue);
+ m_parent->response(retValue);
+}
+} // Popup
+} // Wrt
diff --git a/src/wrt-popup/wrt/popup-bin/InfoPopup.h b/src/wrt-popup/wrt/popup-bin/InfoPopup.h
new file mode 100644
index 0000000..3a29fc0
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/InfoPopup.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 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 InfoPopup.h
+ * @author Andrzej Surdej (a.surdej@samsung.com)
+ * @version 1.0
+ * @brief Popup that contains 'Yes' and 'No' buttons
+ */
+
+#ifndef WRT_INFO_POPUP_H
+#define WRT_INFO_POPUP_H
+
+#include "wrt-popup.h"
+
+namespace Wrt {
+namespace Popup {
+class InfoPopup : public IPopup
+{
+ public:
+ InfoPopup();
+ virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent);
+
+ private:
+
+ void responseCallback(const Renderer::AnswerCallbackData &answer);
+ WrtPopup* m_parent;
+};
+} // Popup
+} // Wrt
+
+#endif /* WRT_INFO_POPUP_H */
+
diff --git a/src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.cpp b/src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.cpp
new file mode 100644
index 0000000..fa6619d
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.cpp
@@ -0,0 +1,71 @@
+/*
+ * File: YesNoCheckPopup.cpp
+ * Author: pciezkowski
+ *
+ * Created on December 12, 2012, 9:23 AM
+ */
+
+#include "YesNoCheckPopup.h"
+#include <memory>
+#include <string.h>
+#include "popup_manager.h"
+#include "PopupSerializer.h"
+
+namespace Wrt {
+namespace Popup {
+YesNoCheckPopup::~YesNoCheckPopup()
+{}
+
+void YesNoCheckPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
+{
+ WrtLogD("Entered");
+ m_parent = parent;
+ Renderer::CtrlPopupPtr popup = createPopup(data);
+ ListenForAnswer(popup);
+
+ Renderer::ShowPopupEventShort event(popup,
+ MakeAnswerCallback(
+ this,
+ &YesNoCheckPopup::responseCallback));
+
+ CONTROLLER_POST_EVENT(Renderer::PopupController,
+ event);
+
+ WrtLogD("Exited");
+ return;
+}
+
+Renderer::CtrlPopupPtr YesNoCheckPopup::createPopup(
+ DPL::BinaryQueueAutoPtr data)
+{
+ std::string title = PopupSerializer::getStringArg(*data);
+ std::string message = PopupSerializer::getStringArg(*data);
+ std::string checkboxLabel = PopupSerializer::getStringArg(*data);
+ Assert(data->Empty());
+ WrtLogD("title: %s message: %s, checkbox: %s",
+ title.c_str(), message.c_str(), checkboxLabel.c_str());
+ Renderer::CtrlPopupPtr popup =
+ Renderer::PopupControllerSingleton::Instance().CreatePopup();
+
+ popup->SetTitle(title);
+ popup->Append(new Renderer::PopupObject::Label(message));
+ popup->Append(new Renderer::PopupObject::Check(checkboxLabel));
+ popup->Append(new Renderer::PopupObject::Button(YES_LABEL, POPUP_YES_VALUE));
+ popup->Append(new Renderer::PopupObject::Button(NO_LABEL, POPUP_NO_VALUE));
+ return popup;
+}
+
+void YesNoCheckPopup::responseCallback(
+ const Renderer::AnswerCallbackData &answer)
+{
+ WrtLogD("Entered");
+ bool result = (POPUP_YES_VALUE == answer.buttonAnswer);
+ DPL::BinaryQueue retValue;
+ PopupSerializer::appendArg(true, retValue);
+ PopupSerializer::appendArg(result, retValue);
+ WrtLogD("Check state: %d", answer.chackState);
+ PopupSerializer::appendArg(answer.chackState, retValue);
+ m_parent->response(retValue);
+}
+} // Popup
+} // Wrt
diff --git a/src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.h b/src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.h
new file mode 100644
index 0000000..635518a
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/YesNoCheckPopup.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 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 YesNoCheckPopup.cpp
+ * @author Przmeyslaw Ciezkowsko (p.ciezkowski@samsung.com)
+ * @version 1.0
+ * @brief Popup that contains 'Yes' and 'No' buttons and checkbox.
+ * Inplementation
+ */
+
+#include "wrt-popup.h"
+
+#ifndef WRT_YES_NO_CHECK_POPUP_H
+#define WRT_YES_NO_CHECK_POPUP_H
+
+namespace Wrt {
+namespace Popup {
+
+const char YES_LABEL[] = "Yes";
+const char NO_LABEL[] = "No";
+const int POPUP_YES_VALUE = 1;
+const int POPUP_NO_VALUE = 2;
+
+class YesNoCheckPopup : public IPopup
+{
+ public:
+ virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent);
+ virtual ~YesNoCheckPopup();
+
+ protected:
+ virtual Renderer::CtrlPopupPtr createPopup(DPL::BinaryQueueAutoPtr data);
+ virtual void responseCallback(const Renderer::AnswerCallbackData &answer);
+ WrtPopup* m_parent;
+};
+} // Popup
+} // Wrt
+
+#endif /* WRT_YES_NO_CHECK_POPUP_H */
+
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/evas_object.cpp b/src/wrt-popup/wrt/popup-bin/renderer/evas_object.cpp
new file mode 100644
index 0000000..13b38c1
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/evas_object.cpp
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2011 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 evas_object.cpp
+ * @author Lukasz Wrzosek (l.wrzosel@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation for Evas_Object wrapper from
+ * Efl.
+ */
+
+#include "evas_object.h"
+#include <stddef.h>
+#include <dpl/foreach.h>
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+Evas_Object* EvasObject::IConnection::GetEvasObject()
+{
+ return m_object->GetObject();
+}
+
+void EvasObject::IConnection::Disconnect()
+{
+ m_object->DisconnectCallback(this);
+}
+
+EvasObject::IConnection::IConnection(EvasObject::EvasObjectShared* object) :
+ m_object(object)
+{}
+
+void EvasObject::IConnection::SmartCallbackWrapper(void* data,
+ Evas_Object* /*object*/,
+ void* event_info)
+{
+ Assert(data);
+ IConnection* Calle = static_cast<IConnection*>(data);
+ Calle->Call(event_info);
+}
+
+void EvasObject::IConnection::EvasCallbackWrapper(void* data,
+ Evas* /*evas*/,
+ Evas_Object* /*object*/,
+ void* event_info)
+{
+ Assert(data);
+ IConnection* Calle = static_cast<IConnection*>(data);
+ Calle->Call(event_info);
+}
+
+Evas_Object* EvasObject::EvasObjectShared::GetObject()
+{
+ return m_object;
+}
+
+EvasObject::EvasObjectShared::SmartConnectionBase::SmartConnectionBase(
+ const std::string& name,
+ EvasObject::EvasObjectShared* object) :
+ IConnection(object),
+ m_callbackName(name)
+{}
+
+void EvasObject::EvasObjectShared::SmartConnectionBase::ConnectPrv()
+{
+ evas_object_smart_callback_add(GetEvasObject(),
+ m_callbackName.c_str(),
+ &IConnection::SmartCallbackWrapper, this);
+}
+
+void EvasObject::EvasObjectShared::SmartConnectionBase::DisconnectPrv()
+{
+ evas_object_smart_callback_del(GetEvasObject(),
+ m_callbackName.c_str(),
+ &IConnection::SmartCallbackWrapper);
+}
+
+EvasObject::EvasObjectShared::EvasConnectionBase::EvasConnectionBase(
+ Evas_Callback_Type type,
+ EvasObject::EvasObjectShared* object) :
+ IConnection(object),
+ m_callbackType(type)
+{}
+
+void EvasObject::EvasObjectShared::EvasConnectionBase::ConnectPrv()
+{
+ evas_object_event_callback_add(
+ GetEvasObject(), m_callbackType, &IConnection::EvasCallbackWrapper,
+ this);
+}
+
+void EvasObject::EvasObjectShared::EvasConnectionBase::DisconnectPrv()
+{
+ evas_object_event_callback_del_full(
+ GetEvasObject(), m_callbackType, &IConnection::EvasCallbackWrapper,
+ this);
+}
+
+EvasObject::EvasObjectShared::EvasObjectShared() :
+ m_object(NULL)
+{}
+
+EvasObject::EvasObjectShared::EvasObjectShared(Evas_Object* object) :
+ m_object(object)
+{
+ Assert(m_object);
+ evas_object_event_callback_add(m_object,
+ EVAS_CALLBACK_DEL,
+ &StaticOnDelEvent,
+ this);
+}
+
+void EvasObject::EvasObjectShared::SetObject(Evas_Object* object)
+{
+ Assert(m_object == NULL);
+ Assert(object != NULL);
+ m_object = object;
+ evas_object_event_callback_add(m_object,
+ EVAS_CALLBACK_DEL,
+ &StaticOnDelEvent,
+ this);
+}
+
+EvasObject::EvasObjectShared::~EvasObjectShared()
+{
+ if (m_object) {
+ DisconnectAll();
+ evas_object_event_callback_del(m_object,
+ EVAS_CALLBACK_DEL,
+ &StaticOnDelEvent);
+ m_object = NULL;
+ }
+}
+
+bool EvasObject::EvasObjectShared::DisconnectCallback(IConnection* connection)
+{
+ IConnectionsSet::iterator it = m_connections.find(connection);
+ if (it != m_connections.end()) {
+ (*it)->DisconnectPrv();
+ delete connection;
+ m_connections.erase(it);
+ return true;
+ }
+ return false;
+}
+
+void EvasObject::EvasObjectShared::DisconnectAll()
+{
+ FOREACH(it, m_connections)
+ {
+ (*it)->DisconnectPrv();
+ delete *it;
+ }
+ m_connections.clear();
+}
+
+void EvasObject::EvasObjectShared::StaticOnDelEvent(void* data,
+ Evas* /*e*/,
+ Evas_Object* /*o*/,
+ void* /*ev*/)
+{
+ Assert(data);
+ EvasObjectShared* This = static_cast<EvasObjectShared*>(data);
+ if (This->m_object) {
+ evas_object_event_callback_del(This->m_object,
+ EVAS_CALLBACK_DEL,
+ &StaticOnDelEvent);
+ This->DisconnectAll();
+ This->m_object = NULL;
+ }
+}
+
+EvasObject::EvasObject() :
+ m_object(new EvasObjectShared())
+{}
+
+EvasObject::EvasObject(Evas_Object* object) :
+ m_object(new EvasObjectShared(object))
+{}
+
+EvasObject::EvasObject(const EvasObject& other) :
+ m_object(other.m_object)
+{}
+
+//this destructor must be here to let pimpl with shared_ptr work without warning
+EvasObject::~EvasObject()
+{}
+
+EvasObject& EvasObject::operator=(const EvasObject& other)
+{
+ Assert(m_object);
+ m_object = other.m_object;
+ return *this;
+}
+
+EvasObject* EvasObject::operator=(Evas_Object* object)
+{
+ Assert(m_object);
+ m_object->SetObject(object);
+ return this;
+}
+
+bool EvasObject::DisconnectCallback(IConnection* connection)
+{
+ Assert(m_object);
+ return m_object->DisconnectCallback(connection);
+}
+
+void EvasObject::DisconnectAll()
+{
+ Assert(m_object);
+ m_object->DisconnectAll();
+}
+
+EvasObject::operator Evas_Object *()
+{
+ Assert(m_object);
+ return m_object->GetObject();
+}
+}
+} // namespace DPL
+} // namespace Popup
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/evas_object.h b/src/wrt-popup/wrt/popup-bin/renderer/evas_object.h
new file mode 100644
index 0000000..2758fa1
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/evas_object.h
@@ -0,0 +1,654 @@
+/*
+ * Copyright (c) 2011 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 evas_object.h
+ * @author Lukasz Wrzosek (l.wrzosel@samsung.com)
+ * @version 1.0
+ * @brief This file is the header for Evas_Object wrapper from Efl.
+ */
+
+#ifndef WRT_SRC_DOMAIN_EFL_EVAS_OBJECT_H
+#define WRT_SRC_DOMAIN_EFL_EVAS_OBJECT_H
+
+#include <Evas.h>
+#include <dpl/noncopyable.h>
+#include <dpl/framework_efl.h>
+#include <dpl/assert.h>
+#include <dpl/foreach.h>
+#include <dpl/apply.h>
+#include <set>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <memory>
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+class EvasObject
+{
+ class EvasObjectShared;
+ typedef std::shared_ptr<EvasObjectShared> EvasObjectSharedPtr;
+
+ public:
+ class IConnection
+ {
+ public:
+ Evas_Object* GetEvasObject();
+ void Disconnect();
+
+ private:
+ IConnection(EvasObjectShared* object);
+ virtual ~IConnection()
+ {}
+ virtual void Call(void* /*event_info*/) = 0;
+
+ static void SmartCallbackWrapper(void* data,
+ Evas_Object* /*object*/,
+ void* event_info);
+ static void EvasCallbackWrapper(void* data,
+ Evas* /*evas*/,
+ Evas_Object* /*object*/,
+ void* event_info);
+
+ virtual void ConnectPrv() = 0;
+ virtual void DisconnectPrv() = 0;
+
+ friend class EvasObjectShared;
+
+ EvasObjectShared* m_object;
+ };
+
+ private:
+ class EvasObjectShared : DPL::Noncopyable
+ {
+ public:
+ friend class IConnection;
+ Evas_Object* GetObject();
+
+ typedef std::set<IConnection*> IConnectionsSet;
+
+ class SmartConnectionBase : public IConnection
+ {
+ public:
+ SmartConnectionBase(const std::string& name,
+ EvasObjectShared* object);
+
+ virtual void ConnectPrv();
+ virtual void DisconnectPrv();
+ std::string m_callbackName;
+ };
+
+ template<typename ... Args>
+ class SmartConnection : public SmartConnectionBase
+ {
+ public:
+ typedef void (*CbType)(IConnection* connection,
+ void* event_info,
+ Args ... args);
+
+ SmartConnection(const std::string& name,
+ CbType callback,
+ EvasObjectShared* object,
+ Args ... args) :
+ SmartConnectionBase(name, object),
+ m_callback(callback),
+ m_args(args ...)
+ {}
+
+ virtual ~SmartConnection()
+ {}
+
+ virtual void Call(void* event_info)
+ {
+ DPL::Apply<void,
+ DPL::ExtraArgsInsertPolicy::Prepend>(m_callback,
+ m_args,
+ this,
+ event_info);
+ }
+
+ private:
+ CbType m_callback;
+ std::tuple<Args ...> m_args;
+ };
+
+ template <class ThisType, class ArgType1>
+ class SmartMemberConnection1 : public SmartConnectionBase
+ {
+ public:
+ typedef void (ThisType::*CbType)(IConnection* connection,
+ void* event_info, ArgType1 *arg1);
+
+ SmartMemberConnection1(const std::string& name,
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ EvasObjectShared* object) :
+ SmartConnectionBase(name, object),
+ m_callback(callback),
+ m_callee(callee),
+ m_arg1(arg1)
+ {}
+
+ virtual ~SmartMemberConnection1()
+ {}
+
+ virtual void Call(void* event_info)
+ {
+ (m_callee->*m_callback)(this, event_info, m_arg1);
+ }
+
+ private:
+ CbType m_callback;
+ ThisType* m_callee;
+ ArgType1* m_arg1;
+ };
+
+ template <class ThisType, class ArgType1, class ArgType2>
+ class SmartMemberConnection2 : public SmartConnectionBase
+ {
+ public:
+ typedef void (ThisType::*CbType)(IConnection* connection,
+ void* event_info, ArgType1 *arg1,
+ ArgType2* arg2);
+
+ SmartMemberConnection2(const std::string& name,
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2,
+ EvasObjectShared* object) :
+ SmartConnectionBase(name, object),
+ m_callback(callback),
+ m_callee(callee),
+ m_arg1(arg1),
+ m_arg2(arg2)
+ {}
+
+ virtual ~SmartMemberConnection2()
+ {}
+
+ virtual void Call(void* event_info)
+ {
+ (m_callee->*m_callback)(this, event_info, m_arg1, m_arg2);
+ }
+
+ private:
+ CbType m_callback;
+ ThisType* m_callee;
+ ArgType1* m_arg1;
+ ArgType2* m_arg2;
+ };
+
+ class EvasConnectionBase : public IConnection
+ {
+ public:
+ EvasConnectionBase(Evas_Callback_Type type,
+ EvasObjectShared* object);
+
+ virtual void ConnectPrv();
+ virtual void DisconnectPrv();
+
+ Evas_Callback_Type m_callbackType;
+ };
+
+ template <class ArgType1>
+ class EvasConnection1 : public EvasConnectionBase
+ {
+ public:
+ typedef void (*CbType)(IConnection* connection, void* event_info,
+ ArgType1 *arg1);
+
+ EvasConnection1(Evas_Callback_Type type,
+ CbType callback,
+ ArgType1* arg1,
+ EvasObjectShared* object) :
+ EvasConnectionBase(type, object),
+ m_callback(callback),
+ m_arg1(arg1)
+ {}
+
+ virtual ~EvasConnection1()
+ {}
+
+ virtual void Call(void* event_info)
+ {
+ m_callback(this, event_info, m_arg1);
+ }
+
+ private:
+ CbType m_callback;
+ ArgType1* m_arg1;
+ };
+
+ template <class ArgType1, class ArgType2>
+ class EvasConnection2 : public EvasConnectionBase
+ {
+ public:
+ typedef void (*CbType)(IConnection* connection, void* event_info,
+ ArgType1 *arg1, ArgType2 *arg2);
+
+ EvasConnection2(Evas_Callback_Type type,
+ CbType callback,
+ ArgType1* arg1,
+ ArgType2* arg2,
+ EvasObjectShared* object) :
+ EvasConnectionBase(type, object),
+ m_callback(callback),
+ m_arg1(arg1),
+ m_arg2(arg2)
+ {}
+
+ virtual ~EvasConnection2()
+ {}
+
+ virtual void Call(void* event_info)
+ {
+ m_callback(this, event_info, m_arg1, m_arg2);
+ }
+
+ private:
+ CbType m_callback;
+ ArgType1* m_arg1;
+ ArgType2* m_arg2;
+ };
+
+ template <class ThisType, class ArgType1>
+ class EvasMemberConnection1 : public EvasConnectionBase
+ {
+ public:
+ typedef void (ThisType::*CbType)(IConnection* connection,
+ void* event_info, ArgType1 *arg1);
+
+ EvasMemberConnection1(Evas_Callback_Type type,
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ EvasObjectShared* object) :
+ EvasConnectionBase(type, object),
+ m_callback(callback),
+ m_callee(callee),
+ m_arg1(arg1)
+ {}
+
+ virtual ~EvasMemberConnection1()
+ {}
+
+ virtual void Call(void* event_info)
+ {
+ (m_callee->*m_callback)(this, event_info, m_arg1);
+ }
+
+ private:
+ CbType m_callback;
+ ThisType* m_callee;
+ ArgType1* m_arg1;
+ };
+
+ template <class ThisType, class ArgType1, class ArgType2>
+ class EvasMemberConnection2 : public EvasConnectionBase
+ {
+ public:
+ typedef void (ThisType::*CbType)(IConnection* connection,
+ void* event_info, ArgType1* arg1,
+ ArgType2* arg2);
+
+ EvasMemberConnection2(Evas_Callback_Type type,
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2,
+ EvasObjectShared* object) :
+ EvasConnectionBase(type, object),
+ m_callback(callback),
+ m_callee(callee),
+ m_arg1(arg1),
+ m_arg2(arg2)
+ {}
+
+ virtual ~EvasMemberConnection2()
+ {}
+
+ virtual void Call(void* event_info)
+ {
+ (m_callee->*m_callback)(this, event_info, m_arg1, m_arg2);
+ }
+
+ private:
+ CbType m_callback;
+ ThisType* m_callee;
+ ArgType1* m_arg1;
+ ArgType2* m_arg2;
+ };
+
+ EvasObjectShared();
+ explicit EvasObjectShared(Evas_Object* object);
+ void SetObject(Evas_Object* object);
+ ~EvasObjectShared();
+
+ template<typename ... Args>
+ IConnection* ConnectSmartCallback(
+ const char* callbackName,
+ typename SmartConnection<Args ...>::
+ CbType callback,
+ Args ... args)
+ {
+ Assert(m_object);
+ Assert(callbackName);
+ Assert(callback);
+ IConnection* connection = new SmartConnection<Args ...>(
+ callbackName,
+ callback,
+ this,
+ args ...);
+ m_connections.insert(connection);
+ connection->ConnectPrv();
+ return connection;
+ }
+
+ template <class ThisType, class ArgType1, class ArgType2>
+ IConnection* ConnectMemberSmartCallback(
+ const char* callbackName,
+ typename SmartMemberConnection2<ThisType, ArgType1,
+ ArgType2>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callbackName);
+ Assert(callback);
+ IConnection* connection =
+ new SmartMemberConnection2<ThisType, ArgType1, ArgType2>(
+ callbackName,
+ callback,
+ callee,
+ arg1,
+ arg2,
+ this);
+ m_connections.insert(connection);
+ connection->ConnectPrv();
+ return connection;
+ }
+
+ template <class ThisType, class ArgType1>
+ IConnection* ConnectMemberSmartCallback(
+ const char* callbackName,
+ typename SmartMemberConnection1<ThisType,
+ ArgType1>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callbackName);
+ Assert(callback);
+ IConnection* connection =
+ new SmartMemberConnection1<ThisType, ArgType1>(callbackName,
+ callback,
+ callee,
+ arg1,
+ this);
+ m_connections.insert(connection);
+ connection->ConnectPrv();
+ return connection;
+ }
+
+ template <class ArgType1, class ArgType2>
+ IConnection* ConnectEvasCallback(Evas_Callback_Type callbackType,
+ typename EvasConnection2<ArgType1,
+ ArgType2>::
+ CbType callback,
+ ArgType1* arg1,
+ ArgType2* arg2)
+ {
+ Assert(m_object);
+ Assert(callbackType);
+ Assert(callback);
+ IConnection* connection = new EvasConnection2<ArgType1, ArgType2>(
+ callbackType,
+ callback,
+ arg1,
+ arg2,
+ this);
+ m_connections.insert(connection);
+ connection->ConnectPrv();
+ return connection;
+ }
+
+ template <class ArgType1>
+ IConnection* ConnectEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasConnection1<ArgType1>::
+ CbType callback,
+ ArgType1* arg1)
+ {
+ Assert(m_object);
+ Assert(callbackType);
+ Assert(callback);
+ IConnection* connection = new EvasConnection1<ArgType1>(
+ callbackType,
+ callback,
+ arg1,
+ this);
+ m_connections.insert(connection);
+ connection->ConnectPrv();
+ return connection;
+ }
+
+ template <class ThisType, class ArgType1, class ArgType2>
+ IConnection* ConnectMemberEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasMemberConnection2<ThisType, ArgType1,
+ ArgType2>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callbackType);
+ Assert(callback);
+ IConnection* connection =
+ new EvasMemberConnection2<ThisType, ArgType1, ArgType2>(
+ callbackType,
+ callback,
+ callee,
+ arg1,
+ arg2,
+ this);
+ m_connections.insert(connection);
+ connection->ConnectPrv();
+ return connection;
+ }
+
+ template <class ThisType, class ArgType1>
+ IConnection* ConnectMemberEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasMemberConnection1<ThisType,
+ ArgType1>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callbackType);
+ Assert(callback);
+ IConnection* connection =
+ new EvasMemberConnection1<ThisType, ArgType1>(callbackType,
+ callback,
+ callee,
+ arg1,
+ this);
+ m_connections.insert(connection);
+ connection->ConnectPrv();
+ return connection;
+ }
+
+ bool DisconnectCallback(IConnection* connection);
+ void DisconnectAll();
+
+ static void StaticOnDelEvent(void* data,
+ Evas* /*e*/,
+ Evas_Object* /*o*/,
+ void* /*ev*/);
+
+ IConnectionsSet m_connections;
+ Evas_Object* m_object;
+ };
+
+ public:
+ EvasObject();
+ explicit EvasObject(Evas_Object* object);
+ EvasObject(const EvasObject& other);
+ ~EvasObject();
+
+ EvasObject& operator=(const EvasObject& other);
+ EvasObject* operator=(Evas_Object* object);
+
+ operator Evas_Object *();
+
+ bool IsValid() const
+ {
+ Assert(m_object);
+ return m_object->GetObject() != NULL;
+ }
+
+ bool DisconnectCallback(IConnection* connection);
+ void DisconnectAll();
+
+ template <class ... Args>
+ IConnection* ConnectSmartCallback(
+ const char* callbackName,
+ typename EvasObjectShared::SmartConnection<Args ...>::CbType
+ callback,
+ Args ... args)
+ {
+ Assert(m_object);
+ return m_object->ConnectSmartCallback(callbackName, callback, args ...);
+ }
+
+ template <class ThisType, class ArgType1, class ArgType2>
+ IConnection* ConnectMemberSmartCallback(
+ const char* callbackName,
+ typename EvasObjectShared::SmartMemberConnection2<ThisType,
+ ArgType1,
+ ArgType2>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callback);
+ return m_object->ConnectMemberSmartCallback(callbackName,
+ callback,
+ callee,
+ arg1,
+ arg2);
+ }
+
+ template <class ThisType, class ArgType1>
+ IConnection* ConnectMemberSmartCallback(
+ const char* callbackName,
+ typename EvasObjectShared::SmartMemberConnection1<ThisType,
+ ArgType1>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callback);
+ return m_object->ConnectMemberSmartCallback(callbackName,
+ callback,
+ callee,
+ arg1);
+ }
+
+ template <class ArgType1, class ArgType2>
+ IConnection* ConnectEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
+ callback,
+ ArgType1* arg1,
+ ArgType2* arg2)
+ {
+ Assert(m_object);
+ return m_object->ConnectEvasCallback(callbackType, callback, arg1, arg2);
+ }
+
+ template <class ArgType1>
+ IConnection* ConnectEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
+ callback,
+ ArgType1* arg1)
+ {
+ Assert(m_object);
+ return m_object->ConnectEvasCallback(callbackType, callback, arg1);
+ }
+
+ template <class ThisType, class ArgType1>
+ IConnection* ConnectMemberEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasMemberConnection1<ThisType,
+ ArgType1>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callback);
+ return m_object->ConnectMemberEvasCallback(callbackType,
+ callback,
+ callee,
+ arg1);
+ }
+
+ template <class ThisType, class ArgType1, class ArgType2>
+ IConnection* ConnectMemberEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasMemberConnection2<ThisType, ArgType1,
+ ArgType2>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
+ {
+ Assert(m_object);
+ Assert(callee);
+ Assert(callback);
+ return m_object->ConnectMemberEvasCallback(callbackType,
+ callback,
+ callee,
+ arg1,
+ arg2);
+ }
+
+ private:
+ EvasObjectSharedPtr m_object;
+};
+}
+} //namespace
+} //namespace
+
+#endif //WRT_SRC_DOMAIN_EFL_EVAS_OBJECT_H
+
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup.h b/src/wrt-popup/wrt/popup-bin/renderer/popup.h
new file mode 100644
index 0000000..c9e75b0
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011 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.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief This is popup inteface declaration
+ */
+
+#ifndef WRT_SRC_POPUP_POPUP_H_
+#define WRT_SRC_POPUP_POPUP_H_
+
+#include <memory>
+#include <dpl/assert.h>
+#include <dpl/log/wrt_log.h>
+#include <string>
+#include <dpl/optional_typedefs.h>
+#include "popup_object.h"
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+struct AnswerCallbackData
+{
+ int buttonAnswer;
+ DPL::OptionalStdString password;
+ bool chackState;
+};
+
+class PopupManager;
+class IPopup;
+typedef std::shared_ptr<IPopup> IPopupPtr;
+
+class IPopup : public std::enable_shared_from_this<IPopup>
+{
+ public:
+ virtual void SetTitle(const std::string &title) = 0;
+ /*The object is deleted automatically after rendered */
+ virtual void Append(PopupObject::IPopupObject *object) = 0;
+
+ protected:
+ typedef void (*PopupCallbackType)(const AnswerCallbackData& answer,
+ void *data);
+ virtual void Show(PopupCallbackType callback,
+ void* data) = 0;
+ virtual ~IPopup()
+ {}
+
+ private:
+ friend class PopupManager;
+ friend class std::shared_ptr<IPopup>;
+};
+}
+} // namespace Popup
+} // namespace Wrt
+
+#endif //WRT_SRC_POPUP_POPUP_H_
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup_controller.cpp b/src/wrt-popup/wrt/popup-bin/renderer/popup_controller.cpp
new file mode 100644
index 0000000..6cc404f
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup_controller.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2011 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_controller.cpp
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @bref Implementation file for popup controller
+ */
+
+#include "popup_controller.h"
+#include <stddef.h>
+#include <dpl/assert.h>
+#include <dpl/log/wrt_log.h>
+#include <dpl/singleton_impl.h>
+
+IMPLEMENT_SINGLETON(Wrt::Popup::Renderer::PopupController)
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+void CtrlPopup::SetTitle(const std::string &title)
+{
+ Assert(m_popup);
+ m_popup->SetTitle(title);
+}
+
+void CtrlPopup::Append(PopupObject::IPopupObject *object)
+{
+ Assert(m_popup);
+ m_popup->Append(object);
+}
+
+CtrlPopup::CtrlPopup(IPopupPtr popup) :
+ m_popup(popup),
+ m_callback()
+{
+ Assert(m_popup);
+}
+
+CtrlPopup::~CtrlPopup()
+{}
+
+void CtrlPopup::EmitAnswer(const AnswerCallbackData & answer)
+{
+ AnswerCallbackData l_answer = answer;
+ PopupAnswerEvent event(shared_from_this(), m_callback, l_answer);
+ DPL::Event::EventSupport<PopupAnswerEvent>::EmitEvent(event);
+}
+
+PopupController::PopupController() : m_canvas(NULL)
+{}
+
+CtrlPopupPtr PopupController::CreatePopup() const
+{
+ return CtrlPopupPtr(
+ new CtrlPopup(PopupManagerSingleton::Instance().CreatePopup()));
+}
+
+void PopupController::OnEventReceived(const ShowPopupEventShort& event)
+{
+ CtrlPopupPtr popup = event.GetArg0();
+ popup->m_callback = event.GetArg1();
+
+ //pass canvas from controller to manager
+ //canvas is not passed earlier because value wasn't set properly
+ PopupManagerSingleton::Instance().setExternalCanvas(getExternalCanvas());
+
+ PopupManagerSingleton::Instance().RunAsyncWithArgType(
+ popup->m_popup,
+ &PopupController::StaticOnAnswerReceived,
+ new CtrlPopupPtr(popup));
+}
+
+void PopupController::StaticOnAnswerReceived(const AnswerCallbackData & answer,
+ CtrlPopupPtr* popup)
+{
+ Assert(popup != NULL);
+ (*popup)->EmitAnswer(answer);
+ delete popup; // Just SharedPtr is destroyed, not the popup itself
+}
+
+void PopupControllerUser::OnEventReceived(const PopupAnswerEvent& event)
+{
+ //Here we are in a proper context to call the callback
+ PopupAnswerCallback answerCall = event.GetArg1();
+ AnswerCallbackData answer = event.GetArg2();
+ answerCall.Call(answer);
+ event.GetArg0()->DPL::Event::EventSupport<PopupAnswerEvent>::RemoveListener(
+ this);
+}
+
+void PopupControllerUser::ListenForAnswer(CtrlPopupPtr popup)
+{
+ popup->DPL::Event::EventSupport<PopupAnswerEvent>::AddListener(this);
+}
+}
+} //namespace Popup
+} //namespace Wrt
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup_controller.h b/src/wrt-popup/wrt/popup-bin/renderer/popup_controller.h
new file mode 100644
index 0000000..0d81695
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup_controller.h
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2011 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_controller.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @bref Header file for popup controller
+ */
+
+/**
+ * To display a popup from a given class:
+ *
+ * class ABC
+ * {
+ * void AskUser()
+ * {
+ * }
+ *
+ * void DoSomeLogicWithAnswer()
+ * {
+ * }
+ * };
+ *
+ * ... update the class to something simmilar:
+ *
+ * class ABC : Popup::PopupControllerUser
+ * {
+ * void AskUser() {
+ * using namespace Popup;
+ * CtrlPopupPtr popup =
+ * PopupControllerSingletion::Instance().CreatePopup();
+ * popup->SetTitle("Title");
+ * popup->SetContent("Content");
+ * popup->AddButton("name1", 1);
+ * popup->AddButton("name2", 2);
+ * ListenForAnswer(popup);
+ * ShowPopupEvent event(popup,
+ * MakeAnswerCallback(this,
+ * &ABC::DoSomeLogicWithAnswer));
+ * CONTROLLER_POST_EVENT(PopupController, event);
+ * }
+ *
+ * void DoSomeLogicWithAnswer(Popup::LabelId answer) {
+ * if (answer == 1)
+ * ;//name1 pressed
+ * else if (answer == 2)
+ * ;//name2 pressed
+ * }
+ * };
+ **/
+
+#ifndef WRT_SRC_POPUP_CONTROLLER_POPUP_CONTROLLER_H_
+#define WRT_SRC_POPUP_CONTROLLER_POPUP_CONTROLLER_H_
+
+#include <memory>
+#include <dpl/singleton.h>
+#include <dpl/event/controller.h>
+#include <dpl/event/event_listener.h>
+#include <dpl/generic_event.h>
+#include <dpl/mutex.h>
+#include <dpl/exception.h>
+#include <dpl/noncopyable.h>
+#include <dpl/log/wrt_log.h>
+#include "popup_manager.h"
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+typedef int LabelId;
+
+struct PopupAnswerCallback
+{
+ typedef void (PopupAnswerCallback::*MemberPtr)();
+
+ void* callee;
+ MemberPtr member;
+ void (*callTranslator)(PopupAnswerCallback* callData,
+ const AnswerCallbackData& answer);
+
+ void Call(const AnswerCallbackData& answer)
+ {
+ callTranslator(this, answer);
+ }
+};
+
+class PopupController;
+class CtrlPopup;
+
+typedef std::shared_ptr<CtrlPopup> CtrlPopupPtr;
+
+DECLARE_GENERIC_EVENT_3(PopupAnswerEvent,
+ CtrlPopupPtr,
+ PopupAnswerCallback,
+ AnswerCallbackData)
+
+DECLARE_GENERIC_EVENT_2(ShowPopupEventShort,
+ CtrlPopupPtr,
+ PopupAnswerCallback)
+
+class CtrlPopup : public DPL::Event::EventSupport<PopupAnswerEvent>,
+ public std::enable_shared_from_this<CtrlPopup>
+{
+ public:
+ void SetTitle(const std::string &title);
+ void Append(PopupObject::IPopupObject *object);
+
+ ~CtrlPopup();
+
+ private:
+ friend class PopupController;
+ friend class std::shared_ptr<CtrlPopup>;
+
+ explicit CtrlPopup(IPopupPtr popup);
+ void EmitAnswer(const AnswerCallbackData& answer);
+
+ IPopupPtr m_popup;
+ PopupAnswerCallback m_callback;
+};
+
+class PopupController :
+ public DPL::Event::Controller<DPL::TypeListDecl<ShowPopupEventShort>::Type>
+{
+ public:
+ CtrlPopupPtr CreatePopup() const;
+
+ void setExternalCanvas(void* canvas)
+ {
+ m_canvas = canvas;
+ }
+ void* getExternalCanvas() const
+ {
+ return m_canvas;
+ }
+ void* m_canvas;
+
+ protected:
+ virtual void OnEventReceived(const ShowPopupEventShort& event);
+ PopupController();
+
+ private:
+ static void StaticOnAnswerReceived(const AnswerCallbackData& answer,
+ CtrlPopupPtr* popup);
+};
+
+class PopupControllerUser : DPL::Event::EventListener<PopupAnswerEvent>
+{
+ template <class Type>
+ struct PopupAnswerCallbackCreator
+ {
+ typedef void (Type::*MemberPtr)(const AnswerCallbackData& answer);
+ union Caster
+ {
+ MemberPtr specific;
+ PopupAnswerCallback::MemberPtr generic;
+ };
+
+ static PopupAnswerCallback Create(Type* callee,
+ MemberPtr callback)
+ {
+ PopupAnswerCallback callData;
+
+ callData.callee = callee;
+
+ Caster caster;
+ caster.specific = callback;
+ callData.member = caster.generic;
+
+ callData.callTranslator =
+ &PopupAnswerCallbackCreator::MemberCallbackTranslator;
+
+ return callData;
+ }
+
+ static void MemberCallbackTranslator(PopupAnswerCallback* callData,
+ const AnswerCallbackData& answer)
+ {
+ Type* typedThis = static_cast<Type*>(callData->callee);
+ Caster caster;
+ caster.generic = callData->member;
+ MemberPtr typedCallback = caster.specific;
+ (typedThis->*typedCallback)(answer);
+ }
+ };
+
+ protected:
+ virtual void OnEventReceived(const PopupAnswerEvent& event);
+ void ListenForAnswer(CtrlPopupPtr popup);
+
+ template <class Type>
+ PopupAnswerCallback MakeAnswerCallback(Type* This,
+ void (Type::*callback)
+ (const AnswerCallbackData &))
+ {
+ return PopupAnswerCallbackCreator<Type>::Create(This, callback);
+ }
+};
+
+typedef DPL::Singleton<PopupController> PopupControllerSingleton;
+}
+} //namespace Popup
+} //namespace Wrt
+
+#endif //WRT_SRC_POPUP_CONTROLLER_POPUP_CONTROLLER_H_
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup_manager.cpp b/src/wrt-popup/wrt/popup-bin/renderer/popup_manager.cpp
new file mode 100644
index 0000000..8bbb380
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup_manager.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 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_manager.cpp
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief This is popup_manager implementation file
+ */
+
+#include "popup_manager.h"
+#include <stddef.h>
+#include <dpl/log/wrt_log.h>
+#include <dpl/assert.h>
+#include <dpl/singleton_impl.h>
+#include "popup.h"
+
+IMPLEMENT_SINGLETON(Wrt::Popup::Renderer::PopupManager)
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+void PopupManager::Initialize(PopupRendererPtr renderer)
+{
+ Assert(!m_initialized);
+ m_popupRenderer = renderer;
+ m_popupRenderer->Initialize();
+ m_initialized = true;
+}
+
+void PopupManager::Deinitialize()
+{
+ m_popupRenderer->Deinitialize();
+ Assert(m_initialized);
+ m_popupRenderer.reset();
+ m_initialized = false;
+}
+
+IPopupPtr PopupManager::CreatePopup()
+{
+ Assert(m_initialized);
+ return m_popupRenderer->CreatePopup();
+}
+}
+} // namespace Popup
+} // namespace Wrt
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup_manager.h b/src/wrt-popup/wrt/popup-bin/renderer/popup_manager.h
new file mode 100644
index 0000000..a254d5c
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup_manager.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011 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_manager.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief This is popup_manager declaration file
+ */
+
+#ifndef WRT_SRC_POPUP_POPUP_MANAGER_H_
+#define WRT_SRC_POPUP_POPUP_MANAGER_H_
+
+#include <memory>
+#include <dpl/assert.h>
+#include <dpl/noncopyable.h>
+#include <dpl/singleton.h>
+#include <dpl/log/wrt_log.h>
+#include "popup.h"
+#include "popup_renderer.h"
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+class PopupManager : DPL::Noncopyable
+{
+ template <class ArgType>
+ struct TemplatedPopupCallback
+ {
+ typedef void (*Type)(const AnswerCallbackData& answer, ArgType* data);
+ };
+
+ public:
+ PopupManager() : m_initialized(false) {}
+ ~PopupManager()
+ {
+ if (m_initialized) {
+ WrtLogE("Destroyed without Deinitialize");
+ }
+ }
+ void Initialize (PopupRendererPtr creator);
+ void Deinitialize();
+ void SetPopupRenderer (PopupRendererPtr creator);
+ IPopupPtr CreatePopup();
+
+ template <class ArgType>
+ void RunAsyncWithArgType(
+ IPopupPtr popup,
+ typename TemplatedPopupCallback<ArgType>::Type
+ callback,
+ ArgType* argument)
+ {
+ Assert(callback);
+ WrapCbAndArg<ArgType>* wrapped =
+ new WrapCbAndArg<ArgType>(callback, argument);
+ popup->Show(&CallbackArgTypeTranslator<ArgType>, wrapped);
+ }
+
+ void Show(IPopupPtr popup,
+ IPopup::PopupCallbackType callback,
+ void* userdata)
+ {
+ popup->Show(callback, userdata);
+ }
+
+ void setExternalCanvas(void* externalCanvas)
+ {
+ AssertMsg(m_initialized, "Manger should be initialized");
+ m_popupRenderer->setExternalCanvas(externalCanvas);
+ }
+
+ private:
+ template <class ArgType>
+ struct WrapCbAndArg
+ {
+ WrapCbAndArg(typename TemplatedPopupCallback<ArgType>::Type cb,
+ ArgType* arg) :
+ callback(cb),
+ argument(arg)
+ {}
+
+ typename TemplatedPopupCallback<ArgType>::Type callback;
+ ArgType* argument;
+ };
+
+ template <class ArgType>
+ static void CallbackArgTypeTranslator(const AnswerCallbackData & answer,
+ void* data)
+ {
+ WrapCbAndArg<ArgType>* wrapped =
+ static_cast< WrapCbAndArg<ArgType>* >(data);
+ wrapped->callback(answer, wrapped->argument);
+ delete wrapped;
+ }
+
+ bool m_initialized;
+ PopupRendererPtr m_popupRenderer;
+};
+
+typedef DPL::Singleton<PopupManager> PopupManagerSingleton;
+}
+} // namespace Popup
+} // namespace Wrt
+
+#endif //WRT_SRC_POPUP_POPUP_MANAGER_H_
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup_object.h b/src/wrt-popup/wrt/popup-bin/renderer/popup_object.h
new file mode 100644
index 0000000..86f7484
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup_object.h
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2011 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_object.h
+ * @author Justyna Mejzner (j.mejzner@samsung.com)
+ * @version 1.0
+ * @brief This is declaration file of PopupObject
+ */
+
+#ifndef WRT_SRC_POPUP_POPUPOBJECT_H_
+#define WRT_SRC_POPUP_POPUPOBJECT_H_
+
+#include <dpl/foreach.h>
+
+#include <list>
+#include <string>
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+namespace PopupObject {
+class IPopupObject;
+class PopupObjectBase;
+class Button;
+class Label;
+class Check;
+
+typedef std::list<IPopupObject*> PopupObjects;
+
+enum PopupType
+{
+ BUTTON,
+ LABEL,
+ CHECK
+};
+
+class IPopupObject
+{
+ public:
+ virtual Button* asButton() = 0;
+ virtual Label* asLabel() = 0;
+ virtual Check* asCheck() = 0;
+ virtual PopupType getType() const = 0;
+ virtual ~IPopupObject()
+ {}
+};
+
+class PopupObjectBase : public IPopupObject
+{
+ public:
+ virtual Button* asButton()
+ {
+ Assert("wrong type");
+ return NULL;
+ }
+ virtual Label* asLabel()
+ {
+ Assert("wrong type");
+ return NULL;
+ }
+ virtual Check* asCheck()
+ {
+ Assert("wrong type");
+ return NULL;
+ }
+
+ PopupType getType() const
+ {
+ return m_type;
+ }
+
+ protected:
+ PopupObjectBase(PopupType type) : m_type(type)
+ {}
+
+ PopupType m_type;
+};
+
+class Button : public PopupObjectBase
+{
+ public:
+ Button(const std::string& label,
+ int labelId) :
+ PopupObjectBase(BUTTON),
+ m_label(label),
+ m_labelId(labelId)
+ {}
+
+ Button* asButton()
+ {
+ return this;
+ }
+
+ const std::string& getLabel() const
+ {
+ return m_label;
+ }
+
+ int getLabelId() const
+ {
+ return m_labelId;
+ }
+
+ private:
+ std::string m_label;
+ int m_labelId;
+};
+
+class Label : public PopupObjectBase
+{
+ public:
+ Label(const std::string &label) :
+ PopupObjectBase(LABEL),
+ m_label(label)
+ {}
+
+ Label* asLabel()
+ {
+ return this;
+ }
+
+ const std::string& getLabel() const
+ {
+ return m_label;
+ }
+
+ private:
+ std::string m_label;
+};
+
+class Check : public PopupObjectBase
+{
+ public:
+ Check(const std::string &label) :
+ PopupObjectBase(CHECK),
+ m_checkLabel(label)
+ {}
+
+ Check* asCheck()
+ {
+ return this;
+ }
+
+ const std::string& getCheckLabel() const
+ {
+ return m_checkLabel;
+ }
+
+ private:
+ std::string m_checkLabel;
+};
+} /*PopupObject*/
+}
+} //namespace Popup
+} //namespace Wrt
+
+#endif //WRT_SRC_POPUP_POPUPOBJECT_H_
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.cpp b/src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.cpp
new file mode 100644
index 0000000..609d3c1
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.cpp
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 2011 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_renderer.cpp
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief This is efl specific implementation for PopupRenderer
+ */
+
+#include "popup_renderer.h"
+#include <stddef.h>
+#include <dpl/assert.h>
+#include <dpl/log/wrt_log.h>
+#include <dpl/foreach.h>
+#include <dpl/framework_efl.h>
+#include <dpl/lexical_cast.h>
+#include <queue>
+#include "popup_manager.h"
+#include "popup_manager.h"
+#include "evas_object.h"
+
+namespace Wrt {
+namespace {
+using namespace Popup;
+const char* EDJ_NAME = "/usr/share/edje/ace/generic_popup.edj";
+const char* POPUP_LAYOUT1 = "popup_layout1";
+const char* POPUP_LAYOUT2 = "popup_layout2";
+const char* POPUP_PART_TITLE = "title,text";
+const char* POPUP_PART_BUTTON1 = "button1";
+const char* POPUP_PART_BUTTON2 = "button2";
+const char* POPUP_PART_BUTTON3 = "button3";
+const char* BUTTON_CLICKED_CALLBACK_NAME = "clicked";
+const char* CHANGED_CALLBACK_NAME = "changed";
+const unsigned int MAX_NUMBER_OF_VERTICAL = 2;
+
+Evas_Object* create_layout_main(Evas_Object* parent, int totalV)
+{
+ Evas_Object *layout = elm_layout_add(parent);
+
+ if (totalV == 1) {
+ elm_layout_file_set(layout, EDJ_NAME, POPUP_LAYOUT1);
+ } else if (totalV == 2) {
+ elm_layout_file_set(layout, EDJ_NAME, POPUP_LAYOUT2);
+ } else {
+ Assert(!"popup needs define new group in the edc");
+ }
+
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ return layout;
+}
+} //namespace
+
+namespace Popup {
+namespace Renderer {
+class PopupRenderer::Impl
+{
+ public:
+ Impl() :
+ m_popupsToRender(),
+ m_current(),
+ m_initialized(false),
+ m_checkState(false),
+ m_themeIndexV(0),
+ m_externalCanvas(NULL)
+ {}
+
+ ~Impl()
+ {
+ if (m_initialized) {
+ WrtLogE("Destroyed without Deinitialize");
+ }
+ }
+
+ void Initialize()
+ {
+ Assert(!m_initialized);
+ m_initialized = true;
+ }
+
+ void Deinitialize()
+ {
+ Assert(m_initialized);
+ m_current.reset();
+ while (!m_popupsToRender.empty()) {
+ m_popupsToRender.pop();
+ }
+ m_initialized = false;
+ }
+
+ void ButtonCallback(EvasObject::IConnection* /*connection*/,
+ void* /*event_info*/,
+ void* data)
+ {
+ WrtLogD("ButtonCallback");
+ Assert(m_initialized);
+ AnswerCallbackData answerData;
+
+ answerData.buttonAnswer = reinterpret_cast<int>(data);
+ answerData.chackState = m_checkState;
+ answerData.password = m_password;
+ m_current->ForwardAnswer(answerData);
+ m_current.reset();
+
+ FOREACH(it, m_createdObjects)
+ {
+ if (it->IsValid()) {
+ evas_object_del(*it);
+ }
+ }
+ m_createdObjects.clear();
+ m_checkState = false;
+ DoRender();
+ }
+
+ void CheckCallback(EvasObject::IConnection* connection,
+ void* /*event_info*/,
+ void* /* unused */)
+ {
+ m_checkState =
+ elm_check_state_get(connection->GetEvasObject());
+ }
+
+ void Render (PopupPtr popup)
+ {
+ Assert(m_initialized);
+ m_popupsToRender.push(popup);
+ DoRender();
+ }
+
+ void DoRender(const PopupObject::Label& object,
+ EvasObject& parent,
+ EvasObject& layout,
+ int themeIndex)
+ {
+ EvasObject label(elm_label_add(parent));
+
+ elm_object_style_set(label, "popup_description/default");
+ elm_label_line_wrap_set(label, ELM_WRAP_WORD);
+ elm_object_text_set(label, object.getLabel().c_str());
+ evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(label);
+
+ elm_object_part_content_set(
+ layout,
+ DPL::lexical_cast<std::string>(themeIndex).c_str(),
+ label);
+ m_createdObjects.push_back(label);
+ }
+
+ void DoRender(const PopupObject::Check& object,
+ EvasObject& parent,
+ EvasObject& layout,
+ int themeIndex)
+ {
+ EvasObject check(elm_check_add(parent));
+
+ evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
+ elm_object_text_set(check,
+ object.getCheckLabel().c_str());
+ elm_object_part_content_set(
+ layout,
+ DPL::lexical_cast<std::string>(themeIndex).c_str(),
+ check);
+
+ check.ConnectMemberSmartCallback(CHANGED_CALLBACK_NAME,
+ &Impl::CheckCallback,
+ this,
+ static_cast<void*>(NULL));
+ evas_object_show(check);
+ m_createdObjects.push_back(check);
+ }
+
+ void DoRender(const PopupObject::Button& object,
+ EvasObject &parent)
+ {
+ EvasObject btn(elm_button_add(parent));
+
+ elm_object_style_set(btn, "popup");
+ elm_object_text_set(btn, object.getLabel().c_str());
+ elm_object_part_content_set(parent, POPUP_PART_BUTTON1, btn);
+ btn.ConnectMemberSmartCallback(BUTTON_CLICKED_CALLBACK_NAME,
+ &Impl::ButtonCallback,
+ this,
+ reinterpret_cast<void*>(object.
+ getLabelId()));
+ m_createdObjects.push_back(btn);
+ }
+
+ void DoRender(const PopupObject::Button& object1,
+ const PopupObject::Button& object2,
+ EvasObject &parent)
+ {
+ DoRender(object1, parent);
+
+ EvasObject btn2(elm_button_add(parent));
+
+ elm_object_style_set(btn2, "popup");
+ elm_object_text_set(btn2, object2.getLabel().c_str());
+ elm_object_part_content_set(parent, POPUP_PART_BUTTON2, btn2);
+ btn2.ConnectMemberSmartCallback(BUTTON_CLICKED_CALLBACK_NAME,
+ &Impl::ButtonCallback,
+ this,
+ reinterpret_cast<void*>(object2.
+ getLabelId()));
+ m_createdObjects.push_back(btn2);
+ }
+
+ void DoRender(const PopupObject::Button& object1,
+ const PopupObject::Button& object2,
+ const PopupObject::Button& object3,
+ EvasObject &parent)
+ {
+ DoRender(object1, object2, parent);
+
+ EvasObject btn3(elm_button_add(parent));
+
+ elm_object_style_set(btn3, "popup");
+ elm_object_text_set(btn3, object3.getLabel().c_str());
+ elm_object_part_content_set(parent, POPUP_PART_BUTTON3, btn3);
+ btn3.ConnectMemberSmartCallback(BUTTON_CLICKED_CALLBACK_NAME,
+ &Impl::ButtonCallback,
+ this,
+ reinterpret_cast<void*>(object3.
+ getLabelId()));
+ m_createdObjects.push_back(btn3);
+ }
+
+ EvasObject getBaseObject()
+ {
+ if (getExternalCanvas() == NULL) {
+ WrtLogD("Create old style popup");
+ EvasObject win(elm_win_add(NULL, "Popup", ELM_WIN_DIALOG_BASIC));
+ elm_win_borderless_set(win, EINA_TRUE);
+ elm_win_alpha_set(win, EINA_TRUE);
+ elm_win_raise(win);
+ {
+ int w, h, x, y;
+ ecore_x_window_geometry_get(ecore_x_window_root_first_get(),
+ &x,
+ &y,
+ &w,
+ &h);
+ evas_object_resize(win, w, h);
+ evas_object_move(win, x, y);
+ }
+ m_createdObjects.push_back(win);
+ evas_object_show(win);
+ return win;
+ } else {
+ WrtLogD("Create new style popup");
+ EvasObject win(getExternalCanvas());
+ evas_object_show(win);
+ return win;
+ }
+ }
+
+ void DoRender()
+ {
+ if (!m_current && !m_popupsToRender.empty()) {
+ m_current = m_popupsToRender.front();
+ m_popupsToRender.pop();
+
+ m_themeIndexV = 0;
+
+ // preprocessing
+ std::vector<int> countPopupObjects = { 0 /* PopupObject::BUTTON */,
+ 0 /* PopupObject::LABEL */,
+ 0 /* PopupObject::CHECK */ };
+ FOREACH(it, m_current->GetPopupObjects()) {
+ AssertMsg((*it)->getType() < countPopupObjects.size(),
+ "Wrong PopupObject assigned");
+ countPopupObjects[(*it)->getType()]++;
+ }
+ int needsIndexV = countPopupObjects[PopupObject::LABEL] +
+ countPopupObjects[PopupObject::CHECK];
+
+ EvasObject win = getBaseObject();
+ EvasObject main(elm_popup_add(win));
+
+ evas_object_size_hint_weight_set(main,
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_object_part_text_set(main,
+ POPUP_PART_TITLE,
+ m_current->GetTitle().c_str());
+
+ m_createdObjects.push_back(main);
+ std::vector<PopupObject::Button> buttonObjectList;
+ EvasObject layout(create_layout_main(main, needsIndexV));
+ m_createdObjects.push_back(layout);
+
+ FOREACH(it, m_current->GetPopupObjects()) {
+ switch ((*it)->getType()) {
+ case PopupObject::BUTTON:
+ buttonObjectList.push_back(*(*it)->asButton());
+ break;
+ case PopupObject::LABEL:
+ DoRender(*(*it)->asLabel(),
+ main,
+ layout,
+ m_themeIndexV++);
+ break;
+ case PopupObject::CHECK:
+ DoRender(*(*it)->asCheck(),
+ main,
+ layout,
+ m_themeIndexV++);
+ break;
+ default:
+ Assert(!"incorrect type");
+ }
+ Assert(m_themeIndexV <= MAX_NUMBER_OF_VERTICAL);
+ }
+ elm_object_content_set(main,
+ layout);
+
+ // show buution
+ switch (buttonObjectList.size()) {
+ case 0:
+ WrtLogD("no button");
+ break;
+ case 1:
+ DoRender(buttonObjectList.at(0),
+ main);
+ break;
+ case 2:
+ DoRender(buttonObjectList.at(0),
+ buttonObjectList.at(1),
+ main);
+ break;
+ case 3:
+ DoRender(buttonObjectList.at(0),
+ buttonObjectList.at(1),
+ buttonObjectList.at(2),
+ main);
+ break;
+ default:
+ Assert(!"incorrect button number");
+ break;
+ }
+
+ evas_object_show(main);
+ }
+ }
+
+ void setExternalCanvas(void* externalCanvas)
+ {
+ m_externalCanvas = static_cast<Evas_Object*>(externalCanvas);
+ }
+
+ Evas_Object* getExternalCanvas() const
+ {
+ return m_externalCanvas;
+ }
+
+ std::queue<PopupPtr> m_popupsToRender;
+ std::list<EvasObject> m_createdObjects;
+ PopupPtr m_current;
+ bool m_initialized;
+ bool m_checkState;
+ DPL::OptionalStdString m_password;
+ unsigned int m_themeIndexV;
+
+ private:
+ Evas_Object* m_externalCanvas;
+};
+
+PopupRenderer::PopupRenderer()
+{
+ m_impl = new PopupRenderer::Impl();
+}
+
+PopupRenderer::~PopupRenderer()
+{
+ delete m_impl;
+}
+
+void PopupRenderer::Initialize()
+{
+ Assert(m_impl);
+ m_impl->Initialize();
+}
+
+void PopupRenderer::Deinitialize()
+{
+ Assert(m_impl);
+ m_impl->Deinitialize();
+}
+
+IPopupPtr PopupRenderer::CreatePopup()
+{
+ return std::static_pointer_cast<IPopup>(IPopupPtr
+ (new Popup(shared_from_this())));
+}
+
+void PopupRenderer::Render(PopupPtr popup)
+{
+ m_impl->Render(popup);
+}
+
+void PopupRenderer::setExternalCanvas(void* externalCanvas)
+{
+ m_impl->setExternalCanvas(externalCanvas);
+}
+}
+} // namespace Popup
+} // namespace Wrt
diff --git a/src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.h b/src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.h
new file mode 100644
index 0000000..98eeb05
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/renderer/popup_renderer.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2011 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_renderer.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief This is declaration file of PopupRenderer
+ */
+
+#ifndef WRT_SRC_POPUP_POPUP_RENDERER_H_
+#define WRT_SRC_POPUP_POPUP_RENDERER_H_
+
+#include <map>
+#include <string>
+#include <memory>
+
+#include <dpl/noncopyable.h>
+#include <dpl/log/wrt_log.h>
+#include <dpl/assert.h>
+#include <dpl/foreach.h>
+#include "popup.h"
+
+namespace Wrt {
+namespace Popup {
+namespace Renderer {
+class PopupRenderer : public std::enable_shared_from_this<PopupRenderer>
+{
+ public:
+ PopupRenderer();
+ ~PopupRenderer();
+ void Initialize();
+ void Deinitialize();
+ IPopupPtr CreatePopup();
+ virtual void setExternalCanvas(void* externalCanvas);
+
+ protected:
+ class Popup;
+ typedef std::shared_ptr<Popup> PopupPtr;
+
+ class Popup : public IPopup
+ {
+ public:
+ typedef std::map<int, std::string> ButtonMap;
+ virtual void SetTitle(const std::string &title)
+ {
+ WrtLogD("%s", title.c_str());
+ Assert(m_title.empty());
+ m_title = title;
+ }
+
+ virtual void Append(PopupObject::IPopupObject *object)
+ {
+ m_popupObjectList.push_back(object);
+ }
+
+ virtual void Show(IPopup::PopupCallbackType callback,
+ void* data)
+ {
+ Assert(callback);
+ m_data = data;
+ m_callback = callback;
+ m_renderer->Render(std::static_pointer_cast<Popup>(shared_from_this()));
+ }
+
+ const std::string& GetTitle() const
+ {
+ return m_title;
+ }
+
+ PopupObject::PopupObjects& GetPopupObjects()
+ {
+ return m_popupObjectList;
+ }
+
+ virtual ~Popup()
+ {
+ FOREACH(it, m_popupObjectList) {
+ delete *it;
+ }
+ }
+
+ private:
+ friend class PopupRenderer;
+ friend class std::shared_ptr<Popup>;
+ friend class PopupObjectTheme;
+
+ Popup(std::shared_ptr<PopupRenderer> renderer) : m_renderer(renderer)
+ {}
+
+ void ForwardAnswer(const AnswerCallbackData & answer) const
+ {
+ m_callback(answer, m_data);
+ }
+
+ std::string m_title;
+ void* m_data;
+ IPopup::PopupCallbackType m_callback;
+ PopupObject::PopupObjects m_popupObjectList;
+ std::shared_ptr<PopupRenderer> m_renderer;
+ };
+
+ private:
+ void Render (PopupPtr popup);
+
+ class Impl;
+ Impl* m_impl;
+};
+
+typedef std::shared_ptr<PopupRenderer> PopupRendererPtr;
+}
+} // namespace Popup
+} // namespace Wrt
+
+#endif //WRT_SRC_POPUP_POPUP_RENDERER_H_
diff --git a/src/wrt-popup/wrt/popup-bin/wrt-popup.cpp b/src/wrt-popup/wrt/popup-bin/wrt-popup.cpp
new file mode 100644
index 0000000..330da9c
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/wrt-popup.cpp
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+#include "wrt-popup.h"
+#include <limits>
+#include <memory>
+
+#include <aul.h>
+#include <dpl/log/wrt_log.h>
+#include <dpl/exception.h>
+#include <dpl/assert.h>
+
+#include "PopupEnum.h"
+#include "PopupSerializer.h"
+#include "InfoPopup.h"
+#include "YesNoCheckPopup.h"
+
+namespace Wrt {
+namespace Popup {
+bool WrtPopup::openPipes()
+{
+ Try
+ {
+ if (m_argc != 3) {
+ WrtLogE("Wrong arguments!");
+ return false;
+ }
+ m_input.Open(m_argv[1]);
+ //open output pipe
+ m_output.Open(m_argv[2]);
+
+ DPL::WaitableHandleWatchSupport::InheritedContext()->
+ AddWaitableHandleWatch(this,
+ m_input.WaitableReadHandle(),
+ DPL::WaitMode::Read);
+ m_pipesOpened = true;
+ return true;
+ }
+ Catch(DPL::Exception)
+ {
+ WrtLogE("cannot open pipes");
+ }
+ return false;
+}
+
+void WrtPopup::closePipes()
+{
+ Try
+ {
+ if (m_pipesOpened) {
+ DPL::WaitableHandleWatchSupport::InheritedContext()->
+ RemoveWaitableHandleWatch(this,
+ m_input.WaitableReadHandle(),
+ DPL::WaitMode::Read);
+ m_input.Close();
+ m_output.Close();
+ m_pipesOpened = false;
+ }
+ }
+ Catch(DPL::Exception)
+ {
+ WrtLogE("cannot close pipes");
+ }
+}
+
+void WrtPopup::OnEventReceived(const QuitEvent & /* event */)
+{
+ WrtLogD("Quiting");
+ closePipes();
+ Quit();
+}
+
+void WrtPopup::OnWaitableHandleEvent(DPL::WaitableHandle waitableHandle,
+ DPL::WaitMode::Type /*mode*/)
+{
+ if (waitableHandle == m_input.WaitableReadHandle()) {
+ readInputData();
+ }
+}
+
+void WrtPopup::readInputData()
+{
+ DPL::BinaryQueueAutoPtr data =
+ m_input.Read(std::numeric_limits<std::size_t>::max());
+ int popupType = PopupSerializer::getIntArg(*data);
+ WrtLogD("popup type %d", popupType);
+ switch (popupType) {
+ case INFO_PROMPT:
+ m_popup.reset(new InfoPopup());
+ m_popup->show(data, this);
+ break;
+ case YES_NO_CHECK_PROMPT:
+ m_popup.reset(new YesNoCheckPopup());
+ m_popup->show(data, this);
+ break;
+ default:
+ Assert(false);
+ }
+}
+
+void WrtPopup::response(DPL::BinaryQueue result)
+{
+ m_output.Write(result, result.Size());
+ PostEvent(QuitEvent());
+}
+
+void WrtPopup::OnStop()
+{
+ WrtLogD("On Stop");
+}
+
+void WrtPopup::OnCreate()
+{
+ if (!openPipes()) {
+ PostEvent(QuitEvent());
+ }
+ WrtLogD("On Create");
+}
+
+void WrtPopup::OnResume()
+{
+ WrtLogD("OnResume");
+}
+
+void WrtPopup::OnPause()
+{
+ WrtLogD("OnPause");
+}
+
+void WrtPopup::OnReset(bundle * /*b*/)
+{
+ WrtLogD("OnReset");
+}
+
+void WrtPopup::OnTerminate()
+{
+ WrtLogD("Wrt Shutdown now");
+}
+
+WrtPopup::WrtPopup(int argc, char **argv) :
+ Application(argc, argv, "wrt-popup", false),
+ m_pipesOpened(false)
+{
+ Touch();
+ Renderer::PopupControllerSingleton::Instance().Touch();
+ Renderer::PopupManagerSingleton::Instance().Initialize(
+ Renderer::PopupRendererPtr(new Renderer::PopupRenderer));
+ WrtLogD("App Created");
+}
+
+WrtPopup::~WrtPopup()
+{
+ Renderer::PopupManagerSingleton::Instance().Deinitialize();
+ WrtLogD("App Finished");
+}
+}
+}
+
+int main(int argc, char *argv[])
+{
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
+ {
+ // Output on stdout will be flushed after every newline character,
+ // even if it is redirected to a pipe. This is useful for running
+ // from a script and parsing output.
+ // (Standard behavior of stdlib is to use full buffering when
+ // redirected to a pipe, which means even after an end of line
+ // the output may not be flushed).
+ setlinebuf(stdout);
+
+ Wrt::Popup::WrtPopup app(argc, argv);
+ int ret = app.Exec();
+ WrtLogD("App returned: %d", ret);
+ return ret;
+ }
+ UNHANDLED_EXCEPTION_HANDLER_END
+}
diff --git a/src/wrt-popup/wrt/popup-bin/wrt-popup.h b/src/wrt-popup/wrt/popup-bin/wrt-popup.h
new file mode 100644
index 0000000..ab9c519
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-bin/wrt-popup.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+#ifndef WRT_POPUP_H
+#define WRT_POPUP_H
+
+#include <memory>
+#include <dpl/application.h>
+#include <dpl/generic_event.h>
+#include <dpl/event/controller.h>
+#include <dpl/type_list.h>
+#include <dpl/named_input_pipe.h>
+#include <dpl/named_output_pipe.h>
+#include <dpl/waitable_handle_watch_support.h>
+#include <dpl/binary_queue.h>
+#include "popup_controller.h"
+
+namespace Wrt {
+namespace Popup {
+DECLARE_GENERIC_EVENT_0(QuitEvent)
+class WrtPopup;
+
+class IPopup : public Renderer::PopupControllerUser
+{
+ public:
+ virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent) = 0;
+ virtual ~IPopup() {}
+};
+
+typedef std::unique_ptr<IPopup> IPopupPtr;
+
+class WrtPopup :
+ public DPL::WaitableHandleWatchSupport::WaitableHandleListener,
+ public DPL::Application,
+ private DPL::Event::Controller<DPL::TypeListDecl<QuitEvent>::Type>
+{
+ public:
+ WrtPopup(int argc, char **argv);
+ virtual ~WrtPopup();
+
+ void response(DPL::BinaryQueue result);
+
+ protected:
+ //DPL::Application functions
+ virtual void OnStop();
+ virtual void OnCreate();
+ virtual void OnResume();
+ virtual void OnPause();
+ virtual void OnReset(bundle *b);
+ virtual void OnTerminate();
+ virtual void OnEventReceived(const QuitEvent &event);
+ virtual void OnWaitableHandleEvent(DPL::WaitableHandle waitableHandle,
+ DPL::WaitMode::Type mode);
+
+ private:
+
+ void showAcePrompt(DPL::BinaryQueueAutoPtr data);
+ void communicationBoxResponse(int buttonAnswer,
+ bool checkState,
+ void* userdata);
+ bool m_pipesOpened;
+ IPopupPtr m_popup;
+
+ bool openPipes();
+ void closePipes();
+ void readInputData();
+
+ DPL::NamedInputPipe m_input;
+ DPL::NamedOutputPipe m_output;
+};
+}
+}
+
+#endif // WRT_POPUP_H
diff --git a/src/wrt-popup/wrt/popup-runner/CMakeLists.txt b/src/wrt-popup/wrt/popup-runner/CMakeLists.txt
new file mode 100644
index 0000000..24970e1
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-runner/CMakeLists.txt
@@ -0,0 +1,69 @@
+# Copyright (c) 2011 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 CMakeLists.txt
+# @author Lukasz Marek (l.marek@samsung.com)
+#
+# @version 1.0
+#
+
+PKG_CHECK_MODULES(WRT_POPUP_RUNNER_LIB_DEP
+ dpl-efl
+ REQUIRED
+)
+
+SET(WRT_POPUP_RUNNER_LIB_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/wrt/popup-runner)
+
+SET(WRT_POPUP_RUNNER_LIB_SOURCES
+ ${WRT_POPUP_COMMON_SRCS}
+ ${WRT_POPUP_RUNNER_LIB_SRC_DIR}/PopupInvoker.cpp
+)
+
+ADD_DEFINITIONS(${WRT_POPUP_RUNNER_LIB_DEP_CFLAGS})
+
+INCLUDE_DIRECTORIES(
+ ${WRT_POPUP_RUNNER_LIB_SRC_DIR}
+ ${WRT_POPUP_RUNNER_LIB_DEP_INCLUDE_DIRS}
+ ${WRT_POPUP_COMMON_DIR}
+)
+
+ADD_LIBRARY(${TARGET_POPUP_WRT_RUNNER_LIB} SHARED
+ ${WRT_POPUP_RUNNER_LIB_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_WRT_RUNNER_LIB} PROPERTIES
+ COMPILE_DEFINITIONS LOG_TAG="${LOG_TAG}")
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_WRT_RUNNER_LIB} PROPERTIES
+ COMPILE_FLAGS -fPIC
+)
+
+SET_TARGET_PROPERTIES(${TARGET_POPUP_WRT_RUNNER_LIB} PROPERTIES
+ SOVERSION ${CMAKE_PROJECT_API_VERSION}
+ VERSION ${CMAKE_PROJECT_VERSION}
+)
+
+TARGET_LINK_LIBRARIES(${TARGET_POPUP_WRT_RUNNER_LIB}
+ ${WRT_POPUP_RUNNER_LIB_DEP_LIBRARIES}
+ ${WRT_POPUP_RUNNER_LIB_DEP_LDFLAGS}
+)
+
+INSTALL(TARGETS ${TARGET_POPUP_WRT_RUNNER_LIB}
+ DESTINATION lib
+)
+
+INSTALL(FILES ${WRT_POPUP_RUNNER_LIB_SRC_DIR}/PopupInvoker.h
+ DESTINATION ${DESTINATION_HEADERS_WRT_POPUP_RUNNER}
+)
diff --git a/src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp b/src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp
new file mode 100644
index 0000000..01996ef
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+#include "PopupInvoker.h"
+#include <sstream>
+#include <limits>
+#include <unistd.h>
+#include <stdio.h>
+#include <dpl/log/wrt_log.h>
+#include <dpl/assert.h>
+#include <dpl/waitable_handle.h>
+#include <dpl/binary_queue.h>
+#include <dpl/serialization.h>
+#include <dpl/exception.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "PopupEnum.h"
+#include "PopupSerializer.h"
+
+namespace {
+const char *POPUP_EXEC = "/usr/bin/wrt-popup-wrt-runtime";
+}
+
+namespace Wrt {
+namespace Popup {
+PopupInvoker::PopupInvoker()
+{
+ char tmp[L_tmpnam + 1];
+ if (NULL == tmpnam(tmp))
+ ThrowMsg(DPL::Exception, "Failed to get pipe name");
+ m_inputName = tmp;
+
+ if (NULL == tmpnam(tmp))
+ ThrowMsg(DPL::Exception, "Failed to get pipe name");
+ m_outputName = tmp;
+
+ m_input.Create(m_inputName);
+ m_output.Create(m_outputName);
+ WrtLogD("Pipes created");
+}
+
+PopupInvoker::~PopupInvoker()
+{
+ Try
+ {
+ m_input.Destroy(m_inputName);
+ m_output.Destroy(m_outputName);
+ WrtLogD("Pipes destroyed");
+ }
+ Catch(DPL::Exception)
+ {
+ WrtLogE("Cannot destroy pipes");
+ }
+}
+
+void PopupInvoker::showInfo(const std::string& title,
+ const std::string& message,
+ const std::string& buttonLabel)
+{
+ WrtLogD("Entered");
+ Try
+ {
+ DPL::BinaryQueue data;
+ PopupSerializer::appendArg(INFO_PROMPT, data);
+ PopupSerializer::appendArg(title, data);
+ PopupSerializer::appendArg(message, data);
+ PopupSerializer::appendArg(buttonLabel, data);
+ DPL::NamedInputPipe tmp;
+ tmp.Open(m_outputName);
+ m_output.Open(m_outputName);
+ m_input.Open(m_inputName);
+ m_output.Write(data, data.Size());
+
+ executePopup();
+ DPL::BinaryQueueAutoPtr resultData =
+ m_input.Read(std::numeric_limits<std::size_t>::max());
+ const int success = PopupSerializer::getIntArg(*resultData);
+ if (!success) {
+ WrtLogW("Failed to show popup.");
+ }
+ //ignore result
+
+ tmp.Close();
+ m_input.Close();
+ m_output.Close();
+ }
+ Catch(DPL::Exception)
+ {
+ WrtLogE("error occured");
+ }
+}
+
+PopupResponse PopupInvoker::askYesNoCheckbox(const std::string& title,
+ const std::string& message,
+ const std::string& checkboxLabel)
+{
+ Try
+ {
+ DPL::BinaryQueue data;
+ PopupSerializer::appendArg(YES_NO_CHECK_PROMPT, data);
+ PopupSerializer::appendArg(title, data);
+ PopupSerializer::appendArg(message, data);
+ PopupSerializer::appendArg(checkboxLabel, data);
+ DPL::NamedInputPipe tmp;
+ tmp.Open(m_outputName);
+ m_output.Open(m_outputName);
+ m_input.Open(m_inputName);
+ m_output.Write(data, data.Size());
+
+ executePopup();
+
+ //Result from popup application is available. Read it.
+ DPL::BinaryQueueAutoPtr resultData =
+ m_input.Read(std::numeric_limits<std::size_t>::max());
+ const int success = PopupSerializer::getIntArg(*resultData);
+ if (success) {
+ const int result = PopupSerializer::getIntArg(*resultData);
+ const int rememberResult = PopupSerializer::getIntArg(*resultData);
+
+ WrtLogD("Popup result is: %d remeber: %d", result, rememberResult);
+
+ Assert(resultData->Empty());
+ tmp.Close();
+ m_input.Close();
+ m_output.Close();
+
+ if (1 == result) {
+ if (rememberResult == 1) {
+ return YES_DO_REMEMBER;
+ } else {
+ return YES_DONT_REMEMBER;
+ }
+ } else {
+ if (rememberResult == 1) {
+ return NO_DO_REMEMBER;
+ } else {
+ return NO_DONT_REMEMBER;
+ }
+ }
+ } else {
+ WrtLogW("Popup failed to execute.");
+ tmp.Close();
+ m_input.Close();
+ m_output.Close();
+ return NO_DONT_REMEMBER;
+ }
+ }
+ Catch(DPL::Exception)
+ {
+ WrtLogE("error occured");
+ }
+ return NO_DONT_REMEMBER;
+}
+
+void PopupInvoker::executePopup()
+{
+ WrtLogD("entered");
+ pid_t pid = fork();
+ if (pid == -1) {
+ //error occured
+ WrtLogE("Failed to create popup process.");
+ Assert(false);
+ }
+ if (pid == 0) {
+ //child process
+ int ret = execl(POPUP_EXEC,
+ POPUP_EXEC,
+ m_outputName.c_str(),
+ m_inputName.c_str(),
+ NULL);
+ if (ret == -1) {
+ //execl returns -1 on error
+ WrtLogE("Failed to set popup binary");
+ //write something to pipe to unblock caller process
+ DPL::NamedOutputPipe errOut;
+ errOut.Open(m_inputName);
+ DPL::BinaryQueue data;
+ PopupSerializer::appendArg(false, data);
+ errOut.Write(data, data.Size());
+ errOut.Close();
+
+ Assert(false);
+ }
+ }
+
+ DPL::WaitableHandle handle = m_input.WaitableReadHandle();
+ DPL::WaitForSingleHandle(handle);
+}
+} // Popup
+} // Wrt
diff --git a/src/wrt-popup/wrt/popup-runner/PopupInvoker.h b/src/wrt-popup/wrt/popup-runner/PopupInvoker.h
new file mode 100644
index 0000000..d7662a1
--- /dev/null
+++ b/src/wrt-popup/wrt/popup-runner/PopupInvoker.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2011 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.
+ */
+
+#ifndef WRT_POPUP_INVOKER_H
+#define WRT_POPUP_INVOKER_H
+
+#include <string>
+
+#include <dpl/named_input_pipe.h>
+#include <dpl/named_output_pipe.h>
+
+/*
+ *
+ * Example usage:
+ *
+ * bool result = PopupInvoker().askYesNoCheckbox("title", "message", "lable for checkbox");
+ *
+ */
+
+namespace Wrt {
+namespace Popup {
+enum PopupResponse {
+ NO_DO_REMEMBER,
+ NO_DONT_REMEMBER,
+ YES_DONT_REMEMBER,
+ YES_DO_REMEMBER
+};
+
+class PopupInvoker
+{
+ public:
+ class Exception
+ {
+ public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, PopupInvokerException)
+ };
+
+ PopupInvoker();
+ ~PopupInvoker();
+
+ void showInfo(const std::string &title,
+ const std::string &message,
+ const std::string &buttonLabel = std::string("OK"));
+ PopupResponse askYesNoCheckbox(const std::string& title,
+ const std::string& message,
+ const std::string& checkboxLabel);
+
+ private:
+
+ void executePopup();
+
+ DPL::NamedInputPipe m_input;
+ DPL::NamedOutputPipe m_output;
+ std::string m_inputName;
+ std::string m_outputName;
+};
+} // Popup
+} // Wrt
+
+#endif