2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 //==========================================================================
12 * @file CicoSCServer.h
14 * @brief This file is definition of CicoSCServer class
16 //==========================================================================
17 #ifndef __CICO_SC_SERVER_H__
18 #define __CICO_SC_SERVER_H__
28 //==========================================================================
29 // forward declaration
30 //==========================================================================
31 class CicoSCUwsHandler;
34 class CicoSCWindowController;
35 class CicoSCInputController;
36 class CicoSCUserManager;
37 class CicoSCResourceManager;
38 class CicoSCPolicyManager;
40 //==========================================================================
42 * @brief This class has function of interprocess message server
44 //==========================================================================
48 // get CicoSCServer instance
49 static CicoSCServer* getInstance();
51 // set window controller instance
52 void setWindowCtrl(CicoSCWindowController* windowCtrl);
54 // set input controller instance
55 void setInputCtrl(CicoSCInputController* inputCtrl);
57 // set input controller instance
58 void setUserMgr(CicoSCUserManager* userMgr);
60 // set resource manager instance
61 void setResourceMgr(CicoSCResourceManager* resourceMgr);
63 // set resource manager instance
64 void setPolicyMgr(CicoSCPolicyManager* policyMgr);
67 int startup(int port, const char *protocol);
72 // send message to application client
73 int sendMessage(const std::string & appid, CicoSCMessage* msg);
75 // send message to homescreen
76 int sendMessageToHomeScreen(CicoSCMessage* msg);
78 // websocket callback function
79 void receiveEventCB(const struct ico_uws_context *context,
80 const ico_uws_evt_e event,
82 const ico_uws_detail *detail,
85 // clear receive command queue
86 void clearRecvCmdQueue(const std::string & appid);
88 // clear send message queue
89 void clearSendMsgQueue(const std::string & appid);
92 // default constructor
98 // assignment operator
99 CicoSCServer& operator=(const CicoSCServer &object);
102 CicoSCServer(const CicoSCServer &object);
104 // websocket utility callback function
105 static void uwsReceiveEventCB(const struct ico_uws_context *context,
106 const ico_uws_evt_e event,
108 const ico_uws_detail *detail,
111 // ecore file destructor callback fucntion
112 static Eina_Bool ecoreFdCallback(void *data,
113 Ecore_Fd_Handler *handler);
115 // add poll websocket file destructor
116 void addPollFd(CicoSCUwsHandler *handler);
118 // delete poll websocket file destructor
119 void delPollFd(CicoSCUwsHandler *handler);
121 // dispatch receive message process and send message process
122 void dispatch(const CicoSCUwsHandler *handler);
124 // find websocket handle by context and id
125 CicoSCUwsHandler* findUwsHandler(const struct ico_uws_context *context,
128 // find websocket handle by ecore file destructor handler
129 CicoSCUwsHandler* findUwsHandler(const Ecore_Fd_Handler *ecoreFdHandler);
131 // find websocket handle by appid
132 CicoSCUwsHandler* findUwsHandler(const std::string & appid);
134 // query whether the handler exists
135 bool isExistUwsHandler(const CicoSCUwsHandler *handler);
137 // notify connected appilication
138 void notifyConnected(const std::string & appid);
141 static CicoSCServer* ms_myInstance; ///< this class instance
143 struct ico_uws_context *m_uwsContext; ///< websocket utility context
145 CicoSCWindowController *m_windowCtrl; ///< window controller instance
146 CicoSCInputController *m_inputCtrl; ///< input controller instance
147 CicoSCUserManager *m_userMgr; ///< user manager instance
148 CicoSCResourceManager *m_resourceMgr; ///< resource manager instance
149 CicoSCPolicyManager *m_policyMgr; ///< policy manager instance
151 bool m_dispatchProcessing;
153 /// websocket handler list
154 std::list<CicoSCUwsHandler*> m_uwsHandlerList;
156 /// send message queue
157 std::list<CicoSCMessage*> m_sendMsgQueue;
159 /// recieve message queue
160 std::list<CicoSCCommand*> m_recvCmdQueue;
162 #endif // __CICO_SC_SERVER_H__
163 // vim:set expandtab ts=4 sw=4: