|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation class for WMDRM DLA Handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_WMDRMDLAHANDLERIMPL_H |
|
20 #define C_WMDRMDLAHANDLERIMPL_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <wmdrmdlatypes.h> |
|
25 |
|
26 class CWmDrmDlaHttpLicAcqPluginFw; |
|
27 class CWmDrmDlaHttpMeteringPluginFw; |
|
28 class CWmDrmDlaRequest; |
|
29 |
|
30 /** |
|
31 * Implementation class for WMDRM DLA Handler |
|
32 * |
|
33 * @since S60 v9.1 |
|
34 */ |
|
35 NONSHARABLE_CLASS( CWmDrmDlaHandlerImpl ) : public CActive |
|
36 { |
|
37 |
|
38 public: |
|
39 |
|
40 static CWmDrmDlaHandlerImpl* NewL(); |
|
41 static CWmDrmDlaHandlerImpl* NewLC(); |
|
42 |
|
43 /** |
|
44 * Destructor. |
|
45 */ |
|
46 virtual ~CWmDrmDlaHandlerImpl(); |
|
47 |
|
48 /** |
|
49 * Checks if license acquisition for file is silent |
|
50 * |
|
51 * @param aFile wmdrm file |
|
52 * @return ETrue if license acquisition is silent |
|
53 * @leave KErrNotFound if there is no handler for the file |
|
54 */ |
|
55 TBool SilentL( const RFile& aFile ); |
|
56 |
|
57 /** |
|
58 * Acquire license based on the file handle |
|
59 * |
|
60 * @param aFile wmdrm file |
|
61 * @param aContentUrl contains content URL on return. Can be NULL. |
|
62 * If it's not NULL, it must be freed by caller. |
|
63 * @param aHtmlData contains HTML data returned by license server |
|
64 * on return. Can be NULL. |
|
65 * If it's not NULL, it must be freed by caller. |
|
66 */ |
|
67 void AcquireLicenseL( const RFile& aFile, HBufC*& aContentUrl, |
|
68 HBufC*& aHtmlData ); |
|
69 |
|
70 /** |
|
71 * Acquire license based on the file handle, asynchronous version |
|
72 * |
|
73 * @param aFile wmdrm file |
|
74 * @param aContentUrl contains content URL on completion. Can be NULL. |
|
75 * If it's not NULL, it must be freed by caller. |
|
76 * @param aHtmlData contains HTML data returned by license server |
|
77 * on completion. Can be NULL. |
|
78 * If it's not NULL, it must be freed by caller. |
|
79 * @param aStatus Request status. On completion contains the error code. |
|
80 */ |
|
81 void AcquireLicense( const RFile& aFile, HBufC*& aContentUrl, |
|
82 HBufC*& aHtmlData, TRequestStatus& aStatus ); |
|
83 |
|
84 /** |
|
85 * Acquire license based on the DRM Header |
|
86 * |
|
87 * @param aDrmHeader DRM Header |
|
88 * @param aErrorUrl URL where error code is sent. Can be NULL. |
|
89 * @param aContentUrl contains content URL on return. Can be NULL. |
|
90 * If it's not NULL, it must be freed by caller. |
|
91 * @param aHtmlData contains HTML data returned by license server |
|
92 * on return. Can be NULL. |
|
93 * If it's not NULL, it must be freed by caller. |
|
94 */ |
|
95 void AcquireLicenseFromDrmHeaderL( const TDesC8& aDrmHeader, |
|
96 HBufC* aErrorUrl, |
|
97 HBufC*& aContentUrl, |
|
98 HBufC*& aHtmlData ); |
|
99 |
|
100 /** |
|
101 * Acquire license based on the DRM Header, asynchronous version |
|
102 * |
|
103 * @param aDrmHeader DRM Header |
|
104 * @param aErrorUrl URL where error code is sent. Can be NULL. |
|
105 * @param aContentUrl contains content URL on completion. Can be NULL. |
|
106 * If it's not NULL, it must be freed by caller. |
|
107 * @param aHtmlData contains HTML data returned by license server |
|
108 * on completion. Can be NULL. |
|
109 * If it's not NULL, it must be freed by caller. |
|
110 * @param aStatus Request status. On completion contains the error code. |
|
111 */ |
|
112 void AcquireLicenseFromDrmHeader( const TDesC8& aDrmHeader, |
|
113 HBufC* aErrorUrl, |
|
114 HBufC*& aContentUrl, |
|
115 HBufC*& aHtmlData, |
|
116 TRequestStatus& aStatus ); |
|
117 |
|
118 /* |
|
119 * Cancels current and all queued license acquisition requests |
|
120 */ |
|
121 void CancelLicenseAcquisition(); |
|
122 |
|
123 /** |
|
124 * Handles metering certificate OTA |
|
125 * |
|
126 * @param aCertificate metering certificate |
|
127 */ |
|
128 void ProcessMeteringCertificateL( const TDesC8& aCertificate ); |
|
129 |
|
130 /** |
|
131 * Handles metering certificate OTA, asynchronous version |
|
132 * |
|
133 * @param aCertificate metering certificate |
|
134 * @param aStatus Request status. On completion contains the error code. |
|
135 */ |
|
136 void ProcessMeteringCertificate( const TDesC8& aCertificate, |
|
137 TRequestStatus& aStatus ); |
|
138 |
|
139 /* |
|
140 * Cancels current and all queued metering requests |
|
141 */ |
|
142 void CancelMetering(); |
|
143 |
|
144 /** |
|
145 * Sets the IAP to be used in the HTTP transactions |
|
146 * |
|
147 * @param aIapId Internet Access Point id |
|
148 */ |
|
149 void SetIapId( TInt aIapId ); |
|
150 |
|
151 protected: // from base class CActive |
|
152 |
|
153 /** |
|
154 * From CActive Cancels async request. |
|
155 */ |
|
156 void DoCancel(); |
|
157 |
|
158 /** |
|
159 * From CActive Called when async request completes. |
|
160 */ |
|
161 void RunL(); |
|
162 |
|
163 /** |
|
164 * From CActive Called if RunL leaves. |
|
165 */ |
|
166 TInt RunError( TInt aError ); |
|
167 |
|
168 private: |
|
169 |
|
170 CWmDrmDlaHandlerImpl(); |
|
171 void ConstructL(); |
|
172 |
|
173 void CompleteSelf(); |
|
174 void CompleteClientRequest( TInt aError ); |
|
175 void CompleteSyncRequest( TInt aError ); |
|
176 |
|
177 /* |
|
178 * Takes next request to handling. |
|
179 * If synchronous request is available, it will be handled first. |
|
180 * Otherwise next async request is taken from the queue and handled. |
|
181 * If there aren't any requests, state is set to idle |
|
182 */ |
|
183 void NextRequest(); |
|
184 |
|
185 //State handlers |
|
186 |
|
187 /* |
|
188 * Completes current request and retrieves next one, |
|
189 * if available, to handling |
|
190 */ |
|
191 void Completed( TInt aError ); |
|
192 |
|
193 /* |
|
194 * Makes asynchronous call to CWmDrmDlaHttpPluginFw to |
|
195 * acquire license from drm header |
|
196 */ |
|
197 void AcquiringLicenseFromDrmHeader(); |
|
198 |
|
199 /* |
|
200 * Makes asynchronous call to CWmDrmDlaHttpPluginFw to |
|
201 * acquire license from file |
|
202 */ |
|
203 void AcquiringLicense(); |
|
204 |
|
205 /* |
|
206 * Makes asynchronous call to CWmDrmDlaHttpPluginFw to |
|
207 * process metering certificate |
|
208 */ |
|
209 void ProcessingMeteringCertificate(); |
|
210 |
|
211 private: // data |
|
212 |
|
213 enum TDlaHandlerState |
|
214 { |
|
215 EIdle, |
|
216 EAcquiringLicense, |
|
217 EAcquiringLicenseFromDrmHeader, |
|
218 EProcessingMeteringCertificate, |
|
219 ECompleted |
|
220 }; |
|
221 |
|
222 TDlaHandlerState iState; |
|
223 CWmDrmDlaHttpLicAcqPluginFw* iLicenseAcquisitionFw; |
|
224 CWmDrmDlaHttpMeteringPluginFw* iMeteringFw; |
|
225 RPointerArray<CWmDrmDlaRequest> iRequests; |
|
226 CWmDrmDlaRequest* iCurrentRequest; |
|
227 CWmDrmDlaRequest* iSyncRequest; |
|
228 TInt iSyncReturnValue; |
|
229 CActiveSchedulerWait* iWait; |
|
230 }; |
|
231 |
|
232 #endif // C_WMDRMDLAHANDLERIMPL_H |