|
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 SEQUENTIALDOWNLOADMANAGER_H |
|
18 #define SEQUENTIALDOWNLOADMANAGER_H |
|
19 |
|
20 #include "dmcommon.h" |
|
21 #include "dmpimpl.h" |
|
22 #include "downloadevent.h" |
|
23 #include <QObject> |
|
24 #include <QQueue> |
|
25 |
|
26 // forward declarations |
|
27 class ClientDownload; |
|
28 class QNetworkReply; |
|
29 class SequentialDownloadManagerPrivate; |
|
30 |
|
31 // class declaration |
|
32 class SequentialDownloadManager : public QObject |
|
33 { |
|
34 DM_DECLARE_PRIVATE(SequentialDownloadManager); // private implementation |
|
35 public: |
|
36 SequentialDownloadManager(); |
|
37 virtual ~SequentialDownloadManager(); |
|
38 |
|
39 // returns all the current downloads |
|
40 QList<Download *>& currentDownloads(); |
|
41 // finds a download provided id if exists |
|
42 Download* findDownload(int dlId); |
|
43 // cancels all the downloads and removes from the list |
|
44 void removeAll(); |
|
45 // cancels and removes the download from list |
|
46 void removeOne(Download *dl); |
|
47 // pauses all the downloads which are in progress |
|
48 void pauseAll(); |
|
49 // resumes all the downloads which are paused |
|
50 void resumeAll(); |
|
51 // Adds to the download list |
|
52 void addToSequentialDownload(Download* dl); |
|
53 |
|
54 private: |
|
55 // removes adownload from created download list to download queue for downloading |
|
56 void addToDownloadQueue(Download* dl); |
|
57 // adds downloads to completed list of downloads |
|
58 void addToCompletedList(Download* dl); |
|
59 // processes a download when download start fired |
|
60 void process(int dlId); |
|
61 // event handler |
|
62 bool event(QEvent *event); |
|
63 // starts the next download in downloadQueue |
|
64 void startNext(); |
|
65 // pauses the download if it is the first one in the queue |
|
66 void pauseDownload(int dlId); |
|
67 // resumes the download if it is the first one in the queue |
|
68 void resumeDownload(int dlId); |
|
69 // cancels the download if it is the first one in the queue |
|
70 void cancelDownload(int dlId); |
|
71 |
|
72 friend class ClientDownload; |
|
73 }; |
|
74 |
|
75 #endif |