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)
################################################################################
%{_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}
--- /dev/null
+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}
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}
--- /dev/null
+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}
${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
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)
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)
${ace-client_LIBRARIES}
${dpl-event_LIBRARIES}
${icu_LIBRARIES}
- ${TARGET_WRT_POPUP_RUNNER_LIB}
+ ${TARGET_POPUP_ACE_RUNNER_LIB}
)
set_target_properties(${TARGET_NAME} PROPERTIES
-ADD_SUBDIRECTORY(popup-bin)
-ADD_SUBDIRECTORY(popup-runner)
+ADD_SUBDIRECTORY(ace)
+ADD_SUBDIRECTORY(wrt)
--- /dev/null
+ADD_SUBDIRECTORY(popup-bin)
+ADD_SUBDIRECTORY(popup-runner)
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
${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
)
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
${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}
)
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){
} // anonymous namespace
-namespace Wrt{
-namespace Popup{
+namespace Wrt {
+namespace Popup {
// BinaryStream class implementation
void BinaryStream::Read(size_t num, void * bytes) {
#include <dpl/serialization.h>
-namespace Wrt{
-namespace Popup{
+namespace Wrt {
+namespace Popup {
class BinaryStream : public DPL::IStream {
public:
--- /dev/null
+
+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)
--- /dev/null
+/*
+ * 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
+
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+# 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)
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 */
+
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+# 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}
+)
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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