upload tizen1.0 source
[framework/web/wrt-security.git] / popup_process / 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 <dpl/popup/popup_controller.h>
30
31 namespace PopupProcess {
32
33 DECLARE_GENERIC_EVENT_0(QuitEvent)
34 class WrtPopup;
35
36 class IPopup : public DPL::Popup::PopupControllerUser
37 {
38 public:
39     virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent) = 0;
40 };
41
42 typedef std::unique_ptr<IPopup> IPopupPtr;
43
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 private:
68
69     void showAcePrompt(DPL::BinaryQueueAutoPtr data);
70     void communicationBoxResponse(int buttonAnswer,
71                                   bool checkState,
72                                   void* userdata);
73     bool m_pipesOpened;
74     IPopupPtr m_popup;
75
76     bool openPipes();
77     void closePipes();
78     void readInputData();
79
80     DPL::NamedInputPipe m_input;
81     DPL::NamedOutputPipe m_output;
82 };
83
84 } // PopupProcess
85
86 #endif // WRT_POPUP_H