[Release] livebox.web-provider-1.46
[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.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    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 <app.h>
26 #include <provider.h>
27 #include <Eina.h>
28 #include <Ecore.h>
29 #include <Plugin/box_plugin_interface.h>
30 #include <Core/BoxData.h>
31
32 // forward declaration
33 class IBoxManager;
34 class IBoxPluginConnector;
35
36 class BoxDaemonImpl {
37     public:
38         bool start(std::string& name);
39         bool stop();
40         bool handleAppService(service_h service);
41
42     public:
43         explicit BoxDaemonImpl();
44         ~BoxDaemonImpl();
45     
46     private:
47         // type definition
48         typedef struct event_arg ProviderEventArg;
49         typedef ProviderEventArg* ProviderEventArgPtr;
50         typedef struct event_handler ProviderCallbacks;
51         typedef ProviderCallbacks* ProviderCallbacksPtr;
52
53         // livebox's provider callbacks
54         static int connectedCallback(ProviderEventArgPtr arg, void* data);
55         static int disconnectedCallback(ProviderEventArgPtr arg, void* data);
56         static int boxCreateCallback( 
57                         ProviderEventArgPtr arg, 
58                         int* width, int* height, 
59                         double* priority, void* data);
60         static int boxReCreateCallback(ProviderEventArgPtr arg, void* data);
61         static int boxDestroyCallback(ProviderEventArgPtr arg, void* data);
62         static int pdCreateCallback(ProviderEventArgPtr arg, void* data);
63         static int pdDestroyCallback(ProviderEventArgPtr arg, void* data);
64         static int clickedCallback(ProviderEventArgPtr arg, void* data);
65         static int boxResizeCallback(ProviderEventArgPtr arg, void* data);
66         static int boxPauseCallback(ProviderEventArgPtr arg, void* data);
67         static int boxResumeCallback(ProviderEventArgPtr arg, void* data);
68         static int pauseCallback(ProviderEventArgPtr arg, void* data);
69         static int resumeCallback(ProviderEventArgPtr arg, void* data);
70         static int boxPeriodChangeCallback(ProviderEventArgPtr arg, void* data);
71         static int boxUpdateCallback(ProviderEventArgPtr arg, void* data);
72
73         // common private functions
74         void setProviderCallbacks(ProviderCallbacks& callbacks);
75         std::string getBoxType(const char* boxId);
76         BoxInfoPtr initializeBoxInfo(ProviderEventArgPtr arg);
77
78         // functions for handling appcontrol per operation
79         std::string getBoxIdFromService(service_h service);
80         bool isServiceCallerBoxOwner(service_h service);
81         BoxInfoPtr handleOperationUpdate(service_h service);
82
83         // callback for ping to master daemon
84         static Eina_Bool pingToMasterCallback(void* data);
85
86         // callback for requested jobs of boxes
87         static void requestBoxJobCallback(void* data);
88
89         // members
90         std::string m_daemonName;
91         Ecore_Timer* m_pingTimer;
92         std::shared_ptr<IBoxPluginConnector> m_pluginConnector;
93 };
94
95 struct JobInfo {
96     request_cmd_type cmdType;
97     BoxInfoPtr boxInfo;
98     BoxDaemonImpl* daemonImpl;
99
100     JobInfo(request_cmd_type cmdType,
101             BoxInfoPtr boxInfo,
102             BoxDaemonImpl* daemonImpl) :
103         cmdType(cmdType),
104         boxInfo(boxInfo),
105         daemonImpl(daemonImpl)
106     {
107     };
108 };
109
110
111 #endif //BOX_DAEMON_IMPL_H
112