BuildmLearn Toolkit  2.0.4
BuildmLearn Toolkit is an easy-to-use program that helps users make mobile apps without any knowledge of application development.
 All Classes Functions Enumerations Groups Pages
BaseNetworkAccessManager Class Reference

Base class for all network access managers. More...

#include <basenetworkaccessmanager.h>

Collaboration diagram for BaseNetworkAccessManager:
Collaboration graph

Public Slots

virtual void loadSettings ()
 Loads network settings for this instance. More...
 

Public Member Functions

 BaseNetworkAccessManager (QObject *parent=0)
 Constructor.
 

Protected Slots

void onSslErrors (QNetworkReply *reply, const QList< QSslError > &error)
 Catches and processes SSL errors. More...
 

Protected Member Functions

QNetworkReply * createRequest (Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
 Creates custom request. More...
 

Detailed Description

Base class for all network access managers.

Definition at line 39 of file basenetworkaccessmanager.h.

Member Function Documentation

QNetworkReply * BaseNetworkAccessManager::createRequest ( Operation  op,
const QNetworkRequest &  request,
QIODevice *  outgoingData 
)
protected

Creates custom request.

Parameters
opRequested operation.
requestThe request object itself.
outgoingDataBuffer for writting output data.
Returns
Returns newly created reply for given request.

Definition at line 97 of file basenetworkaccessmanager.cpp.

99  {
100  QNetworkRequest new_request = request;
101 
102  // This rapidly speeds up loading of web sites.
103  // NOTE: https://en.wikipedia.org/wiki/HTTP_pipelining
104  new_request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute,
105  true);
106 
107  // Setup custom user-agent.
108  new_request.setRawHeader(USER_AGENT_HTTP_HEADER,
109  QString(APP_USERAGENT).toLocal8Bit());
110 
111  return QNetworkAccessManager::createRequest(op, new_request, outgoingData);
112 }
void BaseNetworkAccessManager::loadSettings ( )
virtualslot

Loads network settings for this instance.

Remarks
This sets up proxy settings.

Definition at line 54 of file basenetworkaccessmanager.cpp.

54  {
55  QNetworkProxy new_proxy;
56  QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(qApp->settings()->value(APP_CFG_PROXY,
57  "proxy_type",
58  QNetworkProxy::NoProxy).toInt());
59 
60  if (selected_proxy_type == QNetworkProxy::NoProxy) {
61  // No extra setting is needed, set new proxy and exit this method.
62  setProxy(QNetworkProxy::NoProxy);
63  return;
64  }
65  else if (selected_proxy_type == QNetworkProxy::DefaultProxy) {
66  setProxy(QNetworkProxy::applicationProxy());
67  return;
68  }
69 
70  Settings *settings = qApp->settings();
71 
72  // Custom proxy is selected, set it up.
73  new_proxy.setType(selected_proxy_type);
74  new_proxy.setHostName(settings->value(APP_CFG_PROXY,
75  "host").toString());
76  new_proxy.setPort(settings->value(APP_CFG_PROXY,
77  "port", 80).toInt());
78  new_proxy.setUser(settings->value(APP_CFG_PROXY,
79  "username").toString());
80  new_proxy.setPassword(settings->value(APP_CFG_PROXY,
81  "password").toString());
82  setProxy(new_proxy);
83 
84  qDebug("Settings of BaseNetworkAccessManager loaded.");
85 }
Application-wide settings mechanism.
Definition: settings.h:40
QVariant value(const QString &section, const QString &key, const QVariant &default_value=QVariant())
Getter/setter for settings values.
Definition: settings.h:64

Here is the call graph for this function:

Here is the caller graph for this function:

void BaseNetworkAccessManager::onSslErrors ( QNetworkReply *  reply,
const QList< QSslError > &  error 
)
protectedslot

Catches and processes SSL errors.

Parameters
replyNetwork reply for which error came up.
errorError description.

Definition at line 87 of file basenetworkaccessmanager.cpp.

88  {
89  qDebug("SSL errors for '%s': '%s' (code %d).",
90  qPrintable(reply->url().toString()),
91  qPrintable(reply->errorString()),
92  (int) reply->error());
93 
94  reply->ignoreSslErrors(error);
95 }

Here is the caller graph for this function:


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