|
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 #include "downloadmanager.h" |
|
18 #include "downloadfactory.h" |
|
19 #include "clientdownload.h" |
|
20 #include "downloadcore.h" |
|
21 #include "downloadstore.h" |
|
22 #include "filestorage.h" |
|
23 #include "downloadbackend.h" |
|
24 #include "httpdownloadbackend.h" |
|
25 #include "omadownloadbackend.h" |
|
26 #include "oma2downloadbackend.h" |
|
27 #include <QNetworkReply> |
|
28 #include <QNetworkRequest> |
|
29 |
|
30 #ifdef __SYMBIAN32__ |
|
31 #include <bldvariant.hrh> |
|
32 #include "drmstorage.h" |
|
33 #ifdef RD_WMDRM_DLA_ENABLERS |
|
34 #include "wmdrmdownloadbackend.h" |
|
35 #endif |
|
36 #endif |
|
37 |
|
38 // This is responsible for creation of concrete download download implementation class |
|
39 // based on the content type |
|
40 DownloadBackend* DownloadAbstractFactory::createDownloadImplementation(DownloadCore *dlCore, ClientDownload *dl) |
|
41 { |
|
42 QString contentType = dlCore->contentType(); |
|
43 if(contentType == "") |
|
44 { |
|
45 QNetworkReply *reply = dlCore->reply(); |
|
46 if(reply) |
|
47 { |
|
48 contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); |
|
49 } |
|
50 } |
|
51 |
|
52 QString clientName = dl->downloadManager()->getAttribute(DlMgrClientName).toString(); |
|
53 DownloadBackend *dlBackend = NULL; |
|
54 DownloadStore* store = NULL; |
|
55 if(contentType == OMA_CONTENT_TYPE) { |
|
56 dlBackend = new OMADownloadBackend(dlCore, dl); |
|
57 } |
|
58 else if(contentType == OMA2_CONTENT_TYPE) { |
|
59 dlBackend = new OMA2DownloadBackend(dlCore, dl); |
|
60 } |
|
61 |
|
62 #ifdef __SYMBIAN32__ |
|
63 else if(contentType == OMA_DRM_MESSAGE_CONTENT_TYPE) { |
|
64 store = new DrmStorage(clientName, dl); |
|
65 dlBackend = new HttpDownloadBackend(dlCore, dl, store); |
|
66 } |
|
67 #ifdef RD_WMDRM_DLA_ENABLERS |
|
68 else if(contentType.contains(WMDRM_CONTENT_TYPE, Qt::CaseInsensitive)) |
|
69 dlBackend = new WMDRMDownloadBackend(dlCore, dl); |
|
70 #endif |
|
71 #endif |
|
72 //we can have other if-else cases for different type of downloads |
|
73 // by default the download is http download |
|
74 else { |
|
75 store = new FileStorage(clientName, dl); |
|
76 dlBackend = new HttpDownloadBackend(dlCore, dl, store); |
|
77 } |
|
78 return dlBackend; |
|
79 } |
|
80 |
|
81 |
|
82 |
|
83 |