|
1 /* |
|
2 * Copyright (c) 2006-2009 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 of the CAF Agent Data class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <caf.h> |
|
22 #include <caf/caferr.h> |
|
23 #include <attribute.h> |
|
24 #include <e32test.h> |
|
25 #include "wmdrmagentdata.h" |
|
26 #include "wmdrmagentattributes.h" |
|
27 #include "asf.h" |
|
28 #include "logfn.h" |
|
29 |
|
30 using namespace ContentAccess; |
|
31 |
|
32 // LOCAL FUNCTION PROTOTYPES |
|
33 LOCAL_C TInt MapContentShareMode(TContentShareMode aMode); |
|
34 |
|
35 // ============================= LOCAL FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // MapContentShareMode |
|
39 // Maps the CAF specific file share mode to the RFs/RFile sharing mode |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 TInt MapContentShareMode(TContentShareMode aMode) |
|
43 { |
|
44 TInt r = EFileRead | EFileShareAny; |
|
45 |
|
46 switch (aMode) |
|
47 { |
|
48 case EContentShareReadOnly: |
|
49 r = EFileRead | EFileShareReadersOnly; |
|
50 break; |
|
51 case EContentShareReadWrite: |
|
52 r = EFileRead | EFileShareReadersOrWriters; |
|
53 break; |
|
54 case EContentShareExclusive: |
|
55 r = EFileRead | EFileShareExclusive; |
|
56 break; |
|
57 } |
|
58 return r; |
|
59 } |
|
60 |
|
61 // ============================ MEMBER FUNCTIONS =============================== |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CWmDrmAgentData::CWmDrmAgentData |
|
65 // C++ default constructor can NOT contain any code, that |
|
66 // might leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CWmDrmAgentData::CWmDrmAgentData(): |
|
70 iVirtualPath( KNullDesC ), |
|
71 iAsf( NULL ) |
|
72 { |
|
73 LOGFN( "CWmDrmAgentData::CWmDrmAgentData" ); |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CWmDrmAgentData::NewL |
|
79 // Two-phased constructor. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CWmDrmAgentData* CWmDrmAgentData::NewL( |
|
83 const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode ) |
|
84 { |
|
85 LOGFN( "CWmDrmAgentData::NewL" ); |
|
86 CWmDrmAgentData* self = new (ELeave) CWmDrmAgentData; |
|
87 CleanupStack::PushL(self); |
|
88 self->ConstructL(aVirtualPath, aShareMode); |
|
89 CleanupStack::Pop(self); |
|
90 return self; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CWmDrmAgentData::NewLC |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CWmDrmAgentData* CWmDrmAgentData::NewLC( |
|
98 const TVirtualPathPtr& aVirtualPath, |
|
99 TContentShareMode aShareMode) |
|
100 { |
|
101 LOGFN( "CWmDrmAgentData::NewLC" ); |
|
102 CWmDrmAgentData* self=new(ELeave) CWmDrmAgentData(); |
|
103 CleanupStack::PushL(self); |
|
104 self->ConstructL(aVirtualPath, aShareMode); |
|
105 return self; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CWmDrmAgentData::NewLC |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CWmDrmAgentData* CWmDrmAgentData::NewL( |
|
113 RFile& aFile, const TDesC& aUniqueId ) |
|
114 { |
|
115 LOGFN( "CWmDrmAgentData::NewL (2)" ); |
|
116 CWmDrmAgentData* self = new (ELeave) CWmDrmAgentData; |
|
117 CleanupStack::PushL(self); |
|
118 self->ConstructL(aFile, aUniqueId); |
|
119 CleanupStack::Pop(self); |
|
120 return self; |
|
121 } |
|
122 |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CWmDrmAgentData::NewLC |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 CWmDrmAgentData* CWmDrmAgentData::NewLC( |
|
129 RFile& aFile, |
|
130 const TDesC& aUniqueId ) |
|
131 { |
|
132 LOGFN( "CWmDrmAgentData::NewLC (2)" ); |
|
133 CWmDrmAgentData* self=new(ELeave) CWmDrmAgentData(); |
|
134 CleanupStack::PushL(self); |
|
135 self->ConstructL(aFile, aUniqueId); |
|
136 return self; |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CWmDrmAgentData::~CWmDrmAgentData |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 |
|
144 CWmDrmAgentData::~CWmDrmAgentData() |
|
145 { |
|
146 // Tidy up RFile and RFs |
|
147 LOGFN( "CWmDrmAgentData::~CWmDrmAgentData" ); |
|
148 iFile.Close(); |
|
149 iFs.Close(); |
|
150 delete iAsf; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CWmDrmAgentData::ConstructL |
|
155 // The porting kit is not initialized here since it is time consuming. It is |
|
156 // initialized whenever needed and just allocated at this point. |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CWmDrmAgentData::ConstructL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode) |
|
160 { |
|
161 LOGFN( "CWmDrmAgentData::ConstructL" ); |
|
162 User::LeaveIfError(iFs.Connect()); |
|
163 User::LeaveIfError(iFile.Open(iFs, aVirtualPath.URI(), |
|
164 MapContentShareMode(aShareMode))); |
|
165 iAsf = CAsf::NewL(iFile); |
|
166 iVirtualPath = aVirtualPath; |
|
167 } |
|
168 |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CWmDrmAgentData::ConstructL |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CWmDrmAgentData::ConstructL(RFile& aFile, const TDesC& /*aUniqueId*/) |
|
175 { |
|
176 TInt pos = 0; |
|
177 |
|
178 LOGFN( "CWmDrmAgentData::ConstructL (2)" ); |
|
179 // When creating a CData from a file handle we must duplicate the file handle |
|
180 // before doing anything |
|
181 User::LeaveIfError(iFs.Connect()); |
|
182 User::LeaveIfError(iFile.Duplicate(aFile)); |
|
183 User::LeaveIfError(iFile.Seek(ESeekStart, pos)); // reset to start of file |
|
184 iAsf = CAsf::NewL(iFile); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CWmDrmAgentData::DataSizeL |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CWmDrmAgentData::DataSizeL(TInt &aSize) |
|
192 { |
|
193 LOGFN( "CWmDrmAgentData::DataSizeL" ); |
|
194 User::LeaveIfError(iFile.Size(aSize)); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CWmDrmAgentData::EvaluateIntent |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 TInt CWmDrmAgentData::EvaluateIntent(TIntent /*aIntent*/) |
|
202 { |
|
203 LOGFN( "CWmDrmAgentData::EvaluateIntent" ); |
|
204 return KErrCANotSupported; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CWmDrmAgentData::ExecuteIntent |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TInt CWmDrmAgentData::ExecuteIntent(TIntent /*aIntent*/) |
|
212 { |
|
213 LOGFN( "CWmDrmAgentData::ExecuteIntent" ); |
|
214 return KErrCANotSupported; |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CWmDrmAgentData::Read |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 TInt CWmDrmAgentData::Read(TDes8& aDes) |
|
222 { |
|
223 LOGFN( "CWmDrmAgentData::Read" ); |
|
224 return iFile.Read(aDes); |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // CWmDrmAgentData::Read |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 TInt CWmDrmAgentData::Read(TDes8& aDes,TInt aLength) |
|
232 { |
|
233 LOGFN( "CWmDrmAgentData::Read (2)" ); |
|
234 return iFile.Read(aDes,aLength); |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CWmDrmAgentData::Read |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void CWmDrmAgentData::Read(TDes8& aDes,TRequestStatus& aStatus) |
|
242 { |
|
243 LOGFN( "CWmDrmAgentData::Read (3)" ); |
|
244 iFile.Read(aDes, aStatus); |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CWmDrmAgentData::Read |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void CWmDrmAgentData::Read(TDes8& aDes, |
|
252 TInt aLength, |
|
253 TRequestStatus& aStatus) |
|
254 { |
|
255 LOGFN( "CWmDrmAgentData::Read (4)" ); |
|
256 iFile.Read(aDes, aLength, aStatus); |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CWmDrmAgentData::Read |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 TInt CWmDrmAgentData::Read(TInt aPos, TDes8& aDes, |
|
264 TInt aLength, |
|
265 TRequestStatus& aStatus) |
|
266 { |
|
267 LOGFN( "CWmDrmAgentData::Read (5)" ); |
|
268 iFile.Read(aPos, aDes, aLength, aStatus); |
|
269 return KErrNone; |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CWmDrmAgentData::Seek |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 TInt CWmDrmAgentData::Seek(TSeek aMode, TInt& aPos) |
|
277 { |
|
278 LOGFN( "CWmDrmAgentData::Seek" ); |
|
279 return iFile.Seek(aMode, aPos); |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CWmDrmAgentData::SetProperty |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 TInt CWmDrmAgentData::SetProperty(TAgentProperty /*aProperty*/, TInt /*aValue*/) |
|
287 { |
|
288 LOGFN( "CWmDrmAgentData::SetProperty" ); |
|
289 return KErrCANotSupported; |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CWmDrmAgentData::GetAttribute |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 TInt CWmDrmAgentData::GetAttribute(TInt aAttribute, TInt& aValue) |
|
297 { |
|
298 TInt r = KErrNone; |
|
299 TInt err = KErrNone; |
|
300 |
|
301 LOGFN( "CWmDrmAgentData::GetAttribute" ); |
|
302 TRAP(err,r = TWmDrmAgentAttributes::GetAttributeL(iAsf, |
|
303 aAttribute, aValue, iVirtualPath)); |
|
304 if (err != KErrNone) |
|
305 { |
|
306 return err; |
|
307 } |
|
308 |
|
309 return r; |
|
310 |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CWmDrmAgentData::GetAttributeSet |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 TInt CWmDrmAgentData::GetAttributeSet(RAttributeSet& aAttributeSet) |
|
318 { |
|
319 TInt err = KErrNone; |
|
320 TInt r = KErrNone; |
|
321 |
|
322 LOGFN( "CWmDrmAgentData::GetAttributeS" ); |
|
323 TRAP(err, r = TWmDrmAgentAttributes::GetAttributeSetL(iAsf, |
|
324 aAttributeSet, iVirtualPath) ); |
|
325 if (err != KErrNone) |
|
326 { |
|
327 return err; |
|
328 } |
|
329 return r; |
|
330 } |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // CWmDrmAgentData::GetStringAttribute |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 TInt CWmDrmAgentData::GetStringAttribute(TInt aAttribute, TDes& aValue) |
|
337 { |
|
338 TInt err = KErrNone; |
|
339 TInt r = KErrNone; |
|
340 |
|
341 LOGFN( "CWmDrmAgentData::GetStringAttribute" ); |
|
342 TRAP(err, r = TWmDrmAgentAttributes::GetStringAttributeL(iAsf, |
|
343 aAttribute, aValue, iVirtualPath)); |
|
344 if (err != KErrNone) |
|
345 { |
|
346 return err; |
|
347 } |
|
348 return r; |
|
349 |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // CWmDrmAgentData::GetStringAttributeSet |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 TInt CWmDrmAgentData::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet) |
|
357 { |
|
358 TInt err = KErrNone; |
|
359 TInt r = KErrNone; |
|
360 |
|
361 LOGFN( "CWmDrmAgentData::GetStringAttributeSet" ); |
|
362 TRAP(err,r = TWmDrmAgentAttributes::GetStringAttributeSetL(iAsf, |
|
363 aStringAttributeSet, iVirtualPath)); |
|
364 if (err != KErrNone) |
|
365 { |
|
366 return err; |
|
367 } |
|
368 return r; |
|
369 |
|
370 } |
|
371 |
|
372 // End of File |