Esempio n. 1
0
void ServiceDiscovery::removeAllServiceTypes()
{
    const auto keys = m_serviceItemsMap.keys(); // copy necessary since we modify the map
    for (const auto &key: keys)
    {
        removeServiceType(key);
    }
}
Esempio n. 2
0
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 DNSSDNetworkBuilder::start()
{
    mIsInit = true;
    mNoOfInitServiceTypes = 0;

    mServiceTypeBrowser = new DNSSD::ServiceTypeBrowser();
    connect( mServiceTypeBrowser, SIGNAL(serviceTypeAdded(QString)),
             SLOT(addServiceType(QString)) );
    connect( mServiceTypeBrowser, SIGNAL(serviceTypeRemoved(QString)),
             SLOT(removeServiceType(QString)) );
    connect( mServiceTypeBrowser, SIGNAL(finished()), SLOT(onServiceTypeBrowserFinished()) );
// TODO: add a signal network initialized to Network, so is cleared when first usable
    mServiceTypeBrowser->startBrowse();
}
Esempio n. 4
0
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
}