Information popup
authorLukasz Marek <l.marek@samsung.com>
Tue, 11 Dec 2012 15:11:15 +0000 (16:11 +0100)
committerGerrit Code Review <gerrit2@kim11>
Wed, 12 Dec 2012 13:54:54 +0000 (22:54 +0900)
[Issue#] N/A
[Bug] N/A
[Cause] Implementation of information popup - popup with message and OK button.
[Solution] N/A
[Verification] Build repository.

Change-Id: I7bf809eb9af0ea0af2782306ab603fe61facb1f8

src/Commons/CMakeLists.txt
src/wrt-popup/wrt/PopupEnum.h
src/wrt-popup/wrt/popup-bin/CMakeLists.txt
src/wrt-popup/wrt/popup-bin/InfoPopup.cpp [new file with mode: 0644]
src/wrt-popup/wrt/popup-bin/InfoPopup.h [new file with mode: 0644]
src/wrt-popup/wrt/popup-bin/YesNoPopup.h
src/wrt-popup/wrt/popup-bin/wrt-popup.cpp
src/wrt-popup/wrt/popup-bin/wrt-popup.h
src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp
src/wrt-popup/wrt/popup-runner/PopupInvoker.h

index ff66c21..4d6e3b1 100644 (file)
@@ -29,8 +29,6 @@ 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)
index fed25b0..01af28e 100644 (file)
@@ -19,7 +19,7 @@
 
 namespace Wrt {
 enum PopupType {
-    ACE_PROMPT = 1,
+    INFO_PROMPT = 1,
     YES_NO_PROMPT
 };
 }
index 6058d13..5a191dd 100644 (file)
@@ -30,6 +30,7 @@ SET(WRT_POPUP_SRCS
     ${WRT_POPUP_COMMON_SRCS}
     wrt-popup.cpp
     YesNoPopup.cpp
+    InfoPopup.cpp
 )
 
 ADD_EXECUTABLE(${TARGET_POPUP_WRT}
diff --git a/src/wrt-popup/wrt/popup-bin/InfoPopup.cpp b/src/wrt-popup/wrt/popup-bin/InfoPopup.cpp
new file mode 100644 (file)
index 0000000..1a7d8d3
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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 <dpl/popup/popup_manager.h>
+#include <dpl/popup/popup.h>
+#include "PopupSerializer.h"
+
+namespace Wrt {
+namespace Popup {
+
+using namespace DPL::Popup;
+
+void InfoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
+{
+    LogDebug("Entered");
+    std::string title = PopupSerializer::getStringArg(*data);
+    std::string message = PopupSerializer::getStringArg(*data);
+    std::string button = 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(button, 0));
+
+    ListenForAnswer(popup);
+
+    ShowPopupEventShort event(popup,
+                              MakeAnswerCallback(
+                                     this,
+                                     &InfoPopup::responseCallback));
+
+    CONTROLLER_POST_EVENT(PopupController,
+                          event);
+
+    LogDebug("Exited");
+    return;
+}
+
+void InfoPopup::responseCallback(const DPL::Popup::AnswerCallbackData &answer)
+{
+    DPL::BinaryQueue 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 (file)
index 0000000..42e1df2
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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:
+    virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent);
+
+private:
+
+    void responseCallback(const DPL::Popup::AnswerCallbackData &answer);
+    WrtPopup* m_parent;
+};
+
+} // Popup
+} // Wrt
+
+#endif /* WRT_INFO_POPUP_H */
+
index 9dea6c1..54e89ba 100644 (file)
@@ -24,7 +24,6 @@
 #define WRT_YES_NO_POPUP_H
 
 #include "wrt-popup.h"
-#include <dpl/popup/popup.h>
 
 namespace Wrt {
 namespace Popup {
index 1d5ad6d..10a42d0 100644 (file)
@@ -25,6 +25,7 @@
 #include "PopupEnum.h"
 #include "PopupSerializer.h"
 #include "YesNoPopup.h"
+#include "InfoPopup.h"
 
 namespace Wrt {
 namespace Popup {
@@ -103,6 +104,10 @@ void WrtPopup::readInputData()
         m_popup.reset(new YesNoPopup());
         m_popup->show(data, this);
         break;
+    case INFO_PROMPT:
+        m_popup.reset(new InfoPopup());
+        m_popup->show(data, this);
+        break;
     default:
         Assert(false);
     }
index 7489d05..200ca9a 100644 (file)
@@ -38,6 +38,7 @@ class IPopup : public DPL::Popup::PopupControllerUser
 {
 public:
     virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent) = 0;
+    virtual ~IPopup() {}
 };
 
 typedef std::unique_ptr<IPopup> IPopupPtr;
index b359fce..6ed9dc9 100644 (file)
@@ -103,6 +103,37 @@ bool PopupInvoker::askYesNo(const std::string& title, const std::string& message
     return false;
 }
 
+void PopupInvoker::showInfo(const std::string& title,
+                            const std::string& message,
+                            const std::string& buttonLabel)
+{
+    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();
+
+        //ignore result
+
+        tmp.Close();
+        m_input.Close();
+        m_output.Close();
+    }
+    Catch(DPL::Exception)
+    {
+        LogError("error occured");
+    }
+}
+
 void PopupInvoker::executePopup()
 {
     pid_t pid = fork();
index 95fc881..33df799 100644 (file)
@@ -47,6 +47,9 @@ public:
     ~PopupInvoker();
 
     bool askYesNo(const std::string &title, const std::string &message);
+    void showInfo(const std::string &title,
+                  const std::string &message,
+                  const std::string &buttonLabel = std::string("OK"));
 
 private: