|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Declaration of the ROCHCAFInterface class |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 #ifndef ROCHCAFINTERFACE_H |
|
20 #define ROCHCAFINTERFACE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <caf/importfile.h> |
|
24 #include <caf/supplier.h> |
|
25 #include <caf/supplieroutputfile.h> |
|
26 #include <caf/metadataarray.h> |
|
27 #include <caf/metadata.h> |
|
28 #include <caf/caferr.h> |
|
29 |
|
30 |
|
31 enum TROCHErrorReason { |
|
32 EPanicInvalidCafState = 1 |
|
33 |
|
34 }; |
|
35 |
|
36 using namespace ContentAccess; |
|
37 |
|
38 |
|
39 /** |
|
40 Content Access Framework (CAF) Wrapper class. |
|
41 Provides encapsulation of the CAF functionality required by RO Content Handler. |
|
42 The in source documentation refers to a CAF session. The following pseudocode |
|
43 clarifies the concept of a CAF session. |
|
44 @code |
|
45 BEGIN |
|
46 WHILE processing RO |
|
47 Receive MIME header Content-Type |
|
48 Pass to CAF with RegisterL(Content-Type) |
|
49 IF Registered() |
|
50 Add MIME header metadata to ROCHCAFInterface class using AddToMetaDataL(metadata) |
|
51 ENDIF |
|
52 Detect start of MIME data section |
|
53 If CAF Registered() |
|
54 //BEGIN CAF session |
|
55 PrepareProcessingL() |
|
56 Create file handle for attachment write |
|
57 GetSuggestedAttachmentFileName(filename) |
|
58 StartProcessing(filename,filepath,file handle) |
|
59 WriteData() // Undecoded 1-N buffers in state machine |
|
60 Detect end of MIME data section |
|
61 WriteDataComplete() |
|
62 EndProcessingL() |
|
63 //END CAF Session |
|
64 ELSE |
|
65 Default behaviour |
|
66 ENDIF |
|
67 ENDWHILE |
|
68 END |
|
69 @endcode |
|
70 @internalComponent |
|
71 */ |
|
72 class CROCHCAFInterface : public CBase |
|
73 { |
|
74 public: |
|
75 IMPORT_C CROCHCAFInterface(RFs& aFs); |
|
76 IMPORT_C virtual ~CROCHCAFInterface(); |
|
77 IMPORT_C void RegisterL(const TDesC8& aMimeLine); |
|
78 IMPORT_C void Deregister(); |
|
79 IMPORT_C void AddToMetaDataL(const TDesC8& aMimeLine); |
|
80 IMPORT_C void AddToMetaDataL(const TDesC8& aField, const TDesC8& aData); |
|
81 IMPORT_C void EndProcessingL(); |
|
82 IMPORT_C void PrepareProcessingL(); |
|
83 IMPORT_C void WriteDataL(const TDesC8& aData); |
|
84 IMPORT_C TBool Registered() const; |
|
85 IMPORT_C TBool Processing() const; |
|
86 IMPORT_C TInt GetSuggestedAttachmentFileName(TDes& aFileName) const; |
|
87 IMPORT_C void StartProcessing(const TDesC& aDefaultAttachmentFileName,const TDesC& aAttachmentFilePath,RFile& aStartFile); |
|
88 |
|
89 private: |
|
90 void NewFileL(); |
|
91 void WriteDataCompleteL(); |
|
92 private: |
|
93 /** A CAF class instance. Initialised prior to data write */ |
|
94 CImportFile* iImportFile; |
|
95 /** A CAF class instance. Used to register Content-type with CAF */ |
|
96 CSupplier* iSupplier; |
|
97 /** Store for the MIME Content-type */ |
|
98 HBufC8* iContentType; |
|
99 /** A CAF class instance. Stores MIME header attribute/value pairs. Appended by AddToMetaData() */ |
|
100 CMetaDataArray* iMetaData; |
|
101 /** Stores the filepath for the current CAF session. Initialised by StartProcessing()*/ |
|
102 TBuf<KMaxPath> iAttachmentFilePath; |
|
103 /** If open, handle is used for the next attachment file required by CAF. Initialised by StartProcessing() */ |
|
104 RFile iAttachmentFile; |
|
105 /** The localised default filename . Initialised by StartProcessing() */ |
|
106 TPtrC iDefaultAttachmentFileName; |
|
107 /** Reference to instantiators file server session */ |
|
108 RFs& iFsSession; |
|
109 |
|
110 }; |
|
111 |
|
112 #endif // ROCHCAFInterface_H |