|
1 /* |
|
2 * Copyright (c) 2002-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __APFMIMECONTENTPOLICY_H__ |
|
21 #define __APFMIMECONTENTPOLICY_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 class CApfMimeContentPolicyImpl; |
|
26 class RFile; |
|
27 class RFs; |
|
28 |
|
29 /** |
|
30 CApfMimeContentPolicy is utility class for checking MIME types and |
|
31 file extensions against closed content list. It also provides a function |
|
32 for checking if a given file is a DRM envelope, and a convinience function |
|
33 which combines all the checks mentioned above. |
|
34 |
|
35 Usage: |
|
36 |
|
37 @code |
|
38 TFileName fileName = <name of the file to be checked> |
|
39 TUid uid; |
|
40 TDataType recData; |
|
41 |
|
42 CApfMimeContentPolicy *ccp = CApfMimeContentPolicy::NewLC(); |
|
43 |
|
44 if (ccp->IsDRMEnvelope( fileName )) |
|
45 { |
|
46 // Whatever needs to be done if file is DRM envelope. |
|
47 } |
|
48 |
|
49 // Check file extension. |
|
50 TParse parser; |
|
51 parser.Set(fileName, NULL, NULL); |
|
52 if (IsClosedExtension(parser.Ext())) |
|
53 { |
|
54 // Do what needs to be done if closed content. |
|
55 } |
|
56 |
|
57 iLs.AppForDocument(fileName, uid, recData); // Get MIME type for file. |
|
58 |
|
59 if (ccp->IsClosedType(recData.Des()) // Check if this mime type is closed. |
|
60 { |
|
61 // Whatever needs to be done if type is closed. |
|
62 } |
|
63 |
|
64 // Or you can achieve same result calling a convinience function |
|
65 // which combines all the steps above: |
|
66 if (cpp->IsClosedFileL( fileName ); |
|
67 { |
|
68 // Do whatever has to be done if file is closed. |
|
69 } |
|
70 |
|
71 // Don't forget to clean up. |
|
72 CleanupStack::PopAndDestroy(); // ccp |
|
73 @endcode |
|
74 |
|
75 @publishedPartner |
|
76 @released |
|
77 */ |
|
78 class CApfMimeContentPolicy : public CBase |
|
79 { |
|
80 public: // Constructors and destructor |
|
81 IMPORT_C static CApfMimeContentPolicy* NewL(); |
|
82 IMPORT_C static CApfMimeContentPolicy* NewLC(); |
|
83 IMPORT_C static CApfMimeContentPolicy* NewL(RFs& aFs); |
|
84 IMPORT_C static CApfMimeContentPolicy* NewLC(RFs& aFs); |
|
85 IMPORT_C ~CApfMimeContentPolicy(); |
|
86 public: // New functions |
|
87 IMPORT_C TBool IsClosedType(const TDesC& aMimeType); |
|
88 IMPORT_C TBool IsClosedExtension(const TDesC& aFileExtension); |
|
89 IMPORT_C TBool IsClosedFileL(const TDesC& aFileName); |
|
90 IMPORT_C TBool IsDRMEnvelopeL(const TDesC& aFileName); |
|
91 IMPORT_C TBool IsClosedFileL(RFile& aFileHandle); |
|
92 IMPORT_C TBool IsDRMEnvelopeL(RFile& aFileHandle); |
|
93 private: |
|
94 CApfMimeContentPolicy(); |
|
95 void ConstructL(); |
|
96 void ConstructL(RFs& aFs); |
|
97 private: |
|
98 CApfMimeContentPolicyImpl* iImpl; // Implementation. |
|
99 }; |
|
100 |
|
101 |
|
102 #endif // __APFMIMECONTENTPOLICY_H__ |