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.
17 /* standard library header */
20 /* SLP library header */
24 #include "ClientInstance.h"
25 #include "ServerResource.h"
26 #include "SignatureHelper.h"
28 namespace smartcard_service_api
30 void ClientInstance::setPID(int pid)
35 ServiceInstance *ClientInstance::createService(unsigned int context)
37 ServiceInstance *result = NULL;
39 if ((result = getService(context)) == NULL)
41 result = new ServiceInstance(this, context);
44 mapServices.insert(make_pair(context, result));
53 _ERR("service already exist [%d]", context);
59 ServiceInstance *ClientInstance::getService(unsigned int context)
61 ServiceInstance *result = NULL;
62 map<unsigned int, ServiceInstance *>::iterator item;
64 if ((item = mapServices.find(context)) != mapServices.end())
66 result = item->second;
72 void ClientInstance::removeService(unsigned int context)
74 map<unsigned int, ServiceInstance *>::iterator item;
76 if ((item = mapServices.find(context)) != mapServices.end())
79 mapServices.erase(item);
83 void ClientInstance::removeServices()
85 map<unsigned int, ServiceInstance *>::iterator item;
87 for (item = mapServices.begin(); item != mapServices.end(); item++)
95 bool ClientInstance::sendMessageToAllServices(int socket, Message &msg)
98 map<unsigned int, ServiceInstance *>::iterator item;
100 for (item = mapServices.begin(); item != mapServices.end(); item++)
102 if (ServerIPC::getInstance()->sendMessage(socket, &msg) == false)
109 void ClientInstance::generateCertificationHashes()
111 SignatureHelper::getCertificationHashes(getPID(), certHashes);
113 } /* namespace smartcard_service_api */