コード例 #1
0
void QServiceDiscovery::deinitializeMdns()
{
    if (m_jdns == NULL)
    {
        return;
    }

#ifdef QT_DEBUG
    DEBUG_TAG(1, "SD", "Deinitializing JDNS");
#endif

    if (m_running)
    {
        if (m_lookupMode == UnicastDNS)
        {
            m_unicastLookupTimer->stop();
        }

        removeAllServiceTypes();
        m_queryIdItemMap.clear();
        m_queryIdServiceMap.clear();
        m_queryIdTypeMap.clear();
    }

    m_jdns->deleteLater();
    m_jdns = NULL;

#if defined(Q_OS_ANDROID)
    QAndroidJniObject::callStaticMethod<void>("io/machinekit/service/MulticastActivator",
                                              "disable");
#endif

    m_lookupReady = false;                      // lookup no ready anymore
    emit lookupReadyChanged(m_lookupReady);
}
コード例 #2
0
void ServiceDiscovery::deinitializeMdns(bool cleanup)
{
    if (m_jdns.isNull())
    {
        return;
    }

    DEBUG_TAG(1, "SD", "Deinitializing JDNS");

    if (m_running && cleanup)
    {
        if (m_lookupMode == UnicastDNS)
        {
            m_unicastLookupTimer.stop();
        }

        removeAllServiceTypes();
        m_queryIdItemMap.clear();
        m_queryIdServiceMap.clear();
        m_queryIdTypeMap.clear();
    }

    m_jdns->deleteLater();
    m_jdns.clear();

#if defined(Q_OS_ANDROID)
    if (m_lookupMode == MulticastDNS) {
        QtAndroid::runOnAndroidThreadSync([](){
            QAndroidJniObject::callStaticMethod<void>("io/machinekit/service/MulticastActivator", "disable");
        });
    }
#endif

    if (cleanup) {
        m_lookupReady = false;                      // lookup not ready anymore
        emit lookupReadyChanged(m_lookupReady);
    }
}