1 #ifndef __DALI_INTERNAL_ADAPTOR_ECORE_SERVER_CONNECTION_H_
2 #define __DALI_INTERNAL_ADAPTOR_ECORE_SERVER_CONNECTION_H_
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <Ecore_Ipc.h>
25 #include <dali/public-api/common/vector-wrapper.h>
35 * Makes a connection to a given service as a client
37 class ServerConnection
41 * Observes the connection for data and connection closure
47 * Inform that data has been received on the connection
48 * @param[in] event The event that has been received
50 virtual void DataReceived(void* event) = 0;
53 * Inform the observer that the connection has closed
55 virtual void ConnectionClosed() = 0;
61 * @param[in] serviceName The name of the service
62 * @param[in] serviceNumber The number of the service
63 * @param[in] isSystem Whether to connect as local user or system user
64 * @param[in] observer The connection observer
66 ServerConnection(const char *serviceName, int serviceNumber, bool isSystem, Observer* observer);
74 * Test if the connection is still alive
75 * @return True if the connection is still alive
80 * Disconnect from the server. Will trigger ConnectionClosed() observer callback
85 * Send an event to the server.
86 * @param[in] event Event id
87 * @param[in] data Pointer to the event data
88 * @param[in] size Size of the event data
89 * @return whether the event is sent successfully or not
91 bool SendEvent( int event, const void *data, int size );
94 * Send an event to the server.
95 * @param[in] event Event id
96 * @param[in] ref Message Reference number
97 * @param[in] refTo Reference number of the message this refers to
98 * @param[in] data Pointer to the event data
99 * @param[in] size Size of the event data
100 * @return whether the event is sent successfully or not
102 bool SendEvent( int event, int ref, int refTo, const void *data, int size );
104 private: // Class callbacks
106 * Callback when server added
108 static Eina_Bool IpcServerAdd(void *data, int type, void *event);
111 * Callback when server deleted
113 static Eina_Bool IpcServerDel(void *data, int type, void *event);
116 * Callback when data available from server
118 static Eina_Bool IpcServerData(void *data, int type, void *event);
122 ServerConnection( const ServerConnection& ); ///< Undefined
123 ServerConnection& operator=( const ServerConnection& ); ///< Undefined
125 void CloseConnection();
128 typedef std::vector<Ecore_Event_Handler *> Handlers;
140 Ecore_Ipc_Server* mIpcServer;
141 Handlers mIpcHandlers;
148 #endif // __DALI_INTERNAL_ADAPTOR_ECORE_SERVER_CONNECTION_H_