Exemplo n.º 1
0
void Avahi::removeService(int, int, const QString &name, const QString &, const QString &domain, uint)
{
    if (isLocalDomain(domain) && services.contains(name)) {
        services[name]->deleteLater();
        disconnect(services[name], SIGNAL(serviceResolved(QString)), this, SIGNAL(serviceAdded(QString)));
        services.remove(name);
        emit serviceRemoved(name);
    }
}
Exemplo n.º 2
0
ServiceModel::ServiceModel(ServiceBrowser *browser, QObject *parent)
    :  QAbstractItemModel(parent), d(new ServiceModelPrivate)
{
    d->m_browser = browser;
    browser->setParent(this);
    connect(browser, SIGNAL(serviceAdded(KDNSSD::RemoteService::Ptr)), this,
            SIGNAL(layoutChanged()));
    connect(browser, SIGNAL(serviceRemoved(KDNSSD::RemoteService::Ptr)), this,
            SIGNAL(layoutChanged()));
    browser->startBrowse();
}
Exemplo n.º 3
0
void QConnectionManager::servicesListChanged(const QStringList &list)
{
    bool ok = false;
    Q_FOREACH(const QString &path,list) {
        if (orderedServicesList.indexOf((path)) == -1) {
         //added
            qDebug() << Q_FUNC_INFO << "added" << path;
            serviceAdded(path);
            ok = true;
        }
    }
    Q_FOREACH(const QString &path,orderedServicesList) {
        if (list.indexOf((path)) == -1) {
            qDebug() << Q_FUNC_INFO << "removed" << path;
            serviceRemoved(path);
            ok = true;
         //removed
        }
    }
    if (ok && serviceInProgress.isEmpty())
        autoConnect();
}
Exemplo n.º 4
0
void DNSSDNetworkBuilder::addServiceType( const QString& serviceType )
{
kDebug()<<serviceType<<mServiceBrowserTable.contains(serviceType);
    if( mServiceBrowserTable.contains(serviceType))
        return;

// kDebug()<<serviceType;
    DNSSD::ServiceBrowser* serviceBrowser = new DNSSD::ServiceBrowser( serviceType, true );
    connect( serviceBrowser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)),
            SLOT(addService(DNSSD::RemoteService::Ptr)) );
    connect( serviceBrowser, SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)),
            SLOT(removeService(DNSSD::RemoteService::Ptr)) );

    if( mIsInit )
    {
        ++mNoOfInitServiceTypes;
        connect( serviceBrowser, SIGNAL(finished()), SLOT(onServiceBrowserFinished()) );
    }

    mServiceBrowserTable[serviceType] = serviceBrowser;
    serviceBrowser->startBrowse();
}
Exemplo n.º 5
0
  void ServiceDirectory::unregisterService(const unsigned int &idx)
  {
    boost::recursive_mutex::scoped_lock lock(mutex);
    bool pending = false;
    // search the id before accessing it
    // otherwise operator[] create a empty entry
    std::map<unsigned int, ServiceInfo>::iterator it2;
    it2 = connectedServices.find(idx);
    if (it2 == connectedServices.end()) {
      qiLogVerbose() << "Unregister Service: service #" << idx << " not found in the"
                     << " connected list. Looking in the pending list.";
      it2 = pendingServices.find(idx);
      pending = true;
      if (it2 == pendingServices.end())
      {
        std::stringstream ss;
        ss << "Unregister Service: Can't find service #" << idx;
        qiLogVerbose() << ss.str();
        throw std::runtime_error(ss.str());
      }
    }

    std::string serviceName = it2->second.name();

    std::map<std::string, unsigned int>::iterator it;
    it = nameToIdx.find(serviceName);
    if (it == nameToIdx.end())
    {
      std::stringstream ss;
      ss << "Unregister Service: Mapping error, service #" << idx << " (" << serviceName << ") not in nameToIdx";
      qiLogError() << ss.str();
      throw std::runtime_error(ss.str());
    }


    std::stringstream ss;
    ss << "Unregistered Service \""
          << serviceName
          << "\" (#" << idx << ")";

    if (! serviceName.empty() && serviceName[0] == '_') {
      // Hide services whose name starts with underscore
      qiLogDebug() << ss.str();
    }
    else
    {
      qiLogInfo() << ss.str();
    }

    nameToIdx.erase(it);
    if (pending)
      pendingServices.erase(it2);
    else
      connectedServices.erase(it2);

    // Find and remove serviceId into socketToIdx map
    {
      std::map<TransportSocketPtr , std::vector<unsigned int> >::iterator it;
      for (it = socketToIdx.begin(); it != socketToIdx.end(); ++it) {
        std::vector<unsigned int>::iterator jt;
        for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
          if (*jt == idx) {
            it->second.erase(jt);
            //socketToIdx is erased by onSocketDisconnected
            break;
          }
        }
      }
    }

    serviceRemoved(idx, serviceName);
  }
Exemplo n.º 6
0
 void ServiceDirectoryClient::onServiceRemoved(unsigned int idx, const std::string &name) {
   qiLogVerbose() << "ServiceDirectoryClient: Service Removed #" << idx << ": " << name << std::endl;
   serviceRemoved(idx, name);
 }