Qt 4.8
Public Functions | Public Variables | Private Functions | Properties | List of all members
Maemo::ProxyConfPrivate Class Reference

Public Functions

QList< QNetworkProxyflush (const QNetworkProxyQuery &query)
 
void readProxyData ()
 

Public Variables

QString http_prefix
 
QString prefix
 

Private Functions

bool isHostExcluded (const QString &host)
 

Properties

QString autoconfig_url
 
QString ftp_host
 
quint16 ftp_port
 
quint16 http_port
 
QString http_proxy
 
QList< QVariantignore_hosts
 
QString mode
 
QString rtsp_host
 
quint16 rtsp_port
 
QString secure_host
 
quint16 secure_port
 
QString socks_host
 
quint16 socks_port
 
bool use_http_host
 

Detailed Description

Definition at line 171 of file proxyconf.cpp.

Functions

◆ flush()

QList< QNetworkProxy > Maemo::ProxyConfPrivate::flush ( const QNetworkProxyQuery query)

Definition at line 285 of file proxyconf.cpp.

Referenced by Maemo::ProxyConf::flush().

286 {
287  QList<QNetworkProxy> result;
288 
289 #if 0
290  qDebug()<<"http_proxy" << http_proxy;
291  qDebug()<<"http_port" << http_port;
292  qDebug()<<"ignore_hosts" << ignore_hosts;
293  qDebug()<<"use_http_host" << use_http_host;
294  qDebug()<<"mode" << mode;
295  qDebug()<<"autoconfig_url" << autoconfig_url;
296  qDebug()<<"secure_host" << secure_host;
297  qDebug()<<"secure_port" << secure_port;
298  qDebug()<<"ftp_host" << ftp_host;
299  qDebug()<<"ftp_port" << ftp_port;
300  qDebug()<<"socks_host" << socks_host;
301  qDebug()<<"socks_port" << socks_port;
302  qDebug()<<"rtsp_host" << rtsp_host;
303  qDebug()<<"rtsp_port" << rtsp_port;
304 #endif
305 
306  if (isHostExcluded(query.peerHostName()))
307  return result; // no proxy for this host
308 
309  if (mode == QLatin1String("AUTO")) {
310  // TODO: pac currently not supported, fix me
311  return result;
312  }
313 
314  if (mode == QLatin1String("MANUAL")) {
315  bool isHttps = false;
316  QString protocol = query.protocolTag().toLower();
317 
318  // try the protocol-specific proxy
319  QNetworkProxy protocolSpecificProxy;
320 
321  if (protocol == QLatin1String("ftp")) {
322  if (!ftp_host.isEmpty()) {
323  protocolSpecificProxy.setType(QNetworkProxy::FtpCachingProxy);
324  protocolSpecificProxy.setHostName(ftp_host);
325  protocolSpecificProxy.setPort(ftp_port);
326  }
327  } else if (protocol == QLatin1String("http")) {
328  if (!http_proxy.isEmpty()) {
329  protocolSpecificProxy.setType(QNetworkProxy::HttpProxy);
330  protocolSpecificProxy.setHostName(http_proxy);
331  protocolSpecificProxy.setPort(http_port);
332  }
333  } else if (protocol == QLatin1String("https")) {
334  isHttps = true;
335  if (!secure_host.isEmpty()) {
336  protocolSpecificProxy.setType(QNetworkProxy::HttpProxy);
337  protocolSpecificProxy.setHostName(secure_host);
338  protocolSpecificProxy.setPort(secure_port);
339  }
340  }
341 
342  if (protocolSpecificProxy.type() != QNetworkProxy::DefaultProxy)
343  result << protocolSpecificProxy;
344 
345 
346  if (!socks_host.isEmpty()) {
347  QNetworkProxy proxy;
349  proxy.setHostName(socks_host);
350  proxy.setPort(socks_port);
351  result << proxy;
352  }
353 
354 
355  // Add the HTTPS proxy if present (and if we haven't added yet)
356  if (!isHttps) {
357  QNetworkProxy https;
358  if (!secure_host.isEmpty()) {
360  https.setHostName(secure_host);
361  https.setPort(secure_port);
362  }
363 
364  if (https.type() != QNetworkProxy::DefaultProxy &&
365  https != protocolSpecificProxy)
366  result << https;
367  }
368  }
369 
370  return result;
371 }
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
QString peerHostName() const
Returns the host name or IP address being of the outgoing connection being requested, or an empty string if the remote hostname is not known.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT void qDebug(const char *,...)
The QNetworkProxy class provides a network layer proxy.
QString protocolTag() const
Returns the protocol tag for this QNetworkProxyQuery object, or an empty QString in case the protocol...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setHostName(const QString &hostName)
Sets the host name of the proxy host to be hostName.
QList< QVariant > ignore_hosts
Definition: proxyconf.cpp:179
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
void setType(QNetworkProxy::ProxyType type)
Sets the proxy type for this instance to be type.
bool isHostExcluded(const QString &host)
Definition: proxyconf.cpp:257
void setPort(quint16 port)
Sets the port of the proxy host to be port.

◆ isHostExcluded()

bool Maemo::ProxyConfPrivate::isHostExcluded ( const QString host)
private

Definition at line 257 of file proxyconf.cpp.

258 {
259  if (host.isEmpty())
260  return true;
261 
262  if (ignore_hosts.isEmpty())
263  return false;
264 
265  QHostAddress ipAddress;
266  bool isIpAddress = ipAddress.setAddress(host);
267 
268  foreach (QVariant h, ignore_hosts) {
269  QString entry = h.toString();
270  if (isIpAddress && ipAddress.isInSubnet(QHostAddress::parseSubnet(entry))) {
271  return true; // excluded
272  } else {
273  // do wildcard matching
275  if (rx.exactMatch(host))
276  return true;
277  }
278  }
279 
280  // host was not excluded
281  return false;
282 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QPair< QHostAddress, int > parseSubnet(const QString &subnet)
Parses the IP and subnet information contained in subnet and returns the network prefix for that netw...
bool isInSubnet(const QHostAddress &subnet, int netmask) const
Returns true if this IP is in the subnet described by the network prefix subnet and netmask netmask...
QList< QVariant > ignore_hosts
Definition: proxyconf.cpp:179
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
The QHostAddress class provides an IP address.
Definition: qhostaddress.h:70

◆ readProxyData()

void Maemo::ProxyConfPrivate::readProxyData ( )

Definition at line 227 of file proxyconf.cpp.

Referenced by Maemo::ProxyConf::readProxyData().

228 {
231 
232  //qDebug()<<"values="<<values;
233 
234  /* Read the proxy settings from /system/proxy* */
235  GET_HTTP(http_proxy, host, String);
236  GET_HTTP(http_port, port, Int);
238 
239  GET(mode, String);
242  GET(secure_port, Int);
243  GET(ftp_host, String);
244  GET(ftp_port, Int);
246  GET(socks_port, Int);
247  GET(rtsp_host, String);
248  GET(rtsp_port, Int);
249 
250  if (http_proxy.isEmpty())
251  use_http_host = false;
252  else
253  use_http_host = true;
254 }
#define GET(var, type)
Definition: proxyconf.cpp:212
static QHash< QString, QVariant > getHttpValues(const QString &prefix)
Definition: proxyconf.cpp:206
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
quint16 values[128]
#define GET_HTTP(var, name, type)
Definition: proxyconf.cpp:219
QList< QVariant > ignore_hosts
Definition: proxyconf.cpp:179
static QHash< QString, QVariant > getValues(const QString &prefix)
Definition: proxyconf.cpp:200

Properties

◆ autoconfig_url

QString Maemo::ProxyConfPrivate::autoconfig_url
private

Definition at line 176 of file proxyconf.cpp.

◆ ftp_host

QString Maemo::ProxyConfPrivate::ftp_host
private

Definition at line 182 of file proxyconf.cpp.

◆ ftp_port

quint16 Maemo::ProxyConfPrivate::ftp_port
private

Definition at line 183 of file proxyconf.cpp.

◆ http_port

quint16 Maemo::ProxyConfPrivate::http_port
private

Definition at line 178 of file proxyconf.cpp.

◆ http_prefix

QString Maemo::ProxyConfPrivate::http_prefix

Definition at line 193 of file proxyconf.cpp.

Referenced by Maemo::ProxyConf::ProxyConf().

◆ http_proxy

QString Maemo::ProxyConfPrivate::http_proxy
private

Definition at line 177 of file proxyconf.cpp.

◆ ignore_hosts

QList<QVariant> Maemo::ProxyConfPrivate::ignore_hosts
private

Definition at line 179 of file proxyconf.cpp.

◆ mode

QString Maemo::ProxyConfPrivate::mode
private

Definition at line 174 of file proxyconf.cpp.

◆ prefix

QString Maemo::ProxyConfPrivate::prefix

Definition at line 192 of file proxyconf.cpp.

Referenced by Maemo::ProxyConf::ProxyConf().

◆ rtsp_host

QString Maemo::ProxyConfPrivate::rtsp_host
private

Definition at line 186 of file proxyconf.cpp.

◆ rtsp_port

quint16 Maemo::ProxyConfPrivate::rtsp_port
private

Definition at line 187 of file proxyconf.cpp.

◆ secure_host

QString Maemo::ProxyConfPrivate::secure_host
private

Definition at line 180 of file proxyconf.cpp.

◆ secure_port

quint16 Maemo::ProxyConfPrivate::secure_port
private

Definition at line 181 of file proxyconf.cpp.

◆ socks_host

QString Maemo::ProxyConfPrivate::socks_host
private

Definition at line 184 of file proxyconf.cpp.

◆ socks_port

quint16 Maemo::ProxyConfPrivate::socks_port
private

Definition at line 185 of file proxyconf.cpp.

◆ use_http_host

bool Maemo::ProxyConfPrivate::use_http_host
private

Definition at line 175 of file proxyconf.cpp.


The documentation for this class was generated from the following file: