void ServiceDiscovery::stopAllQueries() { for (auto iter = m_serviceItemsMap.begin(); iter != m_serviceItemsMap.end(); ++iter) { stopQuery(iter.key()); } }
void QServiceDiscovery::updateServices() { QMap<QString, QList<QServiceDiscoveryItem*> > oldServiceTypeMap; oldServiceTypeMap = m_serviceItemsMap; // Iterate through all services and update all service types foreach (QServiceList *serviceList, m_serviceLists) { for (int i = 0; i < serviceList->serviceCount(); ++i) { QService *service; service = serviceList->service(i); disconnect(service, SIGNAL(queriesChanged()), this, SLOT(updateServices())); connect(service, SIGNAL(queriesChanged()), this, SLOT(updateServices())); for (int j = 0; j < service->queriesCount(); ++j) { QServiceDiscoveryQuery *query; query = service->query(j); if (!query->serviceType().isEmpty()) { addServiceType(query->serviceType(), query->queryType()); oldServiceTypeMap.remove(query->serviceType()); if (m_running && m_networkReady) { startQuery(query->serviceType()); } } } } } // Iterate trough all item that are left and remove them QMapIterator<QString, QList<QServiceDiscoveryItem*> > i(oldServiceTypeMap); while (i.hasNext()) { i.next(); if (m_running && m_networkReady) { stopQuery(i.key()); } removeServiceType(i.key()); } updateAllServiceTypes(); // now we need to refill all queries with fresh data }
void ServiceDiscovery::updateServices() { QMap<QString, QList<ServiceDiscoveryItem*> > oldServiceTypeMap; oldServiceTypeMap = m_serviceItemsMap; // Iterate through all services and update all service types for (ServiceList *serviceList: qAsConst(m_serviceLists)) { for (Service *service: *serviceList) { disconnect(service, &Service::queriesChanged, this, &ServiceDiscovery::updateServices); connect(service, &Service::queriesChanged, this, &ServiceDiscovery::updateServices); for (ServiceDiscoveryQuery *query: *service) { if (!query->serviceType().isEmpty()) { addServiceType(query->serviceType(), query->queryType()); oldServiceTypeMap.remove(query->serviceType()); if (m_running && m_networkReady) { startQuery(query->serviceType()); } } } } } // Iterate trough all items that are left and remove them for (auto iter = oldServiceTypeMap.begin(); iter != oldServiceTypeMap.end(); ++iter) { if (m_running && m_networkReady) { stopQuery(iter.key()); } removeServiceType(iter.key()); } updateAllServiceTypes(); // now we need to refill all queries with fresh data }