Fix issues shown by cppcheck for wrt-plugins-common
[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 InfoPopup::InfoPopup() :
33         m_parent(NULL)
34 {}
35
36 void InfoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
37 {
38     LogDebug("Entered");
39     std::string title = PopupSerializer::getStringArg(*data);
40     std::string message = PopupSerializer::getStringArg(*data);
41     std::string button = PopupSerializer::getStringArg(*data);
42     Assert(data->Empty());
43     LogDebug("title: " << title << " message: " << message);
44
45     m_parent = parent;
46
47     Renderer::CtrlPopupPtr popup =
48         Renderer::PopupControllerSingleton::Instance().CreatePopup();
49
50     popup->SetTitle(title);
51     popup->Append(new Renderer::PopupObject::Label(message));
52
53     popup->Append(new Renderer::PopupObject::Button(button, 0));
54
55     ListenForAnswer(popup);
56
57     Renderer::ShowPopupEventShort event(popup,
58                                         MakeAnswerCallback(
59                                             this,
60                                             &InfoPopup::responseCallback));
61
62     CONTROLLER_POST_EVENT(Renderer::PopupController,
63                           event);
64
65     LogDebug("Exited");
66     return;
67 }
68
69 void InfoPopup::responseCallback(const Renderer::AnswerCallbackData &answer)
70 {
71     DPL::BinaryQueue retValue;
72     PopupSerializer::appendArg(answer.buttonAnswer, retValue);
73     m_parent->response(retValue);
74 }
75 } // Popup
76 } // Wrt