Ubuntu Download Manager  0.3.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 #include <ubuntu/download_manager/common.h>
25 
26 class QDBusError;
27 
28 namespace Ubuntu {
29 
30 namespace Transfers {
31 
32 namespace Errors {
33  class AuthErrorStruct;
34  class HttpErrorStruct;
35  class NetworkErrorStruct;
36  class ProcessErrorStruct;
37 }
38 
39 }
40 
41 namespace DownloadManager {
42 
43 class ErrorPrivate;
44 
56 class Error : public QObject {
57  Q_OBJECT
58  Q_DECLARE_PRIVATE(Error)
59 
60  public:
61 
65  enum Type {
66  Auth,
67  DBus,
68  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 } // DownloadManager
473 
474 } // Ubuntu
475 
476 #endif // ERROR_H
The Error class is the base class that represents an error in the download manager API...
Definition: error.h:56
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:311
virtual QString errorString()
Definition: error.cpp:256
The HttpError represents an error that occurred during the download request.
Definition: error.h:254
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:401
The AuthError represents an authentication error that occurred during the request of the download...
Definition: error.h:185