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 OMA2DOWNLOADBACKEND_H
|
|
18 |
#define OMA2DOWNLOADBACKEND_H
|
|
19 |
|
|
20 |
#include "dmcommon.h"
|
|
21 |
#include "dmcommoninternal.h"
|
|
22 |
#include "dmpimpl.h"
|
|
23 |
#include "downloadbackend.h"
|
|
24 |
|
|
25 |
// forward declarations
|
|
26 |
class OMA2DownloadBackendPrivate;
|
|
27 |
class DownloadCore;
|
|
28 |
class ClientDownload;
|
|
29 |
|
|
30 |
typedef QList<ClientDownload*> MediaDownloadList;
|
|
31 |
|
|
32 |
// class declaration
|
|
33 |
|
|
34 |
// concrete download implementation for OMA2 downloads
|
|
35 |
class OMA2DownloadBackend : public DownloadBackend
|
|
36 |
{
|
|
37 |
Q_OBJECT
|
|
38 |
DM_DECLARE_PRIVATE(OMA2DownloadBackend); // private implementation
|
|
39 |
public:
|
|
40 |
OMA2DownloadBackend(DownloadCore *dlCore, ClientDownload *dl);
|
|
41 |
~OMA2DownloadBackend();
|
|
42 |
|
|
43 |
// fetches the oma2 download attributes
|
|
44 |
QVariant getAttribute(DownloadAttribute attr);
|
|
45 |
// sets the oma2 download specific attributes
|
|
46 |
int setAttribute(DownloadAttribute attr, const QVariant& value);
|
|
47 |
// overloaded function for pausing the download
|
|
48 |
int pause();
|
|
49 |
// overloaded function for resuming paused download
|
|
50 |
int resume();
|
|
51 |
// overloaded function for cancelling the download
|
|
52 |
int cancel();
|
|
53 |
// overloaded function for getting child downloads
|
|
54 |
void getChildren(QList<Download*>& list);
|
|
55 |
|
|
56 |
// stores the data in storage
|
|
57 |
void store(QByteArray data, bool lastChunk=false);
|
|
58 |
// deletes the storage
|
|
59 |
void deleteStore();
|
|
60 |
// returns the size of stored data
|
|
61 |
qint64 storedDataSize();
|
|
62 |
// re-constructing all the values as part of persistent storage
|
|
63 |
void init();
|
|
64 |
|
|
65 |
|
|
66 |
private slots:
|
|
67 |
void bytesRecieved(qint64 bytesRecieved, qint64 bytesTotal);
|
|
68 |
void handleFinished();
|
|
69 |
void bytesUploaded(qint64, qint64);
|
|
70 |
private:
|
|
71 |
// parses download descriptor
|
|
72 |
bool parseDownloadDescriptor();
|
|
73 |
// does the capability check on receiving DD
|
|
74 |
bool checkDownloadDescriptor();
|
|
75 |
// event handler
|
|
76 |
bool event(QEvent *event);
|
|
77 |
// suppress user confirmation
|
|
78 |
bool suppressUserConfirmation();
|
|
79 |
// handle status code
|
|
80 |
void handleStatusCode(const int& statusCode);
|
|
81 |
// handle precondition failed
|
|
82 |
void handlePreconditionFailed();
|
|
83 |
// adds the downloads to downloadList
|
|
84 |
void addtoDownloadList(ClientDownload *dl);
|
|
85 |
// finds the download for the given id
|
|
86 |
ClientDownload* findDownload(int id);
|
|
87 |
// posting the install notify event to the web server
|
|
88 |
void postInstallNotifyEvent(const char* statusMessage);
|
|
89 |
// verifying downloads by going through the MediaObject map and setting OMA2'S state at the end.
|
|
90 |
void verifyDownloads();
|
|
91 |
// returns current MediaObject index
|
|
92 |
int currentIndex();
|
|
93 |
// setting values in QSettings for persistent storage
|
|
94 |
void serializeData(ClientDownload* dl, int index);
|
|
95 |
};
|
|
96 |
|
|
97 |
#endif
|