/*!
    Looks up the IP address(es) associated with host name \a name, and
    returns an ID for the lookup. When the result of the lookup is
    ready, the slot or signal \a member in \a receiver is called with
    a QHostInfo argument. The QHostInfo object can then be inspected
    to get the results of the lookup.

    The lookup is performed by a single function call, for example:

    \snippet code/src_network_kernel_qhostinfo.cpp 2

    The implementation of the slot prints basic information about the
    addresses returned by the lookup, or reports an error if it failed:

    \snippet code/src_network_kernel_qhostinfo.cpp 3

    If you pass a literal IP address to \a name instead of a host name,
    QHostInfo will search for the domain name for the IP (i.e., QHostInfo will
    perform a \e reverse lookup). On success, the resulting QHostInfo will
    contain both the resolved domain name and IP addresses for the host
    name. Example:

    \snippet code/src_network_kernel_qhostinfo.cpp 4

    \note There is no guarantee on the order the signals will be emitted
    if you start multiple requests with lookupHost().

    \sa abortHostLookup(), addresses(), error(), fromName()
*/
int QHostInfo::lookupHost(const QString &name, QObject *receiver,
                          const char *member)
{
#if defined QHOSTINFO_DEBUG
    qDebug("QHostInfo::lookupHost(\"%s\", %p, %s)",
           name.toLatin1().constData(), receiver, member ? member + 1 : 0);
#endif

    if (!QAbstractEventDispatcher::instance(QThread::currentThread())) {
        qWarning("QHostInfo::lookupHost() called with no event dispatcher");
        return -1;
    }

    qRegisterMetaType<QHostInfo>();

    int id = theIdCounter.fetchAndAddRelaxed(1); // generate unique ID

    if (name.isEmpty()) {
        if (!receiver)
            return -1;

        QHostInfo hostInfo(id);
        hostInfo.setError(QHostInfo::HostNotFound);
        hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given"));
        QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
        QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
                         receiver, member, Qt::QueuedConnection);
        result.data()->emitResultsReady(hostInfo);
        return id;
    }

    QHostInfoLookupManager *manager = theHostInfoLookupManager();

    if (manager) {
        // the application is still alive
        if (manager->cache.isEnabled()) {
            // check cache first
            bool valid = false;
            QHostInfo info = manager->cache.get(name, &valid);
            if (valid) {
                if (!receiver)
                    return -1;

                info.setLookupId(id);
                QHostInfoResult result;
                QObject::connect(&result, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
                result.emitResultsReady(info);
                return id;
            }
        }

        // cache is not enabled or it was not in the cache, do normal lookup
        QHostInfoRunnable* runnable = new QHostInfoRunnable(name, id);
        if (receiver)
            QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
        manager->scheduleLookup(runnable);
    }
    return id;
}
Esempio n. 2
0
DNSResolver::DNSResolver()
{
    m_dnsShared = new JDnsShared(JDnsShared::UnicastInternet);
    m_dnsShared->addInterface(QHostAddress::Any);
    m_dnsShared->addInterface(QHostAddress::AnyIPv6);
    m_dnsSharedRequest = new JDnsSharedRequest(m_dnsShared);

    connect(m_dnsSharedRequest, SIGNAL(resultsReady()), SLOT(resultsReady()));
}
Esempio n. 3
0
BSocket::BSocket(QObject *parent)
:ByteStream(parent)
{
	d = new Private;
#ifndef NO_NDNS
	connect(&d->ndns, SIGNAL(resultsReady()), SLOT(ndns_done()));
#endif
	connect(&d->srv, SIGNAL(resultsReady()), SLOT(srv_done()));

	reset();
}
Esempio n. 4
0
void tst_Q3Dns::simpleLookup()
{
    // Stuff
    int c = 0;
    char **v = 0;
    QCoreApplication a(c, v);
    Q3Dns dns("qt.nokia.com");

    QSignalSpy spy(&dns, SIGNAL(resultsReady()));
    connect(&dns, SIGNAL(resultsReady()), this, SLOT(simpleLookupDone()));
    QTestEventLoop::instance().enterLoop(5);
    if (QTestEventLoop::instance().timeout())
        QFAIL("Network operation timed out");
    QCOMPARE(spy.count(), 1);
}
Esempio n. 5
0
void DatabaseQuery::runJoin() {
    qDebug() << "Run Join";
    if (m_results.count() == 2) {
        //qSort(m_results);
        DataStore firstBase = m_results.takeFirst();
        DataStore secondBase = m_results.takeFirst();

        if (firstBase.rowCount() > 0 && secondBase.rowCount() > 0) {
            // m_dataHeaders contains the imported salesforce IDs
            DataStore joinResult;
            joinResult.setHeader(firstBase.dataHeaders() + secondBase.dataHeaders().mid(1));
            joinResult.setTypes( firstBase.typeList() + secondBase.typeList().mid(1));
            QListIterator<QStringList> index(firstBase.dataList());
            for (int row = 0; index.hasNext(); row++) {
                QStringList list = index.next();
                if (! list.empty()) {
                    QStringList secondList = secondBase.dataHash()[list.first()].mid(1);
                    if (! secondList.isEmpty()) {
                        // m_dataHash will look up the imported salesforce IDs.
                        list += secondList;
                        joinResult.appendData(list);
                    }
                }
            }
            resultsReady(joinResult);
        }
    }
}
Esempio n. 6
0
Smtp::Smtp( const QString &from, const QString &to,
	    const QString &subject,
	    const QString &body )
{
    socket = new QSocket( this );
    connect ( socket, SIGNAL( readyRead() ),
	      this, SLOT( readyRead() ) );
    connect ( socket, SIGNAL( connected() ),
	      this, SLOT( connected() ) );

    mxLookup = new QDns( to.mid( to.find( '@' )+1 ), QDns::Mx );
    connect( mxLookup, SIGNAL(resultsReady()),
	     this, SLOT(dnsLookupHelper()) );

    message = QString::fromLatin1( "From: " ) + from +
	      QString::fromLatin1( "\nTo: " ) + to +
	      QString::fromLatin1( "\nSubject: " ) + subject +
	      QString::fromLatin1( "\n\n" ) + body + "\n";
    message.replace( QString::fromLatin1( "\n" ),
		     QString::fromLatin1( "\r\n" ) );
    message.replace( QString::fromLatin1( "\r\n.\r\n" ),
		     QString::fromLatin1( "\r\n..\r\n" ) );

    this->from = from;
    rcpt = to;

    state = Init;
}
Esempio n. 7
0
void SingleCellViewSimulationData::reset()
{
    stopAllSimulations();
    newIntegrationRun();

    if (!mIntegrationRun)
        return;

    // Reset our model parameter values which means both initialising our
    // 'constants' and computing our 'computed constants' and 'variables'
    mConstants.clear();
    mStates.clear();
    mRates.clear();
    mAlgebraic.clear();
    mCondVar.clear();

    mState = SingleCellViewSimulationData::SIMSTATE_WAITING_IV;
    mIVGrabber = new GrabInitialValueListener(mIntegrationRun);
    mDidReset = true;
    QObject::connect(mIVGrabber, SIGNAL(resultsReady()), this, SLOT(initialValuesIn()));
    QObject::connect(mIVGrabber, SIGNAL(solveFailure(QString)), this, SLOT(initialValuesFailed(QString)));
    mIntegrationRun->setProgressObserver(mIVGrabber);
    mIntegrationRun->setResultRange(mStartingPoint, mStartingPoint, 1);
    
    mIntegrationRun->start();
}
Esempio n. 8
0
void SIMResolver::resolveTimeout()
{
    bDone    = true;
    bTimeout = true;
    getSocketFactory()->setActive(false);
    QTimer::singleShot(0, parent(), SLOT(resultsReady()));
}
Esempio n. 9
0
void SQLite::slotResults(const QList<QSqlRecord> &result)
{
    qDebug() << __PRETTY_FUNCTION__;
    qDebug() << "count="<<result.count();


    QVariantList val;

    QListIterator<QSqlRecord> sqlRecordsIterator(result);

    while(sqlRecordsIterator.hasNext())
    {
        QSqlRecord sqlRecord = sqlRecordsIterator.next();
        QVariantMap dataMap;
        for(int column = 0; column < sqlRecord.count(); column++)
        {
            //qDebug() << sqlRecord.fieldName(column);
            dataMap.insert(sqlRecord.fieldName(column), sqlRecord.value(column));
        }
        val.append(QVariant::fromValue(dataMap));
    }
    qDebug() << "count of list=" << val.count();
    resultsReady(val, m_query);
    setStatus(Ready);
}
Esempio n. 10
0
void SrvResolver::t_timeout()
{
	SafeDeleteLock s(&d->sd);

	stop();
	resultsReady();
}
Esempio n. 11
0
void SvnDiffJob::setDiff( const QString& diff )
{
    m_diff = KDevelop::VcsDiff();
    m_diff.setBaseDiff(KUrl("/"));
    m_diff.setType( KDevelop::VcsDiff::DiffUnified );

    m_diff.setContentType( KDevelop::VcsDiff::Text );
    m_diff.setDiff( diff );

    QRegExp fileRe("(?:^|\n)Index: ([^\n]+)\n");

    QStringList paths;
    int pos = 0;

    while( ( pos = fileRe.indexIn( diff, pos ) ) != -1 )
    {
        paths << fileRe.cap(1);
        pos += fileRe.matchedLength();
    }

    if (paths.isEmpty()) {
        internalJobDone( m_job );
        emit resultsReady( this );
        return;
    }

    foreach( const QString &s, paths )
    {
        if( !s.isEmpty() )
        {
            SvnCatJob* job = new SvnCatJob( m_part );
            KDevelop::VcsLocation l = m_job->source();
            if( l.type() == KDevelop::VcsLocation::LocalLocation )
            {
                l.setLocalUrl( KUrl( s ) );
            }else
            {
                QString repoLocation = KUrl( l.repositoryServer() ).toLocalFile( KUrl::RemoveTrailingSlash );
                QFileInfo fi( repoLocation );
                if( s == fi.fileName() )
                {
                    l.setRepositoryServer( l.repositoryServer() );
                }else
                {
                    l.setRepositoryServer( l.repositoryServer() + '/' + s );
                }
            }

            job->setSource( l );
            job->setPegRevision( m_job->pegRevision() );
            job->setSrcRevision( m_job->srcRevision() );

            m_catJobMap[job] = l;

            connect( job, SIGNAL(resultsReady(KDevelop::VcsJob*)), this, SLOT(addLeftText(KDevelop::VcsJob*)) );
            connect( job, SIGNAL(result(KJob*)), this, SLOT(removeJob(KJob*)) );

            KDevelop::ICore::self()->runController()->registerJob(job);
        }
    }
Esempio n. 12
0
File: ndns.cpp Progetto: psi-im/iris
//!
//! Constructs an NDns object with parent \a parent.
NDns::NDns(QObject *parent)
:QObject(parent),dns(this)
{
    busy = false;

    connect(&dns, SIGNAL(resultsReady(QList<XMPP::NameRecord>)), SLOT(dns_resultsReady(QList<XMPP::NameRecord>)));
    connect(&dns, SIGNAL(error(XMPP::NameResolver::Error)), SLOT(dns_error(XMPP::NameResolver::Error)));
}
Esempio n. 13
0
/**
 * @brief Runs the given Algorithm and sends the results to the ResultsPageWidget.
 * @param algo The Algorithm.
 */
void SearchManager::startSearch(Algorithm *algo)
{
    mResultsPageWidget->setCursor(QCursor(Qt::CursorShape::WaitCursor));
    mThread = new AlgorithmThread(algo);
    connect(mThread, SIGNAL(resultsReady()), this, SLOT(submitResults()));
    connect(mThread, SIGNAL(finished()), mThread, SLOT(deleteLater()));
    mThread->start();
}
Esempio n. 14
0
void EvaServers::fetchAddress( bool isUdp )
{
	int num = 0;
	if(m_bIsFirst){
		m_bIsFirst = false;
		TDEConfig* config = new TDEConfig( (TQDir::homeDirPath() + "/.eva/eva.cfg") );
		config->setGroup("General");
		TQString type = config->readEntry("Server Type");
		if(!type.isEmpty()){
			TQHostAddress addr(config->readEntry("Server IP"));
			if(!addr.isNull()) {
				if( (type == "UDP" && isUdp) ||
						(type == "TCP" && !isUdp)){
					emit isReady(addr);
					return;
				}
			}
		}
		delete config;
	}
				
	if(isUdp){
		num = UDPServers.count();
		fetchType = UDP;
	} else{
		num = TCPServers.count();
		fetchType = TCP;
	}
	if(num == 0 ){
		defaultAddress();
		return;
	}
	//int index = rand() % num;

	int maxItems = isUdp?UDPServers.count():TCPServers.count();
	if(m_CurrAddrIndex>maxItems) m_CurrAddrIndex = 0;
	serverItem addr;
	if(isUdp)
		addr = UDPServers[m_CurrAddrIndex++];
	else
		addr = TCPServers[m_CurrAddrIndex++];
	
	if(addr.type == Addr_IP){
		emit isReady(TQHostAddress(addr.addr.latin1())); // this way, Red hat 9 might work properly
		return;
	}
	
	// the address should be a URL now, so we try to get the IP
	TQDns * dns =  new TQDns(addr.addr, TQDns::A);
	TQObject::connect(dns, SIGNAL(resultsReady()), this, SLOT(getResultsSlot()));


	m_Timeout = new TQTimer(this, "dns timer");
	TQObject::connect(m_Timeout, SIGNAL(timeout()), SLOT(slotTimeout()));
	m_Timeout->start(30000, true);
}
Esempio n. 15
0
/*!
    Looks up the IP address(es) associated with host name \a name, and
    returns an ID for the lookup. When the result of the lookup is
    ready, the slot or signal \a member in \a receiver is called with
    a QHostInfo argument. The QHostInfo object can then be inspected
    to get the results of the lookup.

    The lookup is performed by a single function call, for example:

    \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 2

    The implementation of the slot prints basic information about the
    addresses returned by the lookup, or reports an error if it failed:

    \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 3

    If you pass a literal IP address to \a name instead of a host name,
    QHostInfo will search for the domain name for the IP (i.e., QHostInfo will
    perform a \e reverse lookup). On success, the resulting QHostInfo will
    contain both the resolved domain name and IP addresses for the host
    name. Example:

    \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 4

    \note There is no guarantee on the order the signals will be emitted
    if you start multiple requests with lookupHost().

    \sa abortHostLookup(), addresses(), error(), fromName()
*/
int QHostInfo::lookupHost(const QString &name, QObject *receiver,
                          const char *member)
{
#if defined QHOSTINFO_DEBUG
    qDebug("QHostInfo::lookupHost(\"%s\", %p, %s)",
           name.toLatin1().constData(), receiver, member ? member + 1 : 0);
#endif
    if (!QAbstractEventDispatcher::instance(QThread::currentThread())) {
        qWarning("QHostInfo::lookupHost() called with no event dispatcher");
        return -1;
    }

    qRegisterMetaType<QHostInfo>("QHostInfo");

    int id = theIdCounter.fetchAndAddRelaxed(1); // generate unique ID

    if (name.isEmpty()) {
        QHostInfo hostInfo(id);
        hostInfo.setError(QHostInfo::HostNotFound);
        hostInfo.setErrorString(QObject::tr("No host name given"));
        QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
        QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
                         receiver, member, Qt::QueuedConnection);
        result.data()->emitResultsReady(hostInfo);
        return id;
    }

#ifdef QT_NO_THREAD
    QHostInfo hostInfo = QHostInfoAgent::fromName(name);
    hostInfo.setLookupId(id);
    QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
    QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
                     receiver, member, Qt::QueuedConnection);
    result.data()->emitResultsReady(hostInfo);
#else
    QHostInfoRunnable* runnable = new QHostInfoRunnable(name, id);
    QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
    theHostInfoLookupManager()->scheduleLookup(runnable);
#endif

    return id;
}
Esempio n. 16
0
SIMResolver::SIMResolver(QObject *parent, const char *host)
        : QObject(parent)
{
    bDone = false;
    bTimeout = false;
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(resolveTimeout()));
    timer->start(20000);
    dns = new QDns(host, QDns::A);
    connect(dns, SIGNAL(resultsReady()), this, SLOT(resolveReady()));
}
Esempio n. 17
0
SrvResolver::SrvResolver(QObject *parent)
:QObject(parent)
{
	d = new Private;
	d->qdns = 0;

#ifndef NO_NDNS
	connect(&d->ndns, SIGNAL(resultsReady()), SLOT(ndns_done()));
#endif
	connect(&d->t, SIGNAL(timeout()), SLOT(t_timeout()));
	stop();
}
void CvsJob::slotProcessError( QProcess::ProcessError err)
{
    Q_UNUSED( err );
    // disconnect all connections to childproc's signals; they are no longer needed
    d->childproc->disconnect();

    d->isRunning = false;

    setError( d->childproc->exitCode() );
    setErrorText( i18n("Process exited with status %1", d->childproc->exitCode()) );
    emitResult(); //KJob
    emit resultsReady(this); //VcsJob
}
Esempio n. 19
0
void SrvResolver::resolve(const QString &server, const QString &type, const QString &proto, bool srvOnly)
{
	stop();

	d->failed = false;
	d->srvonly = srvOnly;
	d->srv = QString("_") + type + "._" + proto + '.' + server;
	d->t.start(15000, true);
	d->qdns = new Q3Dns;
	connect(d->qdns, SIGNAL(resultsReady()), SLOT(qdns_done()));
	d->qdns->setRecordType(Q3Dns::Srv);
	d->qdns->setLabel(d->srv);
}
Esempio n. 20
0
void DatabaseQuery::runQuery() {
    DatabaseQueryRequest *request = takeRequest();
    if (request) {
        QThread *thread = new QThread();
        connect(thread, SIGNAL(finished()), SLOT(threadFinished()));
        thread->start();
        request->moveToThread(thread);
        connect( request, SIGNAL(requestCompleted()), SLOT(finishQuery()) );
        connect( request, SIGNAL(resultsReady(DataStore)), SLOT(addResult(DataStore)) );
        connect( request, SIGNAL(errorMessageBox(QString,QString)), SIGNAL(errorMessageBox(QString,QString)) );
        QMetaObject::invokeMethod(request, "start", Qt::QueuedConnection);
    }
}
Esempio n. 21
0
void Q3Socket::connectToHost( const QString &host, Q_UINT16 port )
{
#if defined(Q3SOCKET_DEBUG)
    qDebug( "Q3Socket (%s)::connectToHost: host %s, port %d",
	    name(), host.ascii(), port );
#endif
    setSocketIntern( -1 );
    d->state = HostLookup;
    d->host = host;
    d->port = port;
    d->dns4 = new Q3Dns( host, Q3Dns::A );
    d->dns6 = new Q3Dns( host, Q3Dns::Aaaa );

    // try if the address is already available (for faster connecting...)
    tryConnecting();
    if ( d->state == HostLookup ) {
	connect( d->dns4, SIGNAL(resultsReady()),
		 this, SLOT(tryConnecting()) );
	connect( d->dns6, SIGNAL(resultsReady()),
		 this, SLOT(tryConnecting()) );
    }
}
Esempio n. 22
0
void EvaUdpUploader::doDnsRequest()
{
	m_HostAddresses.clear();
	if(m_Dns) delete m_Dns;
	m_Dns = new TQDns(SYN_SERVER_URL);
	TQObject::connect(m_Dns, SIGNAL(resultsReady()), SLOT(slotDnsReady()));
	
// 	while(!m_HostAddresses.size()){
// 		if(m_ExitNow) break;
// 		sleep(1);
// 	}
	m_State = ENone;
}
Esempio n. 23
0
void SrvResolver::tryNext()
{
#ifndef NO_NDNS
	d->ndns.resolve(d->servers.first().name);
#else
	d->qdns = new Q3Dns;
	connect(d->qdns, SIGNAL(resultsReady()), SLOT(ndns_done()));
	if(d->aaaa)
		d->qdns->setRecordType(Q3Dns::Aaaa); // IPv6
	else
		d->qdns->setRecordType(Q3Dns::A); // IPv4
	d->qdns->setLabel(d->servers.first().name);
#endif
}
Esempio n. 24
0
DNSHandler::DNSHandler(const QString &marker, const QHostAddress &address)
	: marker(marker)
{
	kdebugf();
//	kdebugm(KDEBUG_WARNING, ">>>>>>>>>>%s\n", qPrintable(marker));

	if (address == QHostAddress())
		kdebugmf(KDEBUG_WARNING, "NULL ip address!\n");

	QHostInfo::lookupHost(address.toString(), this, SLOT(resultsReady(QHostInfo)));
	++counter;

	kdebugmf(KDEBUG_FUNCTION_END, "counter = %d\n", counter);
}
Esempio n. 25
0
void EvaAgentUploader::doDnsRequest()
{
	printf("EvaAgentUploader::doDnsRequest\n");
	m_HostAddresses.clear();
	if(m_Dns) delete m_Dns;
	m_Dns = new TQDns(RELAY_SERVER_URL);
	TQObject::connect(m_Dns, SIGNAL(resultsReady()), SLOT(slotDnsReady()));
	
// 	while(!m_HostAddresses.size()){
// 		printf("EvaAgentUploader::doDnsRequest -- waiting for DNS results\n");
// 		if(m_ExitNow) break;
// 		msleep(200);
// 	}
	m_State = ENone;
}
Esempio n. 26
0
SrvResolver::SrvResolver(QObject *parent)
:QObject(parent)
{
	d = new Private(this);
	d->nndns_busy = false;

	connect(&d->nndns, SIGNAL(resultsReady(const QList<XMPP::NameRecord> &)), SLOT(nndns_resultsReady(const QList<XMPP::NameRecord> &)));
	connect(&d->nndns, SIGNAL(error(XMPP::NameResolver::Error)), SLOT(nndns_error(XMPP::NameResolver::Error)));

#ifndef NO_NDNS
	connect(&d->ndns, SIGNAL(resultsReady()), SLOT(ndns_done()));
#endif
	connect(&d->t, SIGNAL(timeout()), SLOT(t_timeout()));
	stop();
}
Esempio n. 27
0
void SrvResolver::qdns_done()
{
	if(!d->qdns)
		return;

	// apparently we sometimes get this signal even though the results aren't ready
	if(d->qdns->isWorking())
		return;
	d->t.stop();

	SafeDeleteLock s(&d->sd);

	// grab the server list and destroy the qdns object
	QList<Q3Dns::Server> list;
	if(d->qdns->recordType() == Q3Dns::Srv)
		list = d->qdns->servers();
	d->qdns->disconnect(this);
	d->sd.deleteLater(d->qdns);
	d->qdns = 0;

	if(list.isEmpty()) {
		stop();
		resultsReady();
		return;
	}
	sortSRVList(list);
	d->servers = list;

	if(d->srvonly)
		resultsReady();
	else {
		// kick it off
		d->aaaa = true;
		tryNext();
	}
}
Esempio n. 28
0
/*!
    Looks up the IP address(es) associated with host name \a name, and
    returns an ID for the lookup. When the result of the lookup is
    ready, the slot or signal \a member in \a receiver is called with
    a QHostInfo argument. The QHostInfo object can then be inspected
    to get the results of the lookup.

    The lookup is performed by a single function call, for example:

    \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 2

    The implementation of the slot prints basic information about the
    addresses returned by the lookup, or reports an error if it failed:

    \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 3

    If you pass a literal IP address to \a name instead of a host name,
    QHostInfo will search for the domain name for the IP (i.e., QHostInfo will
    perform a \e reverse lookup). On success, the resulting QHostInfo will
    contain both the resolved domain name and IP addresses for the host
    name. Example:

    \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 4

    \sa abortHostLookup(), addresses(), error(), fromName()
*/
int QHostInfo::lookupHost(const QString &name, QObject *receiver,
                          const char *member)
{
#if defined QHOSTINFO_DEBUG
    qDebug("QHostInfo::lookupHost(\"%s\", %p, %s)",
           name.toLatin1().constData(), receiver, member ? member + 1 : 0);
#endif
    if (!QAbstractEventDispatcher::instance(QThread::currentThread())) {
        qWarning("QHostInfo::lookupHost() called with no event dispatcher");
        return -1;
    }

    qRegisterMetaType<QHostInfo>("QHostInfo");

#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
    QWindowsSockInit bust; // makes sure WSAStartup was callled
#endif

    QScopedPointer<QHostInfoResult> result(new QHostInfoResult);
    result.data()->autoDelete = false;
    QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
                     receiver, member);
    int id = result.data()->lookupId = theIdCounter.fetchAndAddRelaxed(1);

    if (name.isEmpty()) {
        QHostInfo info(id);
        info.setError(QHostInfo::HostNotFound);
        info.setErrorString(QObject::tr("No host name given"));
        QMetaObject::invokeMethod(result.data(), "emitResultsReady", Qt::QueuedConnection,
                                  Q_ARG(QHostInfo, info));
        result.take()->autoDelete = true;
        return id;
    }

    QHostInfoAgent *agent = theAgent();
    agent->addHostName(name, result.take());

#if !defined QT_NO_THREAD
    if (!agent->isRunning())
        agent->start();
#else
//    if (!agent->isRunning())
	agent->run();
//    else
//	agent->wakeOne();
#endif
    return id;
}
void CvsJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus)
{
    // disconnect all connections to childproc's signals; they are no longer needed
    d->childproc->disconnect();

    d->isRunning = false;

    kDebug(9500) << "proc exited with code "<< exitCode;

    if (exitStatus != QProcess::NormalExit || exitCode != 0) {
        setError( exitCode );
        setErrorText( i18n("Process exited with status %1", exitCode) );
    }
    emitResult(); //KJob
    emit resultsReady(this); //VcsJob
}
Esempio n. 30
0
SIMResolver::SIMResolver(QObject *parent, const char *host)
        : QObject(parent)
{
    bDone = false;
    bTimeout = false;
#ifdef WIN32
    bool bState;
    if (get_connection_state(bState) && !bState){
        QTimer::singleShot(0, this, SLOT(resolveTimeout()));
        return;
    }
#endif
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(resolveTimeout()));
    timer->start(20000);
    dns = new QDns(host, QDns::A);
    connect(dns, SIGNAL(resultsReady()), this, SLOT(resolveReady()));
}