Ubuntu Download Manager  0.6.0
A session-wide downloading service
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator
error.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-2014 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 #ifndef UBUNTU_DOWNLOADMANAGER_CLIENT_ERROR_H
20 #define UBUNTU_DOWNLOADMANAGER_CLIENT_ERROR_H
21 
22 #include <QObject>
23 #include <QProcess>
24 
25 class QDBusError;
26 
27 namespace Ubuntu {
28 
29 namespace Transfers {
30 
31 namespace Errors {
32  class AuthErrorStruct;
33  class HttpErrorStruct;
34  class NetworkErrorStruct;
35  class ProcessErrorStruct;
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,
70  };
71 
75  virtual ~Error();
76 
82  Type type();
83 
89  virtual QString errorString();
90 
91  protected:
96  Error(Type type, QObject* parent = 0);
97 
98  private:
103  ErrorPrivate* d_ptr;
104 
105 };
106 
107 
108 class DBusErrorPrivate;
109 
116 class DBusError : public Error {
117  Q_OBJECT
118  Q_DECLARE_PRIVATE(DBusError)
119 
120  friend class ManagerImpl;
121  friend class DownloadImpl;
122  friend class DownloadManagerPCW;
123  friend class DownloadsListManagerPCW;
124  friend class MetadataDownloadsListManagerPCW;
125  friend class DownloadPCW;
126  friend class GroupManagerPCW;
127 
131  virtual ~DBusError();
132 
138  QString message();
139 
145  QString name();
146 
152  QString errorString() override;
153 
154  protected:
155 
161  DBusError(QDBusError err, QObject* parent = 0);
162 
163  private:
168  DBusErrorPrivate* d_ptr;
169 };
170 
171 class AuthErrorPrivate;
172 
184 class AuthError : public Error {
185  Q_OBJECT
186  Q_DECLARE_PRIVATE(AuthError)
187 
188  friend class DownloadImpl;
189 
190  public:
191 
195  enum Type {
198  };
199 
203  virtual ~AuthError();
204 
210  Type type();
211 
218  QString phrase();
219 
225  QString errorString() override;
226 
227  protected:
232  AuthError(Transfers::Errors::AuthErrorStruct err, QObject* parent);
233 
234  private:
239  AuthErrorPrivate* d_ptr;
240 };
241 
242 class HttpErrorPrivate;
243 
253 class HttpError : public Error {
254  Q_OBJECT
255  Q_DECLARE_PRIVATE(HttpError)
256 
257  friend class DownloadImpl;
258 
259  public:
260 
264  virtual ~HttpError();
265 
271  int code();
272 
278  QString phrase();
279 
285  QString errorString() override;
286 
287  protected:
292  HttpError(Transfers::Errors::HttpErrorStruct err, QObject* parent);
293 
294  private:
299  HttpErrorPrivate* d_ptr;
300 };
301 
302 class NetworkErrorPrivate;
303 
310 class NetworkError : public Error {
311  Q_OBJECT
312  Q_DECLARE_PRIVATE(NetworkError)
313 
314  friend class DownloadImpl;
315 
316  public:
317 
322  enum ErrorCode {
348  };
349 
353  virtual ~NetworkError();
354 
360  ErrorCode code();
361 
367  QString phrase();
368 
374  QString errorString() override;
375 
376  protected:
377 
382  NetworkError(Transfers::Errors::NetworkErrorStruct err, QObject* parent);
383 
384  private:
389  NetworkErrorPrivate* d_ptr;
390 };
391 
392 class ProcessErrorPrivate;
393 
400 class ProcessError : public Error {
401  Q_OBJECT
402  Q_DECLARE_PRIVATE(ProcessError)
403 
404  friend class DownloadImpl;
405 
406  public:
407 
411  virtual ~ProcessError();
412 
418  QProcess::ProcessError code();
419 
425  QString phrase();
426 
432  int exitCode();
433 
439  QString standardOut();
440 
446  QString standardError();
447 
453  QString errorString() override;
454 
455  protected:
456 
461  ProcessError(Transfers::Errors::ProcessErrorStruct err, QObject* parent);
462 
463  private:
468  ProcessErrorPrivate* d_ptr;
469 };
470 
471 } // DownloadManager
472 
473 } // Ubuntu
474 
475 #endif // ERROR_H
The Error class is the base class that represents an error in the download manager API...
Definition: error.h:55
QString errorString() override
Definition: error.cpp:411
QString errorString() override
Definition: error.cpp:365
QString errorString() override
Definition: error.cpp:310
QProcess::ProcessError code()
Definition: error.cpp:387
ProcessError(Transfers::Errors::ProcessErrorStruct err, QObject *parent)
Definition: error.cpp:370
NetworkError(Transfers::Errors::NetworkErrorStruct err, QObject *parent)
Definition: error.cpp:342
DBusError(QDBusError err, QObject *parent=0)
Definition: error.cpp:261
HttpError(Transfers::Errors::HttpErrorStruct err, QObject *parent)
Definition: error.cpp:315
AuthError(Transfers::Errors::AuthErrorStruct err, QObject *parent)
Definition: error.cpp:288
Error(Type type, QObject *parent=0)
Definition: error.cpp:240
The NetworkError represents an error that occurred during the download request.
Definition: error.h:310
virtual QString errorString()
Definition: error.cpp:256
The HttpError represents an error that occurred during the download request.
Definition: error.h:253
QString errorString() override
Definition: error.cpp:337
The ProcessError represents an error that occurred during the post processing of a downloaded file...
Definition: error.h:400
The AuthError represents an authentication error that occurred during the request of the download...
Definition: error.h:184