44 #include <QStringList> 46 #include <QWriteLocker> 47 #include <QNetworkProxyFactory> 48 #include <QNetworkProxy> 49 #include <gconf/gconf-value.h> 50 #include <gconf/gconf-client.h> 53 #define CONF_PROXY "/system/proxy" 54 #define HTTP_PROXY "/system/http_proxy" 70 case GCONF_VALUE_INVALID:
72 case GCONF_VALUE_BOOL:
73 return QVariant((
bool)gconf_value_get_bool(src));
75 return QVariant(gconf_value_get_int(src));
76 case GCONF_VALUE_FLOAT:
77 return QVariant(gconf_value_get_float(src));
78 case GCONF_VALUE_STRING:
80 case GCONF_VALUE_LIST:
81 switch (gconf_value_get_list_type(src)) {
82 case GCONF_VALUE_STRING:
85 for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
92 for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
97 case GCONF_VALUE_SCHEMA:
115 #define withClient(c) for (GConfClient *c = gconf_client_get_default(); c; c=0) 124 GSList *
entries = gconf_client_all_entries(client, k.
data(), NULL);
125 for (GSList *e = entries; e; e = e->next) {
126 char *key_name = strrchr(((GConfEntry *)e->data)->key,
'/');
128 key_name = ((GConfEntry *)e->data)->key;
133 gconf_entry_unref((GConfEntry *)e->data);
135 children.
insert(key, value);
137 g_slist_free (entries);
158 if (proxy_data_read ==
false) {
159 proxy_data_read =
true;
160 proxy_conf.readProxyData();
195 void readProxyData();
212 #define GET(var, type) \ 214 QVariant v = values.value(#var); \ 216 var = v.to##type (); \ 219 #define GET_HTTP(var, name, type) \ 221 QVariant v = httpValues.value(#name); \ 223 var = v.to##type (); \ 237 GET_HTTP(ignore_hosts, ignore_hosts, List);
242 GET(secure_port, Int);
246 GET(socks_port, Int);
250 if (http_proxy.isEmpty())
251 use_http_host =
false;
253 use_http_host =
true;
262 if (ignore_hosts.isEmpty())
266 bool isIpAddress = ipAddress.
setAddress(host);
268 foreach (
QVariant h, ignore_hosts) {
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;
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;
315 bool isHttps =
false;
322 if (!ftp_host.isEmpty()) {
325 protocolSpecificProxy.
setPort(ftp_port);
328 if (!http_proxy.isEmpty()) {
331 protocolSpecificProxy.
setPort(http_port);
335 if (!secure_host.isEmpty()) {
338 protocolSpecificProxy.
setPort(secure_port);
343 result << protocolSpecificProxy;
346 if (!socks_host.isEmpty()) {
358 if (!secure_host.isEmpty()) {
365 https != protocolSpecificProxy)
The QVariant class acts like a union for the most common Qt data types.
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
char * data()
Returns a pointer to the data stored in the byte array.
The QRegExp class provides pattern matching using regular expressions.
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.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
The QByteArray class provides an array of bytes.
static QHash< QString, QVariant > getHttpValues(const QString &prefix)
QList< QNetworkProxy > flush(const QNetworkProxyQuery &query=QNetworkProxyQuery())
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
QHash< QString, QVariant > getEntries() const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QList< QNetworkProxy > flush(const QNetworkProxyQuery &query)
QList< QNetworkProxy > queryProxy(const QNetworkProxyQuery &query=QNetworkProxyQuery())
This function takes the query request, query, examines the details of the type of socket or request a...
The QString class provides a Unicode character string.
The QNetworkProxyFactory class provides fine-grained proxy selection.
static QVariant convertValue(GConfValue *src)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Q_CORE_EXPORT void qDebug(const char *,...)
The QNetworkProxy class provides a network layer proxy.
void append(const T &t)
Inserts value at the end of the list.
QString protocolTag() const
Returns the protocol tag for this QNetworkProxyQuery object, or an empty QString in case the protocol...
static QString convertKey(const char *key)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static void setApplicationProxyFactory(QNetworkProxyFactory *factory)
Sets the application-wide proxy factory to be factory.
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...
The QStringList class provides a list of strings.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
void setHostName(const QString &hostName)
Sets the host name of the proxy host to be hostName.
GConfItemFast(const QString &k)
static bool isHostExcluded(CFDictionaryRef dict, const QString &host)
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...
The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks ...
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
#define GET_HTTP(var, name, type)
static const MacSpecialKey entries[NumEntries]
QList< QVariant > ignore_hosts
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
The QReadWriteLock class provides read-write locking.
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
static QReadWriteLock lock
void setType(QNetworkProxy::ProxyType type)
Sets the proxy type for this instance to be type.
bool exactMatch(const QString &str) const
Returns true if str is matched exactly by this regular expression; otherwise returns false...
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
static QHash< QString, QVariant > getValues(const QString &prefix)
The QHostAddress class provides an IP address.
bool isHostExcluded(const QString &host)
void setPort(quint16 port)
Sets the port of the proxy host to be port.