Lomiri Download Manager  0.1.2
A session-wide downloading service
error.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-2015 Canonical Ltd.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public
6  * License as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301, USA.
17  */
18 
19 #pragma once
20 
21 #include <QObject>
22 #include <QProcess>
23 
24 class QDBusError;
25 
26 namespace Lomiri {
27 
28 namespace Transfers {
29 
30 namespace Errors {
31  class AuthErrorStruct;
32  class HttpErrorStruct;
33  class NetworkErrorStruct;
34  class ProcessErrorStruct;
35  class HashErrorStruct;
36 }
37 
38 }
39 
40 namespace DownloadManager {
41 
42 class ErrorPrivate;
43 
55 class Error : public QObject {
56  Q_OBJECT
57  Q_DECLARE_PRIVATE(Error)
58 
59  public:
60 
64  enum Type {
65  Auth,
66  DBus,
67  Http,
71  };
72 
76  virtual ~Error();
77 
83  Type type();
84 
90  virtual QString errorString();
91 
92  protected:
97  Error(Type type, QObject* parent = 0);
98 
99  private:
104  ErrorPrivate* d_ptr;
105 
106 };
107 
108 
109 class DBusErrorPrivate;
110 
117 class DBusError : public Error {
118  Q_OBJECT
119  Q_DECLARE_PRIVATE(DBusError)
120 
121  friend class ManagerImpl;
122  friend class DownloadImpl;
123  friend class DownloadManagerPCW;
124  friend class DownloadsListManagerPCW;
125  friend class MetadataDownloadsListManagerPCW;
126  friend class DownloadPCW;
127  friend class GroupManagerPCW;
128 
132  virtual ~DBusError();
133 
139  QString message();
140 
146  QString name();
147 
153  QString errorString() override;
154 
155  protected:
156 
162  DBusError(QDBusError err, QObject* parent = 0);
163 
164  private:
169  DBusErrorPrivate* d_ptr;
170 };
171 
172 class AuthErrorPrivate;
173 
185 class AuthError : public Error {
186  Q_OBJECT
187  Q_DECLARE_PRIVATE(AuthError)
188 
189  friend class DownloadImpl;
190 
191  public:
192 
196  enum Type {
199  };
200 
204  virtual ~AuthError();
205 
211  Type type();
212 
219  QString phrase();
220 
226  QString errorString() override;
227 
228  protected:
233  AuthError(Transfers::Errors::AuthErrorStruct err, QObject* parent);
234 
235  private:
240  AuthErrorPrivate* d_ptr;
241 };
242 
243 class HttpErrorPrivate;
244 
254 class HttpError : public Error {
255  Q_OBJECT
256  Q_DECLARE_PRIVATE(HttpError)
257 
258  friend class DownloadImpl;
259 
260  public:
261 
265  virtual ~HttpError();
266 
272  int code();
273 
279  QString phrase();
280 
286  QString errorString() override;
287 
288  protected:
293  HttpError(Transfers::Errors::HttpErrorStruct err, QObject* parent);
294 
295  private:
300  HttpErrorPrivate* d_ptr;
301 };
302 
303 class NetworkErrorPrivate;
304 
311 class NetworkError : public Error {
312  Q_OBJECT
313  Q_DECLARE_PRIVATE(NetworkError)
314 
315  friend class DownloadImpl;
316 
317  public:
318 
323  enum ErrorCode {
349  };
350 
354  virtual ~NetworkError();
355 
361  ErrorCode code();
362 
368  QString phrase();
369 
375  QString errorString() override;
376 
377  protected:
378 
383  NetworkError(Transfers::Errors::NetworkErrorStruct err, QObject* parent);
384 
385  private:
390  NetworkErrorPrivate* d_ptr;
391 };
392 
393 class ProcessErrorPrivate;
394 
401 class ProcessError : public Error {
402  Q_OBJECT
403  Q_DECLARE_PRIVATE(ProcessError)
404 
405  friend class DownloadImpl;
406 
407  public:
408 
412  virtual ~ProcessError();
413 
419  QProcess::ProcessError code();
420 
426  QString phrase();
427 
433  int exitCode();
434 
440  QString standardOut();
441 
447  QString standardError();
448 
454  QString errorString() override;
455 
456  protected:
457 
462  ProcessError(Transfers::Errors::ProcessErrorStruct err, QObject* parent);
463 
464  private:
469  ProcessErrorPrivate* d_ptr;
470 };
471 
472 class HashErrorPrivate;
473 
480 class HashError : public Error {
481  Q_OBJECT
482  Q_DECLARE_PRIVATE(HashError)
483 
484  friend class DownloadImpl;
485 
486  public:
487 
491  virtual ~HashError();
492 
498  QString method();
499 
506  QString expected();
507 
513  QString checksum();
514 
520  QString errorString() override;
521 
522  protected:
523 
528  HashError(Transfers::Errors::HashErrorStruct err, QObject* parent);
529 
530  private:
535  HashErrorPrivate* d_ptr;
536 };
537 
538 } // DownloadManager
539 
540 } // Lomiri
Lomiri::DownloadManager::HashError
The HashError represents an error that occurred during the hash validation after the download.
Definition: error.h:480
Lomiri::DownloadManager::HashError::errorString
QString errorString() override
Definition: error.cpp:477
QObject
Lomiri::DownloadManager::NetworkError::UnknownContentError
@ UnknownContentError
Definition: error.h:347
Lomiri::DownloadManager::AuthError::Type
Type
Definition: error.h:196
Lomiri::DownloadManager::NetworkError::ConnectionRefusedError
@ ConnectionRefusedError
Definition: error.h:324
Lomiri::DownloadManager::ProcessError::standardError
QString standardError()
Definition: error.cpp:438
Lomiri::DownloadManager::ProcessError::errorString
QString errorString() override
Definition: error.cpp:444
Lomiri::DownloadManager::NetworkError::phrase
QString phrase()
Definition: error.cpp:392
Lomiri::DownloadManager::HttpError::code
int code()
Definition: error.cpp:358
Lomiri::DownloadManager::HttpError::HttpError
HttpError(Transfers::Errors::HttpErrorStruct err, QObject *parent)
Definition: error.cpp:348
Lomiri::DownloadManager::Error::Type
Type
Definition: error.h:64
Lomiri::DownloadManager::DBusError::DBusError
DBusError(QDBusError err, QObject *parent=0)
Definition: error.cpp:294
Lomiri::DownloadManager::HashError::checksum
QString checksum()
Definition: error.cpp:471
Lomiri::DownloadManager::AuthError::type
Type type()
Definition: error.cpp:331
Lomiri::DownloadManager::Error::DBus
@ DBus
Definition: error.h:66
Lomiri::DownloadManager::NetworkError::ProtocolFailure
@ ProtocolFailure
Definition: error.h:348
Lomiri::DownloadManager::ProcessError::ProcessError
ProcessError(Transfers::Errors::ProcessErrorStruct err, QObject *parent)
Definition: error.cpp:403
Lomiri::DownloadManager::ProcessError::~ProcessError
virtual ~ProcessError()
Definition: error.cpp:409
Lomiri::DownloadManager::NetworkError::code
ErrorCode code()
Definition: error.cpp:386
Lomiri::DownloadManager::NetworkError::ProxyAuthenticationRequiredError
@ ProxyAuthenticationRequiredError
Definition: error.h:337
Lomiri::DownloadManager::AuthError::errorString
QString errorString() override
Definition: error.cpp:343
Lomiri::DownloadManager::NetworkError
The NetworkError represents an error that occurred during the download request.
Definition: error.h:311
Lomiri::DownloadManager::HashError::method
QString method()
Definition: error.cpp:459
Lomiri::DownloadManager::NetworkError::ProxyConnectionClosedError
@ ProxyConnectionClosedError
Definition: error.h:334
Lomiri::DownloadManager::AuthError::AuthError
AuthError(Transfers::Errors::AuthErrorStruct err, QObject *parent)
Definition: error.cpp:321
Lomiri
Definition: download.h:26
Lomiri::DownloadManager::ProcessError::exitCode
int exitCode()
Definition: error.cpp:426
Lomiri::DownloadManager::NetworkError::RemoteHostClosedError
@ RemoteHostClosedError
Definition: error.h:325
Lomiri::DownloadManager::NetworkError::BackgroundRequestNotAllowedError
@ BackgroundRequestNotAllowedError
Definition: error.h:332
Lomiri::DownloadManager::NetworkError::TemporaryNetworkFailureError
@ TemporaryNetworkFailureError
Definition: error.h:330
Lomiri::DownloadManager::Error
The Error class is the base class that represents an error in the download manager API.
Definition: error.h:55
Lomiri::DownloadManager::NetworkError::NetworkError
NetworkError(Transfers::Errors::NetworkErrorStruct err, QObject *parent)
Definition: error.cpp:375
Lomiri::DownloadManager::HashError::HashError
HashError(Transfers::Errors::HashErrorStruct err, QObject *parent)
Definition: error.cpp:449
Lomiri::DownloadManager::HttpError::~HttpError
virtual ~HttpError()
Definition: error.cpp:353
Lomiri::DownloadManager::NetworkError::AuthenticationRequiredError
@ AuthenticationRequiredError
Definition: error.h:341
Lomiri::DownloadManager::NetworkError::ContentAccessDenied
@ ContentAccessDenied
Definition: error.h:338
Lomiri::DownloadManager::DBusError
Definition: error.h:117
Lomiri::DownloadManager::AuthError::Server
@ Server
Definition: error.h:197
Lomiri::DownloadManager::NetworkError::NetworkSessionFailedError
@ NetworkSessionFailedError
Definition: error.h:331
Lomiri::DownloadManager::AuthError::~AuthError
virtual ~AuthError()
Definition: error.cpp:326
Lomiri::DownloadManager::NetworkError::HostNotFoundError
@ HostNotFoundError
Definition: error.h:326
Lomiri::DownloadManager::NetworkError::UnknownProxyError
@ UnknownProxyError
Definition: error.h:346
Lomiri::DownloadManager::HttpError
The HttpError represents an error that occurred during the download request.
Definition: error.h:254
Lomiri::DownloadManager::AuthError
The AuthError represents an authentication error that occurred during the request of the download.
Definition: error.h:185
Lomiri::DownloadManager::Error::Http
@ Http
Definition: error.h:67
Lomiri::DownloadManager::Error::Hash
@ Hash
Definition: error.h:70
Lomiri::DownloadManager::NetworkError::ContentReSendError
@ ContentReSendError
Definition: error.h:342
Lomiri::DownloadManager::NetworkError::ProxyConnectionRefusedError
@ ProxyConnectionRefusedError
Definition: error.h:333
Lomiri::DownloadManager::Error::~Error
virtual ~Error()
Definition: error.cpp:278
Lomiri::DownloadManager::NetworkError::ErrorCode
ErrorCode
Definition: error.h:323
Lomiri::DownloadManager::Error::Process
@ Process
Definition: error.h:69
Lomiri::DownloadManager::HttpError::phrase
QString phrase()
Definition: error.cpp:364
Lomiri::DownloadManager::ProcessError::standardOut
QString standardOut()
Definition: error.cpp:432
Lomiri::DownloadManager::NetworkError::ProtocolUnknownError
@ ProtocolUnknownError
Definition: error.h:343
Lomiri::DownloadManager::ProcessError
The ProcessError represents an error that occurred during the post processing of a downloaded file.
Definition: error.h:401
Lomiri::DownloadManager::ProcessError::code
QProcess::ProcessError code()
Definition: error.cpp:420
Lomiri::DownloadManager::NetworkError::ContentOperationNotPermittedError
@ ContentOperationNotPermittedError
Definition: error.h:339
Lomiri::DownloadManager::HashError::expected
QString expected()
Definition: error.cpp:465
Lomiri::DownloadManager::Error::Network
@ Network
Definition: error.h:68
Lomiri::DownloadManager::NetworkError::errorString
QString errorString() override
Definition: error.cpp:398
Lomiri::DownloadManager::Error::errorString
virtual QString errorString()
Definition: error.cpp:289
Lomiri::DownloadManager::ProcessError::phrase
QString phrase()
Definition: error.cpp:414
Lomiri::DownloadManager::NetworkError::TimeoutError
@ TimeoutError
Definition: error.h:327
Lomiri::DownloadManager::NetworkError::SslHandshakeFailedError
@ SslHandshakeFailedError
Definition: error.h:329
Lomiri::DownloadManager::AuthError::phrase
QString phrase()
Definition: error.cpp:337
Lomiri::DownloadManager::NetworkError::ProxyTimeoutError
@ ProxyTimeoutError
Definition: error.h:336
Lomiri::DownloadManager::NetworkError::UnknownNetworkError
@ UnknownNetworkError
Definition: error.h:345
Lomiri::DownloadManager::NetworkError::~NetworkError
virtual ~NetworkError()
Definition: error.cpp:381
Lomiri::DownloadManager::Error::Auth
@ Auth
Definition: error.h:65
Lomiri::DownloadManager::AuthError::Proxy
@ Proxy
Definition: error.h:198
Lomiri::DownloadManager::NetworkError::ContentNotFoundError
@ ContentNotFoundError
Definition: error.h:340
Lomiri::DownloadManager::NetworkError::OperationCanceledError
@ OperationCanceledError
Definition: error.h:328
Lomiri::DownloadManager::Error::type
Type type()
Definition: error.cpp:283
Lomiri::DownloadManager::HttpError::errorString
QString errorString() override
Definition: error.cpp:370
Lomiri::DownloadManager::NetworkError::ProxyNotFoundError
@ ProxyNotFoundError
Definition: error.h:335
Lomiri::DownloadManager::Error::Error
Error(Type type, QObject *parent=0)
Definition: error.cpp:273
Lomiri::DownloadManager::HashError::~HashError
virtual ~HashError()
Definition: error.cpp:454
Lomiri::DownloadManager::NetworkError::ProtocolInvalidOperationError
@ ProtocolInvalidOperationError
Definition: error.h:344