void DbusCapabilitiesUtil::copyJoynrCapaEntryToDbus(const CapabilityEntry& joynrEntry, joynr::messaging::types::Types::CapabilityEntry& dbusEntry) {
    dbusEntry.interfaceName = joynrEntry.getInterfaceName().toStdString();
    dbusEntry.domain = joynrEntry.getDomain().toStdString();
    dbusEntry.participantId = joynrEntry.getParticipantId().toStdString();
    dbusEntry.global = joynrEntry.isGlobal();

    // copy qos
    joynr::messaging::types::Types::ProviderQos qos;
    copyJoynrProviderQosToDbus(joynrEntry.getQos(), qos);
    dbusEntry.qos = qos;

    // at the moment only joynr messaging endpoint addresses are supported
    copyJoynrEndPointListToDbus(joynrEntry.getEndpointAddresses(), dbusEntry.endpointAdresses);
}
void LocalCapabilitiesDirectory::remove(const std::string& domain,
                                        const std::string& interfaceName,
                                        const types::ProviderQos& qos)
{
    // TODO does it make sense to remove any capability for a domain/interfaceName
    // without knowing which provider registered the capability
    QMutexLocker locker(cacheLock);
    QList<CapabilityEntry> entries = interfaceAddress2GlobalCapabilities.lookUpAll(InterfaceAddress(
                                         QString::fromStdString(domain), QString::fromStdString(interfaceName)));
    std::vector<std::string> participantIdsToRemove;

    types::DiscoveryEntry discoveryEntry;

    for (int i = 0; i < entries.size(); ++i) {
        CapabilityEntry entry = entries.at(i);
        if (entry.isGlobal()) {
            types::CapabilityInformation capInfo(domain,
                                                 interfaceName,
                                                 qos,
                                                 capabilitiesClient->getLocalChannelId(),
                                                 entry.getParticipantId().toStdString());
            while (registeredGlobalCapabilities.erase(
                        std::remove(registeredGlobalCapabilities.begin(),
                                    registeredGlobalCapabilities.end(),
                                    capInfo),
                        registeredGlobalCapabilities.end()) !=
                    registeredGlobalCapabilities.end()) {
            }
            participantIdsToRemove.push_back(entry.getParticipantId().toStdString());
            participantId2GlobalCapabilities.remove(entry.getParticipantId(), entry);
            interfaceAddress2GlobalCapabilities.remove(
                InterfaceAddress(entry.getDomain(), entry.getInterfaceName()), entry);
        }
        participantId2LocalCapability.remove(entry.getParticipantId(), entry);
        interfaceAddress2LocalCapabilities.remove(
            InterfaceAddress(
                QString::fromStdString(domain), QString::fromStdString(interfaceName)),
            entry);

        convertCapabilityEntryIntoDiscoveryEntry(entry, discoveryEntry);
        informObserversOnRemove(discoveryEntry);
    }
    if (!participantIdsToRemove.empty()) {
        capabilitiesClient->remove(participantIdsToRemove);
    }
}
void LocalCapabilitiesDirectory::remove(const std::string& participantId)
{
    QMutexLocker lock(cacheLock);
    CapabilityEntry entry =
        participantId2LocalCapability.take(QString::fromStdString(participantId));
    interfaceAddress2LocalCapabilities.remove(
        InterfaceAddress(entry.getDomain(), entry.getInterfaceName()), entry);
    if (entry.isGlobal()) {
        participantId2GlobalCapabilities.remove(QString::fromStdString(participantId), entry);
        interfaceAddress2GlobalCapabilities.remove(
            InterfaceAddress(entry.getDomain(), entry.getInterfaceName()), entry);
    }

    types::DiscoveryEntry discoveryEntry;
    convertCapabilityEntryIntoDiscoveryEntry(entry, discoveryEntry);
    informObserversOnRemove(discoveryEntry);

    capabilitiesClient->remove(participantId);
}