|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * wmdrmaccess.h |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef _WMDRM_ACCESS_API_H_ |
|
20 #define _WMDRM_ACCESS_API_H_ |
|
21 |
|
22 // Forward declarations |
|
23 class CWmDrmAccessEcomInterface; |
|
24 |
|
25 // Class declaration |
|
26 /** |
|
27 * Provides access to WM DRM protected files |
|
28 * (e.g. decrypting services for WM DRM protected files) |
|
29 * |
|
30 * @code |
|
31 * // Way to use CWmDrmAccess |
|
32 * |
|
33 * CWmDrmAccess* access( CWmDrmAccess::NewL() ); |
|
34 * // ... |
|
35 * // fetch file header of the WM DRM protected file to be decrypted. |
|
36 * // Assign it to initializationData |
|
37 * // ... |
|
38 * // Initialize with given initialisation data |
|
39 * access->Initialize( initializationData ); |
|
40 * // ... |
|
41 * // read encrypted data block to buffer |
|
42 * // ... |
|
43 * CWmDrmAccess->Decrypt( buffer ); |
|
44 * // use decrypted data in buffer |
|
45 * // ... |
|
46 * // when all data has been decrypted, close decryption context |
|
47 * access->Close(); |
|
48 * delete access; |
|
49 * @endcode |
|
50 * |
|
51 */ |
|
52 NONSHARABLE_CLASS( CWmDrmAccess ) : public CBase |
|
53 { |
|
54 public: |
|
55 /** Constructors */ |
|
56 IMPORT_C static CWmDrmAccess* NewL(); |
|
57 IMPORT_C static CWmDrmAccess* NewLC(); |
|
58 |
|
59 /** Destructor */ |
|
60 IMPORT_C virtual ~CWmDrmAccess(); |
|
61 |
|
62 /** |
|
63 * Initialises decryption context |
|
64 * This initialises decryption session for given WM DRM protected file. |
|
65 * |
|
66 * @param aHeader This parameter is for inputting header |
|
67 * of the given WM DRM protected file to be decrypted |
|
68 * to WM DRM system. |
|
69 * |
|
70 * |
|
71 * @return A Symbian OS error code, KErrNone on success. |
|
72 * |
|
73 * @see CWmDrmAccess::Close |
|
74 * |
|
75 */ |
|
76 IMPORT_C TInt Initialize( const TDesC8& aHeader ); |
|
77 |
|
78 |
|
79 /** |
|
80 * Decrypts encrypted data in place. |
|
81 * This is for decrypting data of the file, header of which is used |
|
82 * as initialisation parameter at CWmDrmAccess::Initialize. |
|
83 * |
|
84 * @param aBuffer This will contain data to be decrypted. |
|
85 * On successful completion, given data is |
|
86 * decrypted in aBuffer. |
|
87 * |
|
88 * @return A Symbian OS error code, KErrNone on success. |
|
89 * |
|
90 * One small sample describing the use of the function. |
|
91 * @code |
|
92 * RBuf8 buffer; |
|
93 * // ... |
|
94 * // Fetch encrypted data to buffer |
|
95 * FetchEncryptedData( buffer ); |
|
96 * |
|
97 * // Decrypt encrypted data. |
|
98 * TInt error = access->Decrypt( buffer ); |
|
99 * if ( !error ) |
|
100 * { |
|
101 * UseDecryptedData( buffer ); |
|
102 * } |
|
103 * @endcode |
|
104 * |
|
105 * @see CWmDrmAccess::Initialize |
|
106 * @see CWmDrmAccess::Close |
|
107 * |
|
108 */ |
|
109 IMPORT_C TInt Decrypt( TDes8& aBuffer ); |
|
110 |
|
111 |
|
112 /** |
|
113 * Closes decryption context. |
|
114 * |
|
115 * @return A Symbian OS error code, KErrNone on success. |
|
116 * |
|
117 * @see CWmDrmAccess::Initialize |
|
118 * |
|
119 */ |
|
120 IMPORT_C TInt Close(); |
|
121 |
|
122 private: |
|
123 /** Default constructor */ |
|
124 CWmDrmAccess(); |
|
125 /** Second phase constructor */ |
|
126 void ConstructL(); |
|
127 |
|
128 /** Internal interface to the WM DRM system */ |
|
129 CWmDrmAccessEcomInterface* iWmDrmAccessEcomInterface; |
|
130 |
|
131 }; |
|
132 #endif // _WMDRM_ACCESS_API_H_ |