Ubuntu Download Manager  1.2.0
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 Ubuntu {
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 } // Ubuntu
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:444
QString errorString() override
Definition: error.cpp:398
QString errorString() override
Definition: error.cpp:343
QProcess::ProcessError code()
Definition: error.cpp:420
ProcessError(Transfers::Errors::ProcessErrorStruct err, QObject *parent)
Definition: error.cpp:403
NetworkError(Transfers::Errors::NetworkErrorStruct err, QObject *parent)
Definition: error.cpp:375
The HashError represents an error that occurred during the hash validation after the download...
Definition: error.h:480
HashError(Transfers::Errors::HashErrorStruct err, QObject *parent)
Definition: error.cpp:449
DBusError(QDBusError err, QObject *parent=0)
Definition: error.cpp:294
HttpError(Transfers::Errors::HttpErrorStruct err, QObject *parent)
Definition: error.cpp:348
AuthError(Transfers::Errors::AuthErrorStruct err, QObject *parent)
Definition: error.cpp:321
Error(Type type, QObject *parent=0)
Definition: error.cpp:273
The NetworkError represents an error that occurred during the download request.
Definition: error.h:311
virtual QString errorString()
Definition: error.cpp:289
The HttpError represents an error that occurred during the download request.
Definition: error.h:254
QString errorString() override
Definition: error.cpp:370
The ProcessError represents an error that occurred during the post processing of a downloaded file...
Definition: error.h:401
QString errorString() override
Definition: error.cpp:477
The AuthError represents an authentication error that occurred during the request of the download...
Definition: error.h:185