namespace smartcard_service_api
{
-#if 1
- gboolean ClientInstance::_getCertificationHashes(gpointer user_data)
+ ServiceInstance *ClientInstance::createService()
{
- gboolean result = false;
- ClientInstance *instance = (ClientInstance *)user_data;
-
- SignatureHelper::getCertificationHashes(instance->getPID(), instance->certHashes);
-
- return result;
- }
-#endif
-
- void ClientInstance::setPID(int pid)
- {
- this->pid = pid;
-
-#if 0
- if (pid > 0)
- {
- certHash = SignatureHelper::getCertificationHash(pid);
- }
-#endif
- }
-
- bool ClientInstance::createService(unsigned int context)
- {
- bool result = false;
+ ServiceInstance *result = NULL;
- if (getService(context) == NULL)
- {
- ServiceInstance *instance = new ServiceInstance(this, context);
- if (instance != NULL)
- {
- mapServices.insert(make_pair(context, instance));
- result = true;
- }
- else
- {
- SCARD_DEBUG_ERR("alloc failed");
- }
- }
- else
- {
- SCARD_DEBUG_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()
{
-#if 1
- g_idle_add(_getCertificationHashes, (gpointer)this);
-#else
SignatureHelper::getCertificationHashes(getPID(), certHashes);
-#endif
}
} /* namespace smartcard_service_api */