|
1 /* |
|
2 * Copyright (c) 2006-2007 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: DRM Utility base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CDRMUTILITY_H |
|
20 #define CDRMUTILITY_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <drmutilitytypes.h> |
|
25 |
|
26 namespace DRM |
|
27 { |
|
28 |
|
29 |
|
30 /** |
|
31 * DRM Utility base class |
|
32 * |
|
33 * Provides essential information about the DRM protection of a file |
|
34 * and the name of the CAF agent to be used without using CAF. |
|
35 * |
|
36 * @lib drmutility.lib |
|
37 * @since S60 v5.0 |
|
38 */ |
|
39 NONSHARABLE_CLASS( CDrmUtility ) : public CBase |
|
40 { |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 * Creates a new CDrmUtility -object and leaves it in the cleanup stack |
|
46 * |
|
47 * @since S60 5.0 |
|
48 * @return A functional CDrmUtility -object |
|
49 * @leave System wide or DRM specific error code |
|
50 */ |
|
51 IMPORT_C static CDrmUtility* NewLC(); |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * Creates a new CDrmUtility -object |
|
56 * |
|
57 * @since S60 5.0 |
|
58 * @return A functional CDrmUtility -object |
|
59 * @leave System wide or DRM specific error code |
|
60 */ |
|
61 IMPORT_C static CDrmUtility* NewL(); |
|
62 |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 virtual ~CDrmUtility(); |
|
68 |
|
69 /** |
|
70 * Checks whether the given file belongs to a DRM protected |
|
71 * content file |
|
72 * |
|
73 * @since S60 5.0 |
|
74 * @param[in] aFileHandle Open filehandle to the file to be examined |
|
75 * @param[out] aAgent Name of the agent that handles the file or |
|
76 * KNullDesC if no agent is found |
|
77 * @param[out] aProtected EProtected, if the default content object is |
|
78 * protected |
|
79 * EUnprotected, if the default content object |
|
80 * is not protected |
|
81 * |
|
82 * @return ETrue, if the content is handled by a DRM agent |
|
83 * EFalse, if the content is not handled by a DRM agent |
|
84 * |
|
85 * @leave KErrBadHandle if the file handle is invalid |
|
86 * System wide or DRM specific error code |
|
87 */ |
|
88 IMPORT_C TBool GetDrmInfoL( RFile& aFileHandle, |
|
89 TPtrC& aAgent, |
|
90 TDrmProtectionStatus& aProtected ) const; |
|
91 |
|
92 /** |
|
93 * Checks whether the given buffer belongs to a DRM protected |
|
94 * content file |
|
95 * |
|
96 * @since S60 5.0 |
|
97 * @param[in] aContent Memory buffer containing the content (or part |
|
98 * of it) |
|
99 * @param[out] aAgent Name of the agent that handles the file or |
|
100 * KNullDesC if no agent is found |
|
101 * @param[out] aProtected EProtected, if the default content object is |
|
102 * protected |
|
103 * EUnprotected, if the default content object |
|
104 * is not protected |
|
105 * EUnknown, if there is not enough data to |
|
106 * determine the protection status |
|
107 * |
|
108 * @return ETrue, if the content is handled by a DRM agent |
|
109 * EFalse, if the content is not handled by a DRM agent |
|
110 * |
|
111 * @leave KErrArgument if there is not sufficient amount of data |
|
112 * provided to the function to determine if the buffer has drm |
|
113 * data |
|
114 * System wide or DRM specific error code |
|
115 */ |
|
116 IMPORT_C TBool GetDrmInfoL( const TDesC8& aContent, |
|
117 TPtrC& aAgent, |
|
118 TDrmProtectionStatus& aProtected) const; |
|
119 |
|
120 /** |
|
121 * Checks whether the given file is a drm content file and if it's default |
|
122 * content object is protected or not |
|
123 * |
|
124 * @since S60 5.0 |
|
125 * @param[in] aFileHandle Open filehandle to the file to be examined |
|
126 * |
|
127 * @return ETrue, if the default content object is a drm content and |
|
128 * is protected otherwise EFalse |
|
129 * |
|
130 * @leave KErrBadHandle if the file handle is invalid |
|
131 * System wide or DRM specific error code |
|
132 */ |
|
133 IMPORT_C TBool IsProtectedL( RFile& aFileHandle ) const; |
|
134 |
|
135 |
|
136 /** |
|
137 * Checks whether the given buffer is a drm content and if it's default |
|
138 * content object is protected or not |
|
139 * |
|
140 * @since S60 5.0 |
|
141 * @param[in] aContent Memory buffer containing the content (or part |
|
142 * of it) |
|
143 * |
|
144 * @return ETrue, if the default content object is a drm content and |
|
145 * is protected otherwise EFalse |
|
146 * |
|
147 * @leave KErrArgument, if there is not sufficient amount of data |
|
148 * provided to the function to determine if the buffer has drm |
|
149 * data and the protection status |
|
150 * System wide or DRM specific error code |
|
151 */ |
|
152 IMPORT_C TBool IsProtectedL( const TDesC8& aContent ) const; |
|
153 |
|
154 |
|
155 /** |
|
156 * Checks what agent handles the given drm content file |
|
157 * |
|
158 * @since S60 5.0 |
|
159 * @param[in] aFileHandle Open filehandle to the file to be examined |
|
160 * @param[out] aAgent Name of the agent that handles the file |
|
161 * |
|
162 * @return ETrue, if the content is handled by a DRM agent |
|
163 * EFalse, if the content is not handled by a DRM agent |
|
164 * |
|
165 * @leave KErrBadHandle if the file handle is invalid |
|
166 * System wide or DRM specific error code |
|
167 */ |
|
168 IMPORT_C TBool GetAgentL( RFile& aFileHandle, |
|
169 TPtrC& aAgent ) const; |
|
170 |
|
171 /** |
|
172 * Checks what agent handles the given drm content buffer |
|
173 * |
|
174 * @since S60 5.0 |
|
175 * @param[in] aContent Memory buffer containg the file (or part of it) |
|
176 * @param[out] aAgent Name of the agent that handles the file |
|
177 * |
|
178 * @return ETrue, if the content is handled by a DRM agent |
|
179 * EFalse, if the content is not handled by a DRM agent |
|
180 * |
|
181 * @leave KErrArgument, if there is not sufficient amount of data |
|
182 * provided to the function to determine if the buffer has drm |
|
183 * data |
|
184 * System wide or DRM specific error code |
|
185 */ |
|
186 IMPORT_C TBool GetAgentL( const TDesC8& aContent, |
|
187 TPtrC& aAgent ) const; |
|
188 |
|
189 /** |
|
190 * Checks if the given file handle is valid |
|
191 * |
|
192 * @since S60 5.0 |
|
193 * @param[in] aFileHandle Filehandle to be examined |
|
194 * |
|
195 * @return None |
|
196 * |
|
197 * @leave KErrBadHandle if the filehandle is invalid |
|
198 */ |
|
199 IMPORT_C void CheckFileHandleL( RFile& aFileHandle ) const; |
|
200 |
|
201 private: |
|
202 /** |
|
203 * C++ default constructor. |
|
204 */ |
|
205 CDrmUtility(); |
|
206 |
|
207 // Oma based extensions |
|
208 void FetchOmaBasedInfoL(); |
|
209 |
|
210 void ConstructL(); |
|
211 |
|
212 HBufC* iOmaBasedAgentName; |
|
213 HBufC8* iOmaBasedMimeType; |
|
214 |
|
215 }; |
|
216 } |
|
217 |
|
218 |
|
219 #endif // CDRMUTILITY_H |