namespace smartcard_service_api
{
- void ClientInstance::setPID(int pid)
- {
- this->pid = pid;
- }
-
- ServiceInstance *ClientInstance::createService(unsigned int context)
+ ServiceInstance *ClientInstance::createService()
{
ServiceInstance *result = NULL;
- if ((result = getService(context)) == NULL)
- {
- result = new ServiceInstance(this, context);
- if (result != NULL)
- {
- mapServices.insert(make_pair(context, result));
- }
- else
- {
- _ERR("alloc failed");
- }
- }
- else
- {
- _ERR("service already exist [%d]", context);
+ result = new ServiceInstance(this);
+ if (result != NULL) {
+ mapServices.insert(make_pair(result->getHandle(), result));
+ } else {
+ _ERR("alloc failed"); //LCOV_EXCL_LINE
}
return result;
}
- ServiceInstance *ClientInstance::getService(unsigned int context)
+ ServiceInstance *ClientInstance::getService(unsigned int handle)
{
+ /* LCOV_EXCL_START */
ServiceInstance *result = NULL;
map<unsigned int, ServiceInstance *>::iterator item;
- if ((item = mapServices.find(context)) != mapServices.end())
+ if ((item = mapServices.find(handle)) != mapServices.end())
{
result = item->second;
}
return result;
+ /* LCOV_EXCL_STOP */
}
- void ClientInstance::removeService(unsigned int context)
+ void ClientInstance::removeService(unsigned int handle)
{
+ /* LCOV_EXCL_START */
map<unsigned int, ServiceInstance *>::iterator item;
- if ((item = mapServices.find(context)) != mapServices.end())
+ if ((item = mapServices.find(handle)) != mapServices.end())
{
delete item->second;
mapServices.erase(item);
}
+ /* LCOV_EXCL_STOP */
}
void ClientInstance::removeServices()
mapServices.clear();
}
- bool ClientInstance::sendMessageToAllServices(int socket, Message &msg)
- {
- bool result = true;
- map<unsigned int, ServiceInstance *>::iterator item;
-
- for (item = mapServices.begin(); item != mapServices.end(); item++)
- {
- if (ServerIPC::getInstance()->sendMessage(socket, &msg) == false)
- result = false;
- }
-
- return result;
- }
-
void ClientInstance::generateCertificationHashes()
{
SignatureHelper::getCertificationHashes(getPID(), certHashes);