|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdrightsobjectoperationimpl.h" |
|
20 |
|
21 #include <s32mem.h> |
|
22 #include <apmstd.h> |
|
23 |
|
24 #include "catalogsbasemessage.h" |
|
25 #include "catalogshttpincludes.h" |
|
26 |
|
27 #include "catalogsutils.h" |
|
28 #include "catalogscontext.h" |
|
29 #include "ncdproviderdefines.h" |
|
30 #include "ncddescriptordownloadsuboperation.h" |
|
31 #include "ncdhttputils.h" |
|
32 #include "ncdproviderutils.h" |
|
33 #include "ncddeviceinteractionfactory.h" |
|
34 #include "ncdinstallationservice.h" |
|
35 #include "ncdgeneralmanager.h" |
|
36 |
|
37 #include "catalogsdebug.h" |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // NewL |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CNcdRightsObjectOperation* CNcdRightsObjectOperation::NewL( |
|
46 CNcdGeneralManager& aGeneralManager, |
|
47 const TDesC& aDownloadUri, |
|
48 const TDesC& aMimeType, |
|
49 const TNcdConnectionMethod& aMethod, |
|
50 MNcdOperationRemoveHandler& aRemoveHandler, |
|
51 MCatalogsHttpSession& aHttpSession, |
|
52 MCatalogsSession& aSession ) |
|
53 { |
|
54 CNcdRightsObjectOperation* self = new( ELeave ) CNcdRightsObjectOperation( |
|
55 aGeneralManager, aRemoveHandler, aHttpSession, aSession ); |
|
56 CleanupClosePushL( *self ); |
|
57 self->ConstructL( aMethod, aDownloadUri, aMimeType ); |
|
58 CleanupStack::Pop(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Destructor |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CNcdRightsObjectOperation::~CNcdRightsObjectOperation() |
|
68 { |
|
69 DLTRACEIN( ( "" ) ); |
|
70 if ( iDownloadOp ) |
|
71 { |
|
72 iDownloadOp->Close(); |
|
73 iDownloadOp = NULL; |
|
74 } |
|
75 delete iInstallationService; |
|
76 delete iMimeType; |
|
77 DLTRACEOUT(("")); |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Download config getter |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 MCatalogsHttpConfig& CNcdRightsObjectOperation::Config() |
|
86 { |
|
87 DASSERT( iDownloadOp ); |
|
88 return iDownloadOp->Config(); |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Cancel |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CNcdRightsObjectOperation::Cancel() |
|
97 { |
|
98 DLTRACEIN(( "" )); |
|
99 if ( iDownloadOp ) |
|
100 { |
|
101 iDownloadOp->Cancel(); |
|
102 iDownloadOp->Close(); |
|
103 iDownloadOp = NULL; |
|
104 } |
|
105 DLTRACEOUT(( "" )); |
|
106 } |
|
107 |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // RunOperation |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 TInt CNcdRightsObjectOperation::RunOperation() |
|
114 { |
|
115 DLTRACEIN(( "Pending message: %X", iPendingMessage )); |
|
116 DASSERT( iDownloadOp ); |
|
117 |
|
118 if ( !iPendingMessage ) |
|
119 { |
|
120 DLTRACE(("No pending message")); |
|
121 return KErrNotReady; |
|
122 } |
|
123 |
|
124 // Start download. |
|
125 DLINFO(("Starting download op")); |
|
126 TInt err = iDownloadOp->Start(); |
|
127 |
|
128 DLTRACEOUT(("err: %d", err)); |
|
129 return err; |
|
130 } |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // Constructor |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 CNcdRightsObjectOperation::CNcdRightsObjectOperation( |
|
138 CNcdGeneralManager& aGeneralManager, |
|
139 MNcdOperationRemoveHandler& aRemoveHandler, |
|
140 MCatalogsHttpSession& aHttpSession, |
|
141 MCatalogsSession& aSession ) |
|
142 : |
|
143 CNcdBaseOperation( aGeneralManager, &aRemoveHandler, ERightsObjectOperation, aSession ), |
|
144 iHttpSession( aHttpSession ) |
|
145 { |
|
146 } |
|
147 |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // ConstructL |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CNcdRightsObjectOperation::ConstructL( |
|
154 const TNcdConnectionMethod& aMethod, |
|
155 const TDesC& aDownloadUri, |
|
156 const TDesC& aMimeType ) |
|
157 { |
|
158 DLTRACEIN( ( "" ) ); |
|
159 |
|
160 // Call ConstructL for the base class |
|
161 CNcdBaseOperation::ConstructL(); |
|
162 |
|
163 iMimeType = ConvertUnicodeToUtf8L( aMimeType ); |
|
164 |
|
165 iDownloadOp = CNcdDescriptorDownloadSubOperation::NewL( |
|
166 iGeneralManager, iHttpSession, aDownloadUri, *this, iSession ); |
|
167 |
|
168 iGeneralManager.HttpUtils().ConvertConnectionMethod( |
|
169 aMethod, iConnectionMethod ); |
|
170 |
|
171 iDownloadOp->Config().SetConnectionMethod( iConnectionMethod ); |
|
172 |
|
173 iInstallationService = |
|
174 NcdDeviceInteractionFactory::CreateInstallationServiceL(); |
|
175 |
|
176 DLTRACEOUT(( "" )); |
|
177 } |
|
178 |
|
179 void CNcdRightsObjectOperation::Progress( CNcdBaseOperation& /*aOperation*/ ) |
|
180 { |
|
181 DLTRACEIN(("")); |
|
182 } |
|
183 |
|
184 void CNcdRightsObjectOperation::QueryReceived( |
|
185 CNcdBaseOperation& /*aOperation*/, CNcdQuery* /*aQuery*/ ) |
|
186 { |
|
187 DLTRACEIN(("")); |
|
188 } |
|
189 |
|
190 void CNcdRightsObjectOperation::OperationComplete( |
|
191 CNcdBaseOperation* aOperation, TInt aError ) |
|
192 { |
|
193 DLTRACEIN(("aOperation=%08x, aError=%d", aOperation, aError)); |
|
194 (void) aOperation; // suppresses compiler warning |
|
195 |
|
196 if( aError == KErrNone ) |
|
197 { |
|
198 // Install the DRM object. |
|
199 DLINFO(("Installing rights object (%d bytes data, mime type %S)", |
|
200 iDownloadOp->Body().Size(), iMimeType )); |
|
201 |
|
202 TRAP( aError, iInstallationService->AppendRightsL( |
|
203 iDownloadOp->Body(), |
|
204 TDataType( *iMimeType ) ) ); |
|
205 } |
|
206 |
|
207 DLINFO(("Completing rights object dl&install operation with %d", aError)); |
|
208 CompleteMessage( iPendingMessage, |
|
209 aError != KErrNone ? |
|
210 ENCDOperationMessageCompletionError : |
|
211 ENCDOperationMessageCompletionComplete, |
|
212 aError ); |
|
213 } |
|
214 |