Exemplo n.º 1
0
QxtMDNS::QxtMDNS(int id, QObject* parent)
		: QObject(parent)
{
	QXT_INIT_PRIVATE(QxtMDNS);
	qxt_d().info = QHostInfo(id);
	qxt_d().client = NULL;
	qxt_d().recordbrowser = NULL;
	qxt_d().sent = false;
}
Exemplo n.º 2
0
void
SipInfo::clear()
{
    d->visible.clear();
    d->host = QHostInfo();
    d->port = -1;
    d->uniqname = QString();
    d->key = QString();
}
Exemplo n.º 3
0
// ----------------------------------------------------------------------------
// getHostInfo (static)
// ----------------------------------------------------------------------------
QHostInfo NetworkTools::getHostInfo(const QString &in_name)
{
    QHostInfo host_info;

    if (in_name.isEmpty()) host_info = QHostInfo::fromName(QHostInfo::localHostName());
    else host_info = QHostInfo::fromName(in_name);

    if (host_info.error() != QHostInfo::NoError) return QHostInfo();

    return host_info;
}
Exemplo n.º 4
0
QHostInfo QHostInfoCache::get(const QString &name, bool *valid)
{
    QMutexLocker locker(&this->mutex);

    *valid = false;
    if (QHostInfoCacheElement *element = cache.object(name)) {
        if (element->age.elapsed() < max_age*1000)
            *valid = true;
        return element->info;

        // FIXME idea:
        // if too old but not expired, trigger a new lookup
        // to freshen our cache
    }

    return QHostInfo();
}
Exemplo n.º 5
0
// This function returns immediately when we had a result in the cache, else it will later emit a signal
QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id)
{
    *valid = false;
    *id = -1;

    // check cache
    QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager();
    if (manager && manager->cache.isEnabled()) {
        QHostInfo info = manager->cache.get(name, valid);
        if (*valid) {
            return info;
        }
    }

    // was not in cache, trigger lookup
    *id = QHostInfo::lookupHost(name, receiver, member);

    // return empty response, valid==false
    return QHostInfo();
}