16
|
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 DOWNLOADMANAGER_H
|
|
18 |
#define DOWNLOADMANAGER_H
|
|
19 |
|
|
20 |
#include "dmcommon.h"
|
|
21 |
#include "dmpimpl.h"
|
|
22 |
#include "downloadevent.h"
|
|
23 |
#include <QObject>
|
|
24 |
|
|
25 |
#ifndef DOWNLOAD_MGR_EXPORT
|
|
26 |
# ifdef BUILD_DOWNLOAD_MGR_LIB
|
|
27 |
# define DOWNLOAD_MGR_EXPORT Q_DECL_EXPORT
|
|
28 |
# else
|
|
29 |
# define DOWNLOAD_MGR_EXPORT Q_DECL_IMPORT
|
|
30 |
# endif
|
|
31 |
#endif
|
|
32 |
|
|
33 |
// forward declarations
|
|
34 |
class Download;
|
|
35 |
class QNetworkReply;
|
|
36 |
class QNetworkProxy;
|
|
37 |
class DownloadInfo;
|
|
38 |
class DownloadCoreManager;
|
|
39 |
class BackgroundDownloadManager;
|
|
40 |
class DownloadManagerPrivate;
|
|
41 |
class SequentialDownloadManager;
|
|
42 |
|
|
43 |
// class declaration
|
|
44 |
class DownloadManager
|
|
45 |
{
|
|
46 |
DM_DECLARE_PRIVATE(DownloadManager); // private implementation
|
|
47 |
public:
|
|
48 |
DOWNLOAD_MGR_EXPORT DownloadManager(const QString& clientName);
|
|
49 |
DOWNLOAD_MGR_EXPORT virtual ~DownloadManager();
|
|
50 |
|
|
51 |
// to initialise all the downloads which belongs to last
|
|
52 |
// download manager session
|
|
53 |
DOWNLOAD_MGR_EXPORT void init();
|
|
54 |
// creates new download by passing url
|
|
55 |
DOWNLOAD_MGR_EXPORT Download* createDownload(const QString& url, DownloadType type = Parallel, DownloadScope scope = Normal);
|
|
56 |
// creates a download by passing network reply
|
|
57 |
DOWNLOAD_MGR_EXPORT Download* createDownload(QNetworkReply *reply);
|
|
58 |
// sets the proxy
|
|
59 |
DOWNLOAD_MGR_EXPORT void setProxy(const QString& proxyServer, int port);
|
|
60 |
// registers event listener
|
|
61 |
DOWNLOAD_MGR_EXPORT void registerEventReceiver(QObject *receiver);
|
|
62 |
// unregister event listener
|
|
63 |
DOWNLOAD_MGR_EXPORT void unregisterEventReceiver(QObject *receiver);
|
|
64 |
// sets download manager attributes
|
|
65 |
DOWNLOAD_MGR_EXPORT int setAttribute(DownloadManagerAttribute attr, const QVariant& value);
|
|
66 |
// fetches download manager attributes
|
|
67 |
DOWNLOAD_MGR_EXPORT QVariant getAttribute(DownloadManagerAttribute attr);
|
|
68 |
// returns all the current downloads
|
|
69 |
DOWNLOAD_MGR_EXPORT QList<Download *>& currentDownloads();
|
|
70 |
// finds a download provided id if exists
|
|
71 |
DOWNLOAD_MGR_EXPORT Download* findDownload(int dlId);
|
|
72 |
// cancels all the downloads and removes from the list
|
|
73 |
DOWNLOAD_MGR_EXPORT void removeAll();
|
|
74 |
// cancels and removes the download from list
|
|
75 |
DOWNLOAD_MGR_EXPORT void removeOne(Download *dl);
|
|
76 |
// pauses all the downloads which are in progress
|
|
77 |
DOWNLOAD_MGR_EXPORT void pauseAll();
|
|
78 |
// resumes all the downloads which are paused
|
|
79 |
DOWNLOAD_MGR_EXPORT void resumeAll();
|
|
80 |
// returns the network proxy
|
|
81 |
DOWNLOAD_MGR_EXPORT QNetworkProxy* proxy();
|
|
82 |
|
|
83 |
// returns downloadinfo object
|
|
84 |
DownloadInfo* downloadInfo();
|
|
85 |
// returns downloadcoremanager object
|
|
86 |
DownloadCoreManager* downloadCoreManager();
|
|
87 |
// returns sequentialmanager object
|
|
88 |
SequentialDownloadManager* sequentialManager();
|
|
89 |
// returns background download manager object
|
|
90 |
BackgroundDownloadManager* backgroundManager();
|
|
91 |
|
|
92 |
// post the events
|
|
93 |
void postEvent(DEventType type, DlManagerEventAttributeMap* attrMap);
|
|
94 |
|
|
95 |
private:
|
|
96 |
// creates download by passing id
|
|
97 |
// used while loading the saved downloads
|
|
98 |
Download* createDownload(int dlId, DownloadScope scope);
|
|
99 |
// loads the saved downloads
|
|
100 |
void loadAllDownloads();
|
|
101 |
// generated unique id for download
|
|
102 |
long generateDlId();
|
|
103 |
};
|
|
104 |
|
|
105 |
#endif
|