void ctkManagedServiceTracker::removedService(const ctkServiceReference& reference, ctkManagedService* service) { Q_UNUSED(service) QString pid = reference.getProperty(ctkPluginConstants::SERVICE_PID).toString(); { QMutexLocker lock(&configurationStoreMutex); removeManagedService(reference, pid); } context->ungetService(reference); }
void ctkManagedServiceTracker::modifiedService(const ctkServiceReference& reference, ctkManagedService* service) { QString pid = reference.getProperty(ctkPluginConstants::SERVICE_PID).toString(); { QMutexLocker lock(&configurationStoreMutex); if (getManagedService(pid) == service) return; QString previousPid = getPidForManagedService(service); removeManagedService(reference, previousPid); addingService(reference); } }
void ctkLogQDebug::log(const ctkServiceReference& sr, int level, const QString& message, const std::exception* exception, const char* file, const char* function, int line) { Q_UNUSED(function) QString s = QDateTime::currentDateTime().toString(Qt::ISODate) .append(" - ["); s.append(sr.getProperty(ctkPluginConstants::SERVICE_ID).toString()); s.append(";"); QStringList clazzes = sr.getProperty(ctkPluginConstants::OBJECTCLASS).toStringList(); int i = 0; foreach (QString clazz, clazzes) { if (i > 0) s.append(","); s.append(clazz); } s.append(message); exception ? s.append(" (").append(exception->what()).append(")") : false ; if (file) { s.append(" [at ").append(file).append(":").append(QString::number(line)).append("]"); } if (level == ctkLogService::LOG_WARNING) { qWarning() << s; } else if (level == ctkLogService::LOG_ERROR) { qCritical() << s; } else { qDebug() << s; } }
void ctkManagedServiceTracker::addManagedService(const ctkServiceReference& reference, const QString& pid, ctkManagedService* service) { ctkConfigurationImplPtr config = configurationStore->findConfiguration(pid); if (config.isNull() && trackManagedService(pid, reference, service)) { asynchUpdated(service, ctkDictionary()); } else { ctkConfigurationImplLocker lock(config.data()); if (trackManagedService(pid, reference, service)) { if (!config->getFactoryPid().isEmpty()) { CTK_WARN(configurationAdminFactory->getLogService()) << "Configuration for " << ctkPluginConstants::SERVICE_PID << "=" << pid << " should only be used by a ctkManagedServiceFactory"; } else if (config->isDeleted()) { asynchUpdated(service, ctkDictionary()); } else if (config->bind(reference.getPlugin())) { ctkDictionary properties = config->getProperties(); configurationAdminFactory->modifyConfiguration(reference, properties); asynchUpdated(service, properties); } else { CTK_WARN(configurationAdminFactory->getLogService()) << "Configuration for " << ctkPluginConstants::SERVICE_PID << "=" << pid << " could not be bound to " << reference.getPlugin()->getLocation(); } } } }
QSet<ctkServiceSlotEntry> ctkPluginFrameworkListeners::getMatchingServiceSlots( const ctkServiceReference& sr) { QMutexLocker lock(&mutex); Q_UNUSED(lock); QSet<ctkServiceSlotEntry> set; // Check complicated or empty listener filters int n = 0; foreach (ctkServiceSlotEntry sse, complicatedListeners) { ++n; if (sse.getLDAPExpr().isNull() || sse.getLDAPExpr().evaluate(sr.d_func()->getProperties(), false)) { set.insert(sse); } }
bool ctkLDAPSearchFilter::match(const ctkServiceReference& reference) const { return d->ldapExpr.evaluate(reference.d_func()->getProperties(), true); }