2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file YesNoPopup.cpp
18 * @author Andrzej Surdej (a.surdej@samsung.com)
20 * @brief Popup that contains 'Yes' and 'No' buttons. Inplementation
23 #include "YesNoPopup.h"
26 #include <dpl/popup/popup_manager.h>
27 #include "PopupSerializer.h"
30 const char YES_LABEL[] = "Yes";
31 const char NO_LABEL[] = "No";
32 const int POPUP_YES_VALUE = 1;
33 const int POPUP_NO_VALUE = 2;
39 using namespace DPL::Popup;
41 void YesNoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
44 std::string title = PopupSerializer::getStringArg(*data);
45 std::string message = PopupSerializer::getStringArg(*data);
46 Assert(data->Empty());
47 LogDebug("title: " << title << " message: " << message);
51 CtrlPopupPtr popup = PopupControllerSingleton::Instance().CreatePopup();
53 popup->SetTitle(title);
54 popup->Append(new PopupObject::Label(message));
56 popup->Append(new PopupObject::Button(YES_LABEL, POPUP_YES_VALUE));
57 popup->Append(new PopupObject::Button(NO_LABEL, POPUP_NO_VALUE));
59 ListenForAnswer(popup);
61 ShowPopupEventShort event(popup,
64 &YesNoPopup::responseCallback));
66 CONTROLLER_POST_EVENT(PopupController,
73 void YesNoPopup::responseCallback(const DPL::Popup::AnswerCallbackData &answer)
75 bool result = (POPUP_YES_VALUE == answer.buttonAnswer);
76 DPL::BinaryQueue retValue;
77 PopupSerializer::appendArg(result, retValue);
78 m_parent->response(retValue);