Network-related functionality.  
 More...
#include <networkfactory.h>
|  | 
| static QString | networkErrorText (QNetworkReply::NetworkError error_code) | 
|  | Gets human readable text for given network error.  More... 
 | 
|  | 
| static QNetworkReply::NetworkError | downloadFile (const QString &url, int timeout, QByteArray &output, bool protected_contents=false, const QString &username=QString(), const QString &password=QString()) | 
|  | Performs SYNCHRONOUS download of file with given URL and given timeout.  More... 
 | 
|  | 
Network-related functionality. 
Definition at line 40 of file networkfactory.h.
  
  | 
        
          | QNetworkReply::NetworkError NetworkFactory::downloadFile | ( | const QString & | url, |  
          |  |  | int | timeout, |  
          |  |  | QByteArray & | output, |  
          |  |  | bool | protected_contents = false, |  
          |  |  | const QString & | username = QString(), |  
          |  |  | const QString & | password = QString() |  
          |  | ) |  |  |  | static | 
 
Performs SYNCHRONOUS download of file with given URL and given timeout. 
- Parameters
- 
  
    | url | Url. |  | timeout | Download timeout. |  | output | Output to store data to. |  | protected_contents | Is destination URL protected? |  | username | Username. |  | password | Password. |  
 
- Returns
- Returns indication of network status after the donwload finished. 
Definition at line 112 of file networkfactory.cpp.
  126   QNetworkRequest request;
 
  127   QNetworkReply *reply;
 
  128   QObject originatingObject;
 
  131   originatingObject.setProperty(
"protected", protected_contents);
 
  132   originatingObject.setProperty(
"username", username);
 
  133   originatingObject.setProperty(
"password", password);
 
  134   request.setOriginatingObject(&originatingObject);
 
  141   QObject::connect(qApp, SIGNAL(aboutToQuit()), &loop, SLOT(quit()));
 
  142   QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
 
  143   QObject::connect(&manager, SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()));
 
  147     timer.setSingleShot(
true);
 
  150     reply = manager.get(request);
 
  153     timer.start(timeout);
 
  162     if (timer.isActive()) {
 
  173       return QNetworkReply::TimeoutError;
 
  177     QUrl redirection_url = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
 
  179     if (redirection_url.isValid()) {
 
  182       request.setUrl(redirection_url);
 
  195   output = reply->readAll();
 
  197   QNetworkReply::NetworkError reply_error = reply->error();
 
  199   qDebug(
"File '%s' fetched with status '%s' (code %d).",
 
Network access manager with supressed authentication dialogs. 
static QString networkErrorText(QNetworkReply::NetworkError error_code)
Gets human readable text for given network error. 
 
 
 
  
  | 
        
          | QString NetworkFactory::networkErrorText | ( | QNetworkReply::NetworkError | error_code | ) |  |  | static | 
 
Gets human readable text for given network error. 
- Parameters
- 
  
  
- Returns
- Returns human readable text for given network error. 
Definition at line 48 of file networkfactory.cpp.
   50     case QNetworkReply::ProtocolUnknownError:
 
   51     case QNetworkReply::ProtocolFailure:
 
   53       return tr(
"protocol error");
 
   55     case QNetworkReply::HostNotFoundError:
 
   57       return tr(
"host not found");
 
   59     case QNetworkReply::RemoteHostClosedError:
 
   60     case QNetworkReply::ConnectionRefusedError:
 
   62       return tr(
"connection refused");
 
   64     case QNetworkReply::TimeoutError:
 
   65     case QNetworkReply::ProxyTimeoutError:
 
   67       return tr(
"connection timed out");
 
   69     case QNetworkReply::SslHandshakeFailedError:
 
   71       return tr(
"SSL handshake failed");
 
   73     case QNetworkReply::ProxyConnectionClosedError:
 
   74     case QNetworkReply::ProxyConnectionRefusedError:
 
   76       return tr(
"proxy server connection refused");
 
   78     case QNetworkReply::TemporaryNetworkFailureError:
 
   80       return tr(
"temporary failure");
 
   82     case QNetworkReply::AuthenticationRequiredError:
 
   84       return tr(
"authentication failed");
 
   86     case QNetworkReply::ProxyAuthenticationRequiredError:
 
   88       return tr(
"proxy authentication required");
 
   90     case QNetworkReply::ProxyNotFoundError:
 
   92       return tr(
"proxy server not found");
 
   94     case QNetworkReply::NoError:
 
   98     case QNetworkReply::UnknownContentError:
 
  100       return tr(
"uknown content");
 
  102     case QNetworkReply::ContentNotFoundError:
 
  104       return tr(
"content not found");
 
  108       return tr(
"unknown error");
 
 
 
 
The documentation for this class was generated from the following files: