|
1 /* |
|
2 * Copyright (c) 2008 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: Active object for MetadataUtility |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef METADATABUFFERAGG_H |
|
20 #define METADATABUFFERAGG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 class CMetaDataUtilityBody; |
|
26 class MMDUChunkDataObserver; |
|
27 |
|
28 |
|
29 NONSHARABLE_CLASS(CMetaDataBufferAgg): public CActive |
|
30 { |
|
31 |
|
32 |
|
33 public: |
|
34 /** |
|
35 * Two-phased constructor. |
|
36 * @since 9.1 |
|
37 * @param aMimeType The MIME type |
|
38 * @param aObserver should not be NULL |
|
39 * @return A pointer to a new instance of this class |
|
40 */ |
|
41 static CMetaDataBufferAgg* NewL( CMetaDataUtilityBody* aBody, |
|
42 TDesC8& aMimeType, |
|
43 MMDUChunkDataObserver& aObserver); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 virtual ~CMetaDataBufferAgg(); |
|
49 |
|
50 /** |
|
51 * Process the chunk data. |
|
52 * @since 5.1 |
|
53 * Max size of buffer passed in is N bytes for performance optimization |
|
54 * Buffer overflow (out of memory) results in callback with error. |
|
55 * invalid chunk data results in callback with error |
|
56 * parsing APIs are invoked before callback is received results in 0 count or empty container |
|
57 * parsing APIs are invoked after callback is received results in positive count and full container |
|
58 * @param aChunk the data chunk to be processed |
|
59 * @return error value |
|
60 * KErrNone |
|
61 * KErrNotReady |
|
62 */ |
|
63 TInt RequestProcessChunkData( TDesC8& aChunk, TBool aFinalChunk ); |
|
64 |
|
65 /** |
|
66 * Parse the chunk data. |
|
67 * @since 5.1 |
|
68 * parsing APIs are invoked before callback is received results in 0 count or empty container |
|
69 * parsing APIs are invoked after callback is received results in positive count and full container |
|
70 * @return error value |
|
71 * KErrNone |
|
72 * KErrNotReady |
|
73 */ |
|
74 TInt RequestParseChunkData(); |
|
75 |
|
76 void ReadyToGo(); |
|
77 |
|
78 /** |
|
79 * Do Cancel |
|
80 * @since 9.1 |
|
81 */ |
|
82 void DoCancel(); |
|
83 |
|
84 /** |
|
85 * Run for Active Object |
|
86 * @since 9.1 |
|
87 */ |
|
88 void RunL(); |
|
89 |
|
90 private: |
|
91 |
|
92 private: |
|
93 enum TAggregateState |
|
94 { |
|
95 EFindIdentifier, |
|
96 ECalculateSize, |
|
97 ECollectData, |
|
98 EParseData, |
|
99 EParseComplete |
|
100 }; |
|
101 |
|
102 |
|
103 void ConstructL(const TDesC8& aMimeType ); |
|
104 CMetaDataBufferAgg( CMetaDataUtilityBody* aBody, |
|
105 MMDUChunkDataObserver& aObserver ); |
|
106 |
|
107 void FindMetaDataIdentifierL( TDesC8* aBuf ); |
|
108 void CalculateMetaDataSizeL( TDesC8* aBuf ); |
|
109 void ComputeSize( TDesC8* aBuf, TInt aOffset ); |
|
110 void CollectMetaDataL( TDesC8* aBuf ); |
|
111 void ProcessPreviousChunkL( TDesC8* aBuf ); |
|
112 void DoCallback( TInt aError ); |
|
113 void CopyBufferL(RBuf8* aDes, TUint8* aPtr, TInt aSize ); |
|
114 void AppendBufferL(RBuf8* aDes, TUint8* aPtr, TInt aSize ); |
|
115 |
|
116 |
|
117 private: // data |
|
118 CMetaDataUtilityBody* iBody; |
|
119 MMDUChunkDataObserver& iObserver; |
|
120 TAggregateState iState; |
|
121 RBuf8 iMimeType; |
|
122 TDesC8* iUserChunk; |
|
123 RBuf8 iPrevBuf; // to save previous data |
|
124 RBuf8 iMetaDataBuf; |
|
125 TBool iFinalChunk; |
|
126 TInt iMetaDataSize; |
|
127 |
|
128 }; |
|
129 |
|
130 #endif // METADATABUFFERAGG_H |