75cb537099796d643100c917a714ba505d4ebc1a
[platform/framework/web/web-provider.git] / src / Daemon / BoxDaemonImpl.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.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://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    BoxDaemonImpl.h
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #ifndef BOX_DAEMON_IMPL_H
21 #define BOX_DAEMON_IMPL_H
22
23 #include <string>
24 #include <memory>
25 #include <provider.h>
26 #include <Eina.h>
27 #include <Ecore.h>
28 #include <Plugin/box_plugin_interface.h>
29 #include <Core/BoxData.h>
30
31 // forward declaration
32 class IBoxManager;
33 class IBoxPluginConnector;
34
35 class BoxDaemonImpl {
36     public:
37         bool start(std::string& name);
38         bool stop();
39
40     public:
41         explicit BoxDaemonImpl();
42         ~BoxDaemonImpl();
43     
44     private:
45         // type definition
46         typedef struct event_arg ProviderEventArg;
47         typedef ProviderEventArg* ProviderEventArgPtr;
48         typedef struct event_handler ProviderCallbacks;
49         typedef ProviderCallbacks* ProviderCallbacksPtr;
50
51         // livebox's provider callbacks
52         static int connectedCallback(ProviderEventArgPtr arg, void* data);
53         static int disconnectedCallback(ProviderEventArgPtr arg, void* data);
54         static int boxCreateCallback( 
55                         ProviderEventArgPtr arg, 
56                         int* width, int* height, 
57                         double* priority, void* data);
58         static int boxReCreateCallback(ProviderEventArgPtr arg, void* data);
59         static int boxDestroyCallback(ProviderEventArgPtr arg, void* data);
60         static int pdCreateCallback(ProviderEventArgPtr arg, void* data);
61         static int pdDestroyCallback(ProviderEventArgPtr arg, void* data);
62         static int clickedCallback(ProviderEventArgPtr arg, void* data);
63         static int resizeCallback(ProviderEventArgPtr arg, void* data);
64         static int boxPauseCallback(ProviderEventArgPtr arg, void* data);
65         static int boxResumeCallback(ProviderEventArgPtr arg, void* data);
66         static int pauseCallback(ProviderEventArgPtr arg, void* data);
67         static int resumeCallback(ProviderEventArgPtr arg, void* data);
68         static int updateContentCallback(ProviderEventArgPtr arg, void* data);
69         static int changePeriodCallback(ProviderEventArgPtr arg, void* data);
70
71         // common private functions
72         void setProviderCallbacks(ProviderCallbacks& callbacks);
73         const char* getBoxType(const char* boxId);
74         //bool checkProviderEventArg(ProviderEventArgPtr arg);
75         BoxInfoPtr initializeBoxInfo(ProviderEventArgPtr arg);
76
77         // callback for ping to master daemon
78         static Eina_Bool pingToMasterCallback(void* data);
79
80         // callback for requested jobs of boxes
81         static void requestBoxJobCallback(void* data);
82
83         // members
84         std::string m_daemonName;
85         Ecore_Timer* m_pingTimer;
86         std::shared_ptr<IBoxPluginConnector> m_pluginConnector;
87 };
88
89 struct JobInfo {
90     request_cmd_type cmdType;
91     BoxInfoPtr boxInfo;
92     BoxDaemonImpl* daemonImpl;
93
94     JobInfo(request_cmd_type cmdType,
95             BoxInfoPtr boxInfo,
96             BoxDaemonImpl* daemonImpl) :
97         cmdType(cmdType),
98         boxInfo(boxInfo),
99         daemonImpl(daemonImpl)
100     {
101     };
102 };
103
104
105 #endif //BOX_DAEMON_IMPL_H
106