KIO
Go to the documentation of this file.
22 #include <config-kpac.h>
26 #ifdef HAVE_SYS_TYPES_H
27 #include <sys/types.h>
29 #ifdef HAVE_NETINET_IN_H
30 #include <netinet/in.h>
32 #include <arpa/nameser.h>
33 #ifdef HAVE_ARPA_NAMESER8_COMPAT_H
34 #include <arpa/nameser8_compat.h>
36 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
37 #include <arpa/nameser_compat.h>
40 #ifdef HAVE_SYS_PARAM_H
42 #include <sys/param.h>
46 #include <sys/utsname.h>
48 #include <QtCore/QTimer>
49 #include <QtNetwork/QHostInfo>
55 #include "discovery.moc"
63 connect( m_helper, SIGNAL(readyReadStandardOutput()), SLOT(helperOutput()) );
64 connect( m_helper, SIGNAL(finished(
int,QProcess::ExitStatus)), SLOT(
failed()) );
67 if ( !m_helper->waitForStarted() )
68 QTimer::singleShot( 0,
this, SLOT(
failed()) );
71 bool Discovery::initDomainName()
73 m_domainName = QHostInfo::localDomainName();
74 return !m_domainName.isEmpty();
77 bool Discovery::checkDomain()
const
85 unsigned char buf[ PACKETSZ ];
88 int len = res_query( m_domainName.toLocal8Bit(), C_IN, T_SOA,
89 response.buf,
sizeof( response.buf ) );
90 if ( len <=
int(
sizeof( response.header ) ) ||
91 ntohs( response.header.ancount ) != 1 )
94 unsigned char* pos = response.buf +
sizeof( response.header );
95 unsigned char*
end = response.buf + len;
98 pos += dn_skipname( pos, end ) + QFIXEDSZ;
103 pos += dn_skipname( pos, end );
105 GETSHORT( type, pos );
106 return type != T_SOA;
111 setError(
i18n(
"Could not find a usable proxy configuration script" ) );
116 const bool firstQuery = m_domainName.isEmpty();
117 if ( ( firstQuery && !initDomainName() ) ||
118 ( !firstQuery && !checkDomain() ) )
124 const int dot = m_domainName.indexOf(
'.' );
127 KUrl url( QLatin1String(
"http://wpad.") + m_domainName + QLatin1String(
"/wpad.dat") );
128 m_domainName.remove( 0, dot + 1 );
136 void Discovery::helperOutput()
138 m_helper->disconnect(
this );
139 const QByteArray line = m_helper->readLine();
140 const KUrl url( QString::fromLocal8Bit(line.constData(), line.length()).trimmed() );
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Feb 9 2013 12:13:31 by
doxygen 1.8.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.