2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 /* standard library header */
25 #include <sys/epoll.h>
28 /* SLP library header */
32 #include "DispatcherHelper.h"
34 namespace smartcard_service_api
39 static const int IPC_SERVER_PORT = 8989;
40 static const int IPC_SERVER_MAX_CLIENT = 10;
44 GIOChannel *ioChannel;
45 pthread_mutex_t ipcLock;
46 DispatcherHelper *dispatcher;
47 #ifdef CLIENT_IPC_THREAD
49 static const int EPOLL_SIZE = 5;
51 struct epoll_event *pollEvents;
57 static void *threadRead(void *data);
61 static gboolean channelCallbackFunc(GIOChannel* channel, GIOCondition condition, gpointer data);
63 virtual int handleIOErrorCondition(void *channel, GIOCondition condition) = 0;
64 virtual int handleInvalidSocketCondition(void *channel, GIOCondition condition) = 0;
65 virtual int handleIncomingCondition(void *channel, GIOCondition condition) = 0;
71 bool createListenSocket();
72 bool createConnectSocket();
73 void destroyListenSocket();
74 void destroyConnectSocket();
76 bool sendMessage(int socket, Message *msg);
77 bool sendMessage(int socket, ByteArray &buffer);
78 Message *retrieveMessage();
79 ByteArray retrieveBuffer(int socket);
80 Message *retrieveMessage(int socket);
82 void setDispatcher(DispatcherHelper *dispatcher);
84 #ifdef CLIENT_IPC_THREAD
85 friend void *threadRead(void *data);
87 friend gboolean channelCallbackFunc(GIOChannel* channel, GIOCondition condition, gpointer data);
90 } /* namespace smartcard_service_api */
91 #endif /* IPCHELPER_H_ */