|
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 #ifndef DOWNLOADMANAGERCLIENT_H |
|
17 #define DOWNLOADMANAGERCLIENT_H |
|
18 |
|
19 #include <QObject> |
|
20 #include "downloadmanager.h" |
|
21 #include "dmcommoninternal.h" |
|
22 #include "dmpimpl.h" |
|
23 |
|
24 class DownloadManagerClientPrivate; |
|
25 |
|
26 class DownloadManagerClient : public QObject |
|
27 { |
|
28 Q_OBJECT |
|
29 DM_DECLARE_PRIVATE(DownloadManagerClient); |
|
30 |
|
31 public: |
|
32 DownloadManagerClient(DownloadManager* downloadManager); |
|
33 ~DownloadManagerClient(); |
|
34 |
|
35 // low-level implementation of functions present in BackgroundDownloadManager class |
|
36 void setStartupInfo(); |
|
37 void setProxy(const QString& proxyServer, const int port); |
|
38 int createDownload(const QString& url, DownloadType type); |
|
39 bool attachToDownload(int dlId); |
|
40 void removeDownload(int downloadId); |
|
41 void pauseAll(); |
|
42 void resumeAll(); |
|
43 void removeAll(); |
|
44 QVariant getDownloadManagerAttribute(DownloadManagerAttribute attr); |
|
45 int setDownloadManagerAttribute(DownloadManagerAttribute attr, const QVariant& value); |
|
46 |
|
47 // low-level implementation of functions present in BackgroundDownload class |
|
48 int startDownload(int dlId); |
|
49 int pauseDownload(int dlId); |
|
50 int resumeDownload(int dlId); |
|
51 int cancelDownload(int dlId); |
|
52 QVariant getDownloadAttribute(int dlId, DownloadAttribute attr); |
|
53 int setDownloadAttribute(int dlId, DownloadAttribute attr, const QVariant& value); |
|
54 |
|
55 // server error functions |
|
56 int serverError(); |
|
57 |
|
58 private: |
|
59 // start server if required and connect to it; set proxy info in server |
|
60 bool initServer(); |
|
61 // connect to download manager server |
|
62 bool connectToServer(); |
|
63 // process Download and DownloadManager events |
|
64 void processEvents(QString eventMsg); |
|
65 // encodes the strings (client name, url, etc) so that it does not contain |
|
66 // message delimiter (DM_DELIMITER) |
|
67 QString encodeString(const QString& inputString); |
|
68 |
|
69 private slots: |
|
70 // poll server for events |
|
71 void getEvents(); |
|
72 // set server IPC error |
|
73 void setServerError(int ); |
|
74 }; |
|
75 |
|
76 #endif |