Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_wearable / wrt-popup / wrt / popup-bin / wrt-popup.h
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 #ifndef WRT_POPUP_H
18 #define WRT_POPUP_H
19
20 #include <memory>
21 #include <dpl/application.h>
22 #include <dpl/generic_event.h>
23 #include <dpl/event/controller.h>
24 #include <dpl/type_list.h>
25 #include <dpl/named_input_pipe.h>
26 #include <dpl/named_output_pipe.h>
27 #include <dpl/waitable_handle_watch_support.h>
28 #include <dpl/binary_queue.h>
29 #include "popup_controller.h"
30
31 namespace Wrt {
32 namespace Popup {
33 DECLARE_GENERIC_EVENT_0(QuitEvent)
34 class WrtPopup;
35
36 class IPopup : public Renderer::PopupControllerUser
37 {
38   public:
39     virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent) = 0;
40     virtual ~IPopup() {}
41 };
42
43 typedef std::unique_ptr<IPopup> IPopupPtr;
44
45 class WrtPopup :
46     public DPL::WaitableHandleWatchSupport::WaitableHandleListener,
47     public DPL::Application,
48     private DPL::Event::Controller<DPL::TypeListDecl<QuitEvent>::Type>
49 {
50   public:
51     WrtPopup(int argc, char **argv);
52     virtual ~WrtPopup();
53
54     void response(DPL::BinaryQueue result);
55
56   protected:
57     //DPL::Application functions
58     virtual void OnStop();
59     virtual void OnCreate();
60     virtual void OnResume();
61     virtual void OnPause();
62     virtual void OnReset(bundle *b);
63     virtual void OnTerminate();
64     virtual void OnEventReceived(const QuitEvent &event);
65     virtual void OnWaitableHandleEvent(DPL::WaitableHandle waitableHandle,
66                                        DPL::WaitMode::Type mode);
67
68   private:
69
70     void showAcePrompt(DPL::BinaryQueueAutoPtr data);
71     void communicationBoxResponse(int buttonAnswer,
72                                   bool checkState,
73                                   void* userdata);
74     bool m_pipesOpened;
75     IPopupPtr m_popup;
76
77     bool openPipes();
78     void closePipes();
79     void readInputData();
80
81     DPL::NamedInputPipe m_input;
82     DPL::NamedOutputPipe m_output;
83 };
84 }
85 }
86
87 #endif // WRT_POPUP_H