Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QNetworkProxyFactory Class

TheQNetworkProxyFactory class provides fine-grained proxy selection.More...

Header:#include <QNetworkProxyFactory>
Since: Qt 4.5

Public Functions

QNetworkProxyFactory()
virtual~QNetworkProxyFactory()
virtual QList<QNetworkProxy>queryProxy(const QNetworkProxyQuery & query = QNetworkProxyQuery()) = 0

Static Public Members

QList<QNetworkProxy>proxyForQuery(const QNetworkProxyQuery & query)
voidsetApplicationProxyFactory(QNetworkProxyFactory * factory)
voidsetUseSystemConfiguration(bool enable)
QList<QNetworkProxy>systemProxyForQuery(const QNetworkProxyQuery & query = QNetworkProxyQuery())

Detailed Description

TheQNetworkProxyFactory class provides fine-grained proxy selection.

QNetworkProxyFactory is an extension toQNetworkProxy, allowing applications to have a more fine-grained control over which proxy servers are used, depending on the socket requesting the proxy. This allows an application to apply different settings, according to the protocol or destination hostname, for instance.

QNetworkProxyFactory can be set globally for an application, in which case it will override any global proxies set withQNetworkProxy::setApplicationProxy(). If set globally, any sockets created with Qt will query the factory to determine the proxy to be used.

A factory can also be set in certain frameworks that support multiple connections, such asQNetworkAccessManager. When set on such object, the factory will be queried for sockets created by that framework only.

System Proxies

You can configure a factory to use the system proxy's settings. Call thesetUseSystemConfiguration() function with true to enable this behavior, or false to disable it.

Similarly, you can use a factory to make queries directly to the system proxy by calling itssystemProxyForQuery() function.

Warning: Depending on the configuration of the user's system, the use of system proxy features on certain platforms may be subject to limitations. ThesystemProxyForQuery() documentation contains a list of these limitations for those platforms that are affected.

Member Function Documentation

QNetworkProxyFactory::QNetworkProxyFactory()

Creates aQNetworkProxyFactory object.

SinceQNetworkProxyFactory is an abstract class, you cannot create objects of typeQNetworkProxyFactory directly.

[virtual]QNetworkProxyFactory::~QNetworkProxyFactory()

Destroys theQNetworkProxyFactory object.

[static]QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(constQNetworkProxyQuery & query)

This function takes the query request,query, examines the details of the type of socket or request and returns a list ofQNetworkProxy objects that indicate the proxy servers to be used, in order of preference.

[pure virtual]QList<QNetworkProxy> QNetworkProxyFactory::queryProxy(constQNetworkProxyQuery & query = QNetworkProxyQuery())

This function takes the query request,query, examines the details of the type of socket or request and returns a list ofQNetworkProxy objects that indicate the proxy servers to be used, in order of preference.

When reimplementing this class, take care to return at least one element.

If you cannot determine a better proxy alternative, useQNetworkProxy::DefaultProxy, which tells the code querying for a proxy to use a higher alternative. For example, if this factory is set to aQNetworkAccessManager object, DefaultProxy will tell it to query the application-level proxy settings.

If this factory is set as the application proxy factory, DefaultProxy and NoProxy will have the same meaning.

[static]void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory * factory)

Sets the application-wide proxy factory to befactory. This function will take ownership of that object and will delete it when necessary.

The application-wide proxy is used as a last-resort when all other proxy selection requests returnedQNetworkProxy::DefaultProxy. For example,QTcpSocket objects can have a proxy set withQTcpSocket::setProxy, but if none is set, the proxy factory class set with this function will be queried.

If you set a proxy factory with this function, any application level proxies set withQNetworkProxy::setApplicationProxy will be overridden.

See alsoQNetworkProxy::setApplicationProxy(),QAbstractSocket::proxy(), andQAbstractSocket::setProxy().

[static]void QNetworkProxyFactory::setUseSystemConfiguration(bool enable)

Enables the use of the platform-specific proxy settings, and only those. SeesystemProxyForQuery() for more information.

Internally, this method (when called withenable set to true) sets an application-wide proxy factory. For this reason, this method is mutually exclusive withsetApplicationProxyFactory(): callingsetApplicationProxyFactory() overrides the use of the system-wide proxy, and calling setUseSystemConfiguration() overrides any application proxy or proxy factory that was previously set.

Note:See thesystemProxyForQuery() documentation for a list of limitations related to the use of system proxies.

This function was introduced in Qt 4.6.

[static]QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(constQNetworkProxyQuery & query = QNetworkProxyQuery())

This function takes the query request,query, examines the details of the type of socket or request and returns a list ofQNetworkProxy objects that indicate the proxy servers to be used, in order of preference.

This function can be used to determine the platform-specific proxy settings. This function will use the libraries provided by the operating system to determine the proxy for a given connection, if such libraries exist. If they don't, this function will just return aQNetworkProxy of typeQNetworkProxy::NoProxy.

On Windows, this function will use the WinHTTP DLL functions. Despite its name, Microsoft suggests using it for all applications that require network connections, not just HTTP. This will respect the proxy settings set on the registry with the proxycfg.exe tool. If those settings are not found, this function will attempt to obtain Internet Explorer's settings and use them.

On MacOS X, this function will obtain the proxy settings using the SystemConfiguration framework from Apple. It will apply the FTP, HTTP and HTTPS proxy configurations for queries that contain the protocol tag "ftp", "http" and "https", respectively. If the SOCKS proxy is enabled in that configuration, this function will use the SOCKS server for all queries. If SOCKS isn't enabled, it will use the HTTPS proxy for all TcpSocket and UrlRequest queries.

On BlackBerry, this function obtains proxy settings for the default configuration using system configuration. The type will be set based on protocol tag "http", "https", "ftp", respectively. By default, it assumes http type. Proxy username and password are also set during the query using system configuration.

On other systems, this function will pick up proxy settings from the "http_proxy" environment variable. This variable must be a URL using one of the following schemes: "http", "socks5" or "socks5h".

Limitations

These are the limitations for the current version of this function. Future versions of Qt may lift some of the limitations listed here.

  • On MacOS X, this function will ignore the Proxy Auto Configuration settings, since it cannot execute the associated ECMAScript code.
  • On Windows platforms, this function may take several seconds to execute depending on the configuration of the user's system.
  • On BlackBerry, only UrlRequest and TcpSocket queries are supported. SOCKS is not supported. The proxy credentials are only retrieved for the default configuration.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp