Popup cleaning
authorLukasz Marek <l.marek@samsung.com>
Wed, 5 Dec 2012 17:14:39 +0000 (18:14 +0100)
committerGerrit Code Review <gerrit2@kim11>
Mon, 10 Dec 2012 15:44:32 +0000 (00:44 +0900)
[Issue#] N/A
[Bug] N/A
[Cause] Implementation of modal popups is divided into multiple repositiories
[Solution] This commit moves implementation into one place (apart from DPL impl).
[Verification] Rebuild wrt-plugins-common, wrt, plugins and run widget showing popups.

Change-Id: I08ee29db38d68992ede89aa5421a1e7e81cf63d7

27 files changed:
CMakeLists.txt
packaging/wrt-plugins-common.spec
pkgconfigs/wrt-popup-ace-runner.pc.in [new file with mode: 0644]
pkgconfigs/wrt-popup-runner.pc.in
pkgconfigs/wrt-popup-wrt-runner.pc.in [new file with mode: 0644]
src/CMakeLists.txt
src/Commons/CMakeLists.txt
src/wrt-popup/CMakeLists.txt
src/wrt-popup/ace/CMakeLists.txt [new file with mode: 0755]
src/wrt-popup/ace/popup-bin/CMakeLists.txt [moved from src/wrt-popup/popup-bin/CMakeLists.txt with 79% similarity]
src/wrt-popup/ace/popup-bin/Popup.cpp [moved from src/wrt-popup/popup-bin/Popup.cpp with 100% similarity]
src/wrt-popup/ace/popup-bin/Popup.h [moved from src/wrt-popup/popup-bin/Popup.h with 100% similarity]
src/wrt-popup/ace/popup-runner/CMakeLists.txt [moved from src/wrt-popup/popup-runner/CMakeLists.txt with 79% similarity]
src/wrt-popup/ace/popup-runner/popup-runner.cpp [moved from src/wrt-popup/popup-runner/popup-runner.cpp with 98% similarity]
src/wrt-popup/ace/popup-runner/popup-runner.h [moved from src/wrt-popup/popup-runner/popup-runner.h with 97% similarity]
src/wrt-popup/wrt/CMakeLists.txt [new file with mode: 0755]
src/wrt-popup/wrt/PopupEnum.h [new file with mode: 0644]
src/wrt-popup/wrt/PopupSerializer.cpp [new file with mode: 0644]
src/wrt-popup/wrt/PopupSerializer.h [new file with mode: 0644]
src/wrt-popup/wrt/popup-bin/CMakeLists.txt [new file with mode: 0644]
src/wrt-popup/wrt/popup-bin/YesNoPopup.cpp [new file with mode: 0644]
src/wrt-popup/wrt/popup-bin/YesNoPopup.h [new file with mode: 0644]
src/wrt-popup/wrt/popup-bin/wrt-popup.cpp [new file with mode: 0644]
src/wrt-popup/wrt/popup-bin/wrt-popup.h [new file with mode: 0644]
src/wrt-popup/wrt/popup-runner/CMakeLists.txt [new file with mode: 0644]
src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp [new file with mode: 0644]
src/wrt-popup/wrt/popup-runner/PopupInvoker.h [new file with mode: 0644]

index 2132922..58d8a72 100644 (file)
@@ -134,6 +134,8 @@ configure_and_install_pkg(wrt-plugins-plugin-manager.pc)
 configure_and_install_pkg(wrt-plugin-loading.pc)
 configure_and_install_pkg(wrt-plugin-js-overlay.pc)
 configure_and_install_pkg(wrt-popup-runner.pc)
+configure_and_install_pkg(wrt-popup-ace-runner.pc)
+configure_and_install_pkg(wrt-popup-wrt-runner.pc)
 configure_and_install_pkg(wrt-plugins-api-support.pc)
 
 ################################################################################
index 591f911..defca3e 100644 (file)
@@ -66,7 +66,8 @@ touch /opt/share/widget/plugin-installation-required
 %{_libdir}/wrt-plugins/w3c-widget-interface/libwrt-plugins-w3c-widget-interface.so
 %attr(644,root,root) %{_libdir}/wrt-plugins/standard-features-list
 %attr(644,root,root) /usr/share/wrt-plugins-common/widget_interface_db.sql
-%attr(755,root,root) %{_bindir}/wrt-popup-runtime
+%attr(755,root,root) %{_bindir}/wrt-popup-ace-runtime
+%attr(755,root,root) %{_bindir}/wrt-popup-wrt-runtime
 %attr(755,root,root) %{_bindir}/wrt-plugins-installer
 %{_datadir}/license/%{name}
 
diff --git a/pkgconfigs/wrt-popup-ace-runner.pc.in b/pkgconfigs/wrt-popup-ace-runner.pc.in
new file mode 100644 (file)
index 0000000..ad9605e
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+project_name=@CMAKE_PROJECT_NAME@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/${project_name}
+
+Name: wrt-popup-runner
+Description:  Library with function to run wrt runtime popup
+Version: @CMAKE_PROJECT_VERSION@
+Requires: dpl-efl dpl-dbus-efl elementary security-client
+Libs: -L${libdir} -lwrt-popup-ace-runner
+Cflags: -I${includedir}
index 7e53635..ad9605e 100644 (file)
@@ -8,5 +8,5 @@ Name: wrt-popup-runner
 Description:  Library with function to run wrt runtime popup
 Version: @CMAKE_PROJECT_VERSION@
 Requires: dpl-efl dpl-dbus-efl elementary security-client
-Libs: -L${libdir} -lwrt-popup-runner
+Libs: -L${libdir} -lwrt-popup-ace-runner
 Cflags: -I${includedir}
diff --git a/pkgconfigs/wrt-popup-wrt-runner.pc.in b/pkgconfigs/wrt-popup-wrt-runner.pc.in
new file mode 100644 (file)
index 0000000..a7b830f
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+project_name=@CMAKE_PROJECT_NAME@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/${project_name}
+
+Name: wrt-popup-runner
+Description:  Library with function to run wrt runtime popup
+Version: @CMAKE_PROJECT_VERSION@
+Requires: dpl-efl
+Libs: -L${libdir} -lwrt-popup-wrt-runner
+Cflags: -I${includedir}
index 76e712d..eea2566 100644 (file)
@@ -42,7 +42,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                     ${CMAKE_CURRENT_SOURCE_DIR}/CommonsJavaScript
                     ${CMAKE_CURRENT_SOURCE_DIR}/plugin-loading
                     ${CMAKE_CURRENT_SOURCE_DIR}/js-overlay
-                    ${CMAKE_CURRENT_SOURCE_DIR}/wrt-popup/popup-runner
+                    ${CMAKE_CURRENT_SOURCE_DIR}/wrt-popup/ace/popup-runner
                     )
 
 #target names
@@ -50,8 +50,10 @@ set(TARGET_PLUGIN_LOADING_LIB "wrt-plugin-loading")
 set(TARGET_COMMONS "wrt-plugins-commons")
 set(TARGET_COMMONS_JAVASCRIPT "wrt-plugins-commons-javascript")
 set(TARGET_JS_OVERLAY "wrt-plugins-js-overlay")
-SET(TARGET_WRT_POPUP "wrt-popup-runtime")
-SET(TARGET_WRT_POPUP_RUNNER_LIB "wrt-popup-runner")
+SET(TARGET_POPUP_ACE "wrt-popup-ace-runtime")
+SET(TARGET_POPUP_ACE_RUNNER_LIB "wrt-popup-ace-runner")
+SET(TARGET_POPUP_WRT "wrt-popup-wrt-runtime")
+SET(TARGET_POPUP_WRT_RUNNER_LIB "wrt-popup-wrt-runner")
 set(TARGET_PLUGINS_API_SUPPORT "wrt-plugins-api-support")
 
 set(PLUGIN_LOADING_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/plugin-loading)
index 64126f3..ff66c21 100644 (file)
@@ -29,6 +29,8 @@ endmacro()
 
 include_config_file(WrtAccess)
 
+message(__________________________________${TARGET_POPUP_ACE_RUNNER_LIB})
+
 pkg_search_module(plugin-types REQUIRED wrt-plugins-types)
 pkg_search_module(ace-client REQUIRED security-client)
 pkg_search_module(dpl-event REQUIRED dpl-event-efl)
@@ -66,7 +68,7 @@ target_link_libraries(${TARGET_NAME}
   ${ace-client_LIBRARIES}
   ${dpl-event_LIBRARIES}
   ${icu_LIBRARIES}
-  ${TARGET_WRT_POPUP_RUNNER_LIB}
+  ${TARGET_POPUP_ACE_RUNNER_LIB}
 )
 
 set_target_properties(${TARGET_NAME} PROPERTIES
index 2ecd23d..13a79cc 100755 (executable)
@@ -1,2 +1,2 @@
-ADD_SUBDIRECTORY(popup-bin)
-ADD_SUBDIRECTORY(popup-runner)
+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 (executable)
index 0000000..2ecd23d
--- /dev/null
@@ -0,0 +1,2 @@
+ADD_SUBDIRECTORY(popup-bin)
+ADD_SUBDIRECTORY(popup-runner)
similarity index 79%
rename from src/wrt-popup/popup-bin/CMakeLists.txt
rename to src/wrt-popup/ace/popup-bin/CMakeLists.txt
index 4c2b381..f87483d 100644 (file)
@@ -26,7 +26,7 @@ PKG_CHECK_MODULES(WRT_POPUP_DEP
     security-popup-validation
    REQUIRED)
 
-set(WRT_POPUP_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/popup-bin)
+set(WRT_POPUP_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/ace/popup-bin)
 
 set(WRT_POPUP_SOURCES
     ${WRT_POPUP_SRC_DIR}/Popup.cpp
@@ -39,26 +39,26 @@ INCLUDE_DIRECTORIES(
     ${WRT_POPUP_DEP_INCLUDE_DIRS}
 )
 
-ADD_EXECUTABLE(${TARGET_WRT_POPUP}
+ADD_EXECUTABLE(${TARGET_POPUP_ACE}
     ${WRT_POPUP_SOURCES}
 )
 
-SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP} PROPERTIES
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE} PROPERTIES
     COMPILE_FLAGS -fPIC
 )
 
-SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP} PROPERTIES
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE} PROPERTIES
     #LINK_FLAGS "-Wl,--as-needed -Wl"
     SOVERSION ${PROJECT_API_VERSION}
     VERSION ${PROJECT_VERSION}
 )
 
-target_link_libraries(${TARGET_WRT_POPUP}
+target_link_libraries(${TARGET_POPUP_ACE}
     ${WRT_POPUP_DEP_LIBRARIES}
-    ${TARGET_WRT_POPUP_RUNNER_LIB}
+    ${TARGET_POPUP_ACE_RUNNER_LIB}
     ${WRT_POPUP_DEP_LDFLAGS}
 )
 
-INSTALL(TARGETS ${TARGET_WRT_POPUP}
+INSTALL(TARGETS ${TARGET_POPUP_ACE}
     DESTINATION bin
 )
similarity index 79%
rename from src/wrt-popup/popup-runner/CMakeLists.txt
rename to src/wrt-popup/ace/popup-runner/CMakeLists.txt
index 5a45dfe..4e5053c 100644 (file)
@@ -25,7 +25,7 @@ PKG_CHECK_MODULES(WRT_POPUP_RUNNER_LIB_DEP
     security-client
    REQUIRED)
 
-set(WRT_POPUP_RUNNER_LIB_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/popup-runner)
+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
@@ -38,28 +38,28 @@ INCLUDE_DIRECTORIES(
     ${WRT_POPUP_RUNNER_LIB_DEP_INCLUDE_DIRS}
 )
 
-ADD_LIBRARY(${TARGET_WRT_POPUP_RUNNER_LIB} SHARED
+ADD_LIBRARY(${TARGET_POPUP_ACE_RUNNER_LIB} SHARED
     ${WRT_POPUP_RUNNER_LIB_SOURCES}
 )
 
-SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP_RUNNER_LIB} PROPERTIES
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE_RUNNER_LIB} PROPERTIES
     COMPILE_FLAGS -fPIC
 )
 
-SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP_RUNNER_LIB} PROPERTIES
+SET_TARGET_PROPERTIES(${TARGET_POPUP_ACE_RUNNER_LIB} PROPERTIES
     SOVERSION ${CMAKE_PROJECT_API_VERSION}
     VERSION ${CMAKE_PROJECT_VERSION}
 )
 
-target_link_libraries(${TARGET_WRT_POPUP_RUNNER_LIB}
+target_link_libraries(${TARGET_POPUP_ACE_RUNNER_LIB}
     ${WRT_POPUP_RUNNER_LIB_DEP_LIBRARIES}
     ${WRT_POPUP_RUNNER_LIB_DEP_LDFLAGS}
 )
 
-INSTALL(TARGETS ${TARGET_WRT_POPUP_RUNNER_LIB}
+INSTALL(TARGETS ${TARGET_POPUP_ACE_RUNNER_LIB}
     DESTINATION lib
 )
 
-INSTALL(FILES ${PROJECT_SOURCE_DIR}/src/wrt-popup/popup-runner/popup-runner.h
+INSTALL(FILES ${WRT_POPUP_RUNNER_LIB_SRC_DIR}/popup-runner.h
     DESTINATION ${DESTINATION_HEADERS_WRT_POPUP_RUNNER}
 )
@@ -38,7 +38,7 @@
 
 namespace { // anonymous
 
-const char *POPUP_EXEC = "/usr/bin/wrt-popup-runtime"; // wrt-popup-runtime
+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){
 
@@ -65,8 +65,8 @@ void _ace_params_serializer (const ace_param_list_t* ace_param_list, Wrt::Popup:
 
 } // anonymous namespace
 
-namespace Wrt{
-namespace Popup{
+namespace Wrt {
+namespace Popup {
 
 // BinaryStream class implementation
 void BinaryStream::Read(size_t num, void * bytes) {
similarity index 97%
rename from src/wrt-popup/popup-runner/popup-runner.h
rename to src/wrt-popup/ace/popup-runner/popup-runner.h
index 9da8c38..e3cf0ad 100644 (file)
@@ -24,8 +24,8 @@
 
 #include <dpl/serialization.h>
 
-namespace Wrt{
-namespace Popup{
+namespace Wrt {
+namespace Popup {
 
 class BinaryStream : public DPL::IStream {
   public:
diff --git a/src/wrt-popup/wrt/CMakeLists.txt b/src/wrt-popup/wrt/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..ed0e24b
--- /dev/null
@@ -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 (file)
index 0000000..fed25b0
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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 {
+    ACE_PROMPT = 1,
+    YES_NO_PROMPT
+};
+}
+
+#endif
+
diff --git a/src/wrt-popup/wrt/PopupSerializer.cpp b/src/wrt-popup/wrt/PopupSerializer.cpp
new file mode 100644 (file)
index 0000000..481519a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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 (file)
index 0000000..27094fd
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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 (file)
index 0000000..6058d13
--- /dev/null
@@ -0,0 +1,49 @@
+# 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
+    dpl-efl
+    dpl-event-efl
+    dpl-popup-efl
+    REQUIRED
+)
+
+INCLUDE_DIRECTORIES(
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${WRT_POPUP_DEPS_INCLUDE_DIRS}
+    ${WRT_POPUP_COMMON_DIR}
+)
+
+SET(WRT_POPUP_SRCS
+    ${WRT_POPUP_COMMON_SRCS}
+    wrt-popup.cpp
+    YesNoPopup.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
+    LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
+    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/YesNoPopup.cpp b/src/wrt-popup/wrt/popup-bin/YesNoPopup.cpp
new file mode 100644 (file)
index 0000000..10235fe
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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        YesNoPopup.cpp
+ * @author      Andrzej Surdej (a.surdej@samsung.com)
+ * @version     1.0
+ * @brief       Popup that contains 'Yes' and 'No' buttons. Inplementation
+ */
+
+#include "YesNoPopup.h"
+#include <memory>
+#include <string.h>
+#include <dpl/popup/popup_manager.h>
+#include "PopupSerializer.h"
+
+namespace {
+const char YES_LABEL[] = "Yes";
+const char NO_LABEL[] = "No";
+const int POPUP_YES_VALUE = 1;
+const int POPUP_NO_VALUE = 2;
+} //anonymous
+
+namespace Wrt {
+namespace Popup {
+
+using namespace DPL::Popup;
+
+void YesNoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
+{
+    LogDebug("Entered");
+    std::string title = PopupSerializer::getStringArg(*data);
+    std::string message = PopupSerializer::getStringArg(*data);
+    Assert(data->Empty());
+    LogDebug("title: " << title << " message: " << message);
+
+    m_parent = parent;
+
+    CtrlPopupPtr popup = PopupControllerSingleton::Instance().CreatePopup();
+
+    popup->SetTitle(title);
+    popup->Append(new PopupObject::Label(message));
+
+    popup->Append(new PopupObject::Button(YES_LABEL, POPUP_YES_VALUE));
+    popup->Append(new PopupObject::Button(NO_LABEL, POPUP_NO_VALUE));
+
+    ListenForAnswer(popup);
+
+    ShowPopupEventShort event(popup,
+                              MakeAnswerCallback(
+                                     this,
+                                     &YesNoPopup::responseCallback));
+
+    CONTROLLER_POST_EVENT(PopupController,
+                          event);
+
+    LogDebug("Exited");
+    return;
+}
+
+void YesNoPopup::responseCallback(const DPL::Popup::AnswerCallbackData &answer)
+{
+    bool result = (POPUP_YES_VALUE == answer.buttonAnswer);
+    DPL::BinaryQueue retValue;
+    PopupSerializer::appendArg(result, retValue);
+    m_parent->response(retValue);
+}
+
+} // Popup
+} // Wrt
diff --git a/src/wrt-popup/wrt/popup-bin/YesNoPopup.h b/src/wrt-popup/wrt/popup-bin/YesNoPopup.h
new file mode 100644 (file)
index 0000000..9dea6c1
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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        YesNoPopup.h
+ * @author      Andrzej Surdej (a.surdej@samsung.com)
+ * @version     1.0
+ * @brief       Popup that contains 'Yes' and 'No' buttons
+ */
+
+#ifndef WRT_YES_NO_POPUP_H
+#define WRT_YES_NO_POPUP_H
+
+#include "wrt-popup.h"
+#include <dpl/popup/popup.h>
+
+namespace Wrt {
+namespace Popup {
+
+class YesNoPopup : public IPopup
+{
+public:
+    virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent);
+
+private:
+
+    void responseCallback(const DPL::Popup::AnswerCallbackData &answer);
+    WrtPopup* m_parent;
+};
+
+} // Popup
+} // Wrt
+
+#endif /* WRT_YES_NO_POPUP_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 (file)
index 0000000..1d5ad6d
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * 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/log.h>
+#include <dpl/exception.h>
+#include <dpl/assert.h>
+
+#include "PopupEnum.h"
+#include "PopupSerializer.h"
+#include "YesNoPopup.h"
+
+namespace Wrt {
+namespace Popup {
+
+bool WrtPopup::openPipes()
+{
+    Try
+    {
+        if (m_argc != 3) {
+            LogError("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)
+    {
+        LogError("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)
+    {
+        LogError("cannot close pipes");
+    }
+}
+
+void WrtPopup::OnEventReceived(const QuitEvent &/* event */)
+{
+    LogDebug("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);
+    LogDebug("popup type " << popupType);
+    switch(popupType) {
+    case YES_NO_PROMPT:
+        m_popup.reset(new YesNoPopup());
+        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()
+{
+    LogInfo("On Stop");
+}
+
+void WrtPopup::OnCreate()
+{
+    if (!openPipes())
+    {
+        PostEvent(QuitEvent());
+    }
+    LogInfo("On Create");
+}
+
+void WrtPopup::OnResume()
+{
+    LogDebug("OnResume");
+}
+
+void WrtPopup::OnPause()
+{
+    LogDebug("OnPause");
+}
+
+void WrtPopup::OnReset(bundle */*b*/)
+{
+    LogDebug("OnReset");
+}
+
+void WrtPopup::OnTerminate()
+{
+    LogDebug("Wrt Shutdown now");
+}
+
+WrtPopup::WrtPopup(int argc, char **argv) :
+    Application(argc, argv, "wrt-popup", false),
+    m_pipesOpened(false)
+{
+    Touch();
+    DPL::Popup::PopupControllerSingleton::Instance().Touch();
+    DPL::Popup::PopupManagerSingleton::Instance().Initialize(
+        DPL::Popup::PopupRendererPtr(new DPL::Popup::PopupRenderer));
+    LogDebug("App Created");
+}
+
+WrtPopup::~WrtPopup()
+{
+    DPL::Popup::PopupManagerSingleton::Instance().Deinitialize();
+    LogDebug("App Finished");
+}
+
+}
+}
+
+int main(int argc, char *argv[])
+{
+    // 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);
+
+    DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-POPUP");
+    Wrt::Popup::WrtPopup app(argc, argv);
+    int ret = app.Exec();
+    LogDebug("App returned: " << ret);
+    return ret;
+}
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 (file)
index 0000000..7489d05
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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 <dpl/popup/popup_controller.h>
+
+namespace Wrt {
+namespace Popup {
+
+DECLARE_GENERIC_EVENT_0(QuitEvent)
+class WrtPopup;
+
+class IPopup : public DPL::Popup::PopupControllerUser
+{
+public:
+    virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent) = 0;
+};
+
+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 (file)
index 0000000..0a8f45e
--- /dev/null
@@ -0,0 +1,66 @@
+# 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_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 (file)
index 0000000..b359fce
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * 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 <unistd.h>
+#include <stdio.h>
+#include <dpl/log/log.h>
+#include <dpl/waitable_handle.h>
+#include <dpl/binary_queue.h>
+#include <dpl/serialization.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() :
+    m_inputName(tmpnam(NULL)),
+    m_outputName(tmpnam(NULL))
+{
+    Try
+    {
+        m_input.Create(m_inputName);
+        m_output.Create(m_outputName);
+        LogDebug("Pipes created");
+    }
+    Catch (DPL::Exception)
+    {
+        LogError("Cannot create pipes");
+    }
+}
+
+PopupInvoker::~PopupInvoker()
+{
+    Try
+    {
+        m_input.Destroy(m_inputName);
+        m_output.Destroy(m_outputName);
+        LogDebug("Pipes destroyed");
+    }
+    Catch (DPL::Exception)
+    {
+        LogError("Cannot destroy pipes");
+    }
+}
+
+bool PopupInvoker::askYesNo(const std::string& title, const std::string& message)
+{
+    Try
+    {
+        DPL::BinaryQueue data;
+        PopupSerializer::appendArg(YES_NO_PROMPT, data);
+        PopupSerializer::appendArg(title, data);
+        PopupSerializer::appendArg(message, 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 result = PopupSerializer::getIntArg(*resultData);
+
+        LogDebug("Popup result is: " << result);
+
+        Assert(resultData->Empty());
+
+        tmp.Close();
+        m_input.Close();
+        m_output.Close();
+
+        return (!!result);
+    }
+    Catch(DPL::Exception)
+    {
+        LogError("error occured");
+    }
+
+    return false;
+}
+
+void PopupInvoker::executePopup()
+{
+    pid_t pid = fork();
+    if (pid == -1)
+    {
+        //error occured
+        LogError("Cannot display popup!");
+        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
+            LogError("Cannot display popup!");
+            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 (file)
index 0000000..95fc881
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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().askYesNo("title", "message");
+
+ */
+
+namespace Wrt {
+namespace Popup {
+
+class PopupInvoker
+{
+public:
+    class Exception
+    {
+      public:
+        DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+        DECLARE_EXCEPTION_TYPE(Base, PopupInvokerException)
+    };
+
+    PopupInvoker();
+    ~PopupInvoker();
+
+    bool askYesNo(const std::string &title, const std::string &message);
+
+private:
+
+    void executePopup();
+
+    DPL::NamedInputPipe m_input;
+    DPL::NamedOutputPipe m_output;
+    const std::string m_inputName;
+    const std::string m_outputName;
+};
+
+} // Popup
+} // Wrt
+
+#endif