41cb8ba9b40f863b218d4853dbdbb4048a9c34a8
[platform/framework/web/web-provider.git] / src / Core / Box.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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    Box.h
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #ifndef BOX_H
21 #define BOX_H
22
23 #include <string>
24 #include <memory>
25 #include <ctime>
26 #include <Ecore.h>
27 #include <Plugin/IBoxPluginFactory.h>
28 #include "Buffer/IRenderBuffer.h"
29 #include "View/IRenderView.h"
30 #include "Util/ITimer.h"
31 #include "BoxData.h"
32 #include "IBoxState.h"
33 #include "IBoxContext.h"
34 #include "IBox.h"
35 #include "Box.h"
36
37 class Box: public IBox, public IBoxContext {
38     public:
39         static IBoxPtr create(
40                 BoxInfoPtr boxInfo, 
41                 IBoxPluginFactoryPtr factory,  
42                 EwkContextPtr ewkContext)
43         { 
44             return IBoxPtr(new Box(boxInfo, factory, ewkContext)); 
45         };
46         // IBox
47         bool show();
48         bool hide();
49         bool resize(int width, int height);
50         bool resume();
51         bool pause(bool background);
52         bool openPd(int width, int height, double x, double y);
53         bool closePd();
54         bool update(time_t requestTime, std::string& contentInfo);
55         bool changePeriod(float period);
56         bool isCurrentTab();
57         time_t getLastUpdateRequestTime();
58         ~Box();
59
60     private:
61         RenderInfoPtr makeRenderInfo(const std::string& renderType) const;
62         void updateInternal();
63
64         // IBoxContext
65         void setState(IBoxStatePtr state);
66
67         // static callbacks
68         static Eina_Bool updateCallback(void* data);
69         static Eina_Bool startUpdateRenderBufferIdlerCallback(void* data);
70
71         // constructor
72         explicit Box(
73                 BoxInfoPtr boxInfo, 
74                 IBoxPluginFactoryPtr factory, 
75                 EwkContextPtr ewkContext);
76
77         BoxInfoPtr m_boxInfo;
78         IBoxPluginFactoryPtr m_factory;
79         IRenderBufferPtr m_boxBuffer;
80         IRenderBufferPtr m_pdBuffer;
81         IRenderViewPtr m_view;
82         ITimerPtr m_updateTimer;
83         //IBoxStatePtr m_state;
84         // flag for knowing this box is on current tab
85         bool m_currentTab;
86         // flag for knowing this box has been already paused
87         bool m_paused;
88         // flag for knowing this box should be updated when the box is resumed
89         bool m_updateNeeded;
90         // timestamp for saving last update request from external app
91         time_t m_lastUpdateRequestTime;
92
93         friend class BoxSchemeHandler;
94 };
95
96 #endif //BOX_H
97