Remove popup dependency from wrt-commons
[platform/framework/web/wrt-plugins-common.git] / src / wrt-popup / wrt / popup-bin / InfoPopup.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file        InfoPopup.cpp
18  * @author      Lukasz Marek(l.marek@samsung.com)
19  * @version     1.0
20  * @brief       Popup that displays information. Inplementation
21  */
22
23 #include "InfoPopup.h"
24 #include <memory>
25 #include <string.h>
26 #include "popup_manager.h"
27 #include "popup.h"
28 #include "PopupSerializer.h"
29
30 namespace Wrt {
31 namespace Popup {
32
33 void InfoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
34 {
35     LogDebug("Entered");
36     std::string title = PopupSerializer::getStringArg(*data);
37     std::string message = PopupSerializer::getStringArg(*data);
38     std::string button = PopupSerializer::getStringArg(*data);
39     Assert(data->Empty());
40     LogDebug("title: " << title << " message: " << message);
41
42     m_parent = parent;
43
44     Renderer::CtrlPopupPtr popup =
45         Renderer::PopupControllerSingleton::Instance().CreatePopup();
46
47     popup->SetTitle(title);
48     popup->Append(new Renderer::PopupObject::Label(message));
49
50     popup->Append(new Renderer::PopupObject::Button(button, 0));
51
52     ListenForAnswer(popup);
53
54     Renderer::ShowPopupEventShort event(popup,
55                                         MakeAnswerCallback(
56                                             this,
57                                             &InfoPopup::responseCallback));
58
59     CONTROLLER_POST_EVENT(Renderer::PopupController,
60                           event);
61
62     LogDebug("Exited");
63     return;
64 }
65
66 void InfoPopup::responseCallback(const Renderer::AnswerCallbackData &answer)
67 {
68     DPL::BinaryQueue retValue;
69     PopupSerializer::appendArg(answer.buttonAnswer, retValue);
70     m_parent->response(retValue);
71 }
72
73 } // Popup
74 } // Wrt