Add NOTICE, AUTHOR file and modify boilerplate
[platform/core/connectivity/smartcard-service.git] / server / include / ClientInstance.h
1 /*
2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
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
18 #ifndef CLIENTINSTANCE_H_
19 #define CLIENTINSTANCE_H_
20
21 /* standard library header */
22 #include <map>
23 #include <vector>
24 #if 1
25 #include <glib.h>
26 #endif
27
28 /* SLP library header */
29
30 /* local header */
31 #include "Message.h"
32 #include "ServiceInstance.h"
33
34 namespace smartcard_service_api
35 {
36         class ClientInstance
37         {
38         private:
39                 void *ioChannel;
40                 int socket;
41                 int watchID;
42                 int state;
43                 int pid;
44                 vector<ByteArray> certHashes;
45                 map<unsigned int, ServiceInstance *> mapServices;
46
47                 static gboolean _getCertificationHashes(gpointer user_data);
48
49         public:
50                 ClientInstance(void *ioChannel, int socket, int watchID, int state, int pid)
51                 {
52                         this->ioChannel = ioChannel;
53                         this->socket = socket;
54                         this->watchID = watchID;
55                         this->state = state;
56                         this->pid = pid;
57                 }
58                 ~ClientInstance() { removeServices(); }
59
60                 inline bool operator ==(const int &socket) const { return (this->socket == socket); }
61
62                 inline void *getIOChannel() { return ioChannel; }
63                 inline int getSocket() { return socket; }
64                 inline int getWatchID() { return watchID; }
65                 inline int getState() { return state; }
66
67                 void setPID(int pid);
68                 inline int getPID() { return pid; }
69
70                 bool createService(unsigned int context);
71                 ServiceInstance *getService(unsigned int context);
72                 void removeService(unsigned int context);
73                 void removeServices();
74
75                 bool sendMessageToAllServices(int socket, Message &msg);
76                 void generateCertificationHashes();
77
78                 inline vector<ByteArray> &getCertificationHashes() { return certHashes; }
79
80                 friend gboolean _getCertificationHashes(gpointer user_data);
81         };
82 } /* namespace smartcard_service_api */
83 #endif /* CLIENTINSTANCE_H_ */