|
1 /** |
|
2 This file is part of CWRT package ** |
|
3 |
|
4 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** |
|
5 |
|
6 This program is free software: you can redistribute it and/or modify |
|
7 it under the terms of the GNU (Lesser) General Public License as |
|
8 published by the Free Software Foundation, version 2.1 of the License. |
|
9 This program is distributed in the hope that it will be useful, but |
|
10 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 (Lesser) General Public License for more details. You should have |
|
13 received a copy of the GNU (Lesser) General Public License along |
|
14 with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 */ |
|
16 |
|
17 #ifndef BACKGROUNDDOWNLOAD_H |
|
18 #define BACKGROUNDDOWNLOAD_H |
|
19 |
|
20 #include "download.h" |
|
21 #include "dmcommon.h" |
|
22 #include "dmpimpl.h" |
|
23 #include <QObject> |
|
24 |
|
25 class DownloadManager; |
|
26 class BackgroundDownloadManager; |
|
27 class BackgroundDownloadPrivate; |
|
28 |
|
29 typedef QList<QObject*> EventReceiverList; |
|
30 |
|
31 // class declaration |
|
32 class BackgroundDownload : public Download |
|
33 { |
|
34 Q_OBJECT |
|
35 DM_DECLARE_PRIVATE(BackgroundDownload); |
|
36 public: |
|
37 BackgroundDownload(DownloadManager* mgr, const QString& url, int dlId); |
|
38 virtual ~BackgroundDownload(); |
|
39 |
|
40 // starts the download |
|
41 int start(); |
|
42 // id of the download |
|
43 int id(); |
|
44 // sets the attributes for the download |
|
45 int setAttribute(DownloadAttribute attr, const QVariant& value); |
|
46 // fetches the attributes of download |
|
47 QVariant getAttribute(DownloadAttribute attr); |
|
48 // pauses the download |
|
49 int pause(); |
|
50 // resumes the download |
|
51 int resume(); |
|
52 // cancels the download |
|
53 int cancel(); |
|
54 // registers the event listener |
|
55 void registerEventReceiver(QObject *receiver); |
|
56 // unregisters the event listener |
|
57 void unregisterEventReceiver(QObject *receiver); |
|
58 // returns the download manager |
|
59 DownloadManager* downloadManager(); |
|
60 // returns the list of child downloads |
|
61 void getChildren(QList<Download*>& list); |
|
62 // posts the event to recievers event loop |
|
63 void postEvent(DEventType type, DlEventAttributeMap* attrMap); |
|
64 // remove info of this download |
|
65 void removeDownloadInfo(); |
|
66 |
|
67 private: // copy constructor and assaignment operator |
|
68 BackgroundDownload(const BackgroundDownload &); |
|
69 BackgroundDownload &operator=(const BackgroundDownload &); |
|
70 |
|
71 // returns the event listeners |
|
72 EventReceiverList& eventReceivers(); |
|
73 }; |
|
74 |
|
75 #endif |