|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 #if !defined (__APMFNDR_H__) |
|
17 #define __APMFNDR_H__ |
|
18 |
|
19 #if !defined(__E32BASE_H__) |
|
20 #include <e32base.h> |
|
21 #endif |
|
22 #if !defined(__F32FILE_H__) |
|
23 #include <f32file.h> |
|
24 #endif |
|
25 #if !defined(__APMREC_H__) |
|
26 #include <apmrec.h> |
|
27 #endif |
|
28 |
|
29 #include <babackup.h> |
|
30 |
|
31 /** |
|
32 @internalComponent |
|
33 */ |
|
34 |
|
35 // classes defined |
|
36 class CApaRecognizerDll; |
|
37 |
|
38 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
39 /** This is a special priority that overrides any user settings. Applications must |
|
40 have EWriteDeviceData to use this priority. If they have not then they will be |
|
41 downgraded to KDataTypePriorityNormal. |
|
42 |
|
43 @publishedPartner |
|
44 @released |
|
45 @see TDataTypeWithPriority */ |
|
46 const TInt32 KDataTypePrioritySystem = 0xFFF9; |
|
47 |
|
48 |
|
49 class CApaDataRecognizer : public CBase |
|
50 /** |
|
51 @internalTechnology |
|
52 */ |
|
53 { |
|
54 public: |
|
55 IMPORT_C TDataRecognitionResult RecognizeL(const TDesC& aName, const TDesC8& aBuffer); |
|
56 IMPORT_C TDataRecognitionResult RecognizeL(RFile& aFile, TInt aPreferredBufSize); |
|
57 IMPORT_C TBool RecognizeL(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType); |
|
58 IMPORT_C TBool RecognizeL(RFile& aFile, TInt aPreferredBufSize, const TDataType& aDataType); |
|
59 IMPORT_C ~CApaDataRecognizer(); |
|
60 IMPORT_C TInt PreferredBufSize() const; |
|
61 IMPORT_C void DataTypeL(CDataTypeArray& aArray); |
|
62 IMPORT_C void UpdateDataTypesL(); |
|
63 IMPORT_C TInt AcceptedConfidence() const; |
|
64 IMPORT_C void SetAcceptedConfidence(TInt aConfidence); |
|
65 inline void SetFilePassedByHandle(RFile* aFilePassedByHandle) {iFilePassedByHandle=aFilePassedByHandle;} |
|
66 inline RFile* FilePassedByHandle() {return iFilePassedByHandle;} |
|
67 protected: |
|
68 IMPORT_C CApaDataRecognizer(RFs& aFs); |
|
69 IMPORT_C void AddDataRecognizerTypeL(CApaDataRecognizerType* aDataRecognizerType); |
|
70 inline void AddDataRecognizerType(CApaDataRecognizerType* aDataRecognizerType); |
|
71 IMPORT_C TInt RemoveDataRecognizerType(const CApaDataRecognizerType* aDataRecognizerType); |
|
72 IMPORT_C void DestroyRecognizerList(); |
|
73 private: |
|
74 void AddDataTypeL(const TDataType& aDataType); |
|
75 TDataRecognitionResult RecognizeL(TDataToRecognize& aDataToRecognize); |
|
76 TBool RecognizeL(TDataToRecognize& aDataToRecognize, const TDataType& aDataType); |
|
77 TBool DoRecognize(CApaDataRecognizerType* aDataRecognizerType, TDataToRecognize& aDataToRecognize, const TDataType& aDataType, TInt& aError); |
|
78 protected: |
|
79 RFs& iFs; |
|
80 // iMaxBufferSize is mutable to allow modification by PreferredBufSize() which is const. |
|
81 mutable TInt iMaxBufferSize; |
|
82 private: |
|
83 IMPORT_C virtual void CApaDataRecognizer_Reserved_1(); // shouldn't be necessary as the class is @internalTechnology |
|
84 private: |
|
85 RPointerArray<CApaDataRecognizerType> iDataRecognizerList; |
|
86 RArray<TDataType> iDataArray; |
|
87 TInt iAcceptedConfidence; |
|
88 TDataRecognitionResult iResult; |
|
89 RFile* iFilePassedByHandle; |
|
90 }; |
|
91 |
|
92 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
93 |
|
94 class CApaScanningDataRecognizer : public CApaDataRecognizer |
|
95 /** |
|
96 @publishedPartner |
|
97 @released |
|
98 */ |
|
99 { |
|
100 public: |
|
101 class TRecognizer |
|
102 { |
|
103 friend class CApaRecognizerDll; |
|
104 friend class CT_MimeStep; |
|
105 public: |
|
106 TRecognizer(HBufC* aName); |
|
107 inline const TDesC& Name() const; |
|
108 public: |
|
109 TUid iUid; |
|
110 TInt iDrive; |
|
111 TTime iModified; |
|
112 private: |
|
113 inline TRecognizer(); |
|
114 TRecognizer(const TRecognizer&); |
|
115 TRecognizer operator=(const TRecognizer&); |
|
116 private: |
|
117 HBufC* iName; |
|
118 }; |
|
119 typedef CArrayFixFlat<TRecognizer> CRecognizerArray; |
|
120 |
|
121 private: |
|
122 class CApaBackupOperationObserver : public CBase, public MBackupOperationObserver |
|
123 { |
|
124 public: |
|
125 CApaBackupOperationObserver(CApaScanningDataRecognizer& aRecognizer); |
|
126 ~CApaBackupOperationObserver(); |
|
127 void RegisterObserverL(); |
|
128 |
|
129 virtual void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes); |
|
130 TInt UpdateCounter() const; |
|
131 void SetUpdateCounter( TInt aValue ); |
|
132 private: |
|
133 CBaBackupSessionWrapper* iSession; |
|
134 CApaScanningDataRecognizer& iRecognizer; |
|
135 TInt iUpdateCounter; |
|
136 }; |
|
137 friend class CApaScanningDataRecognizer::CApaBackupOperationObserver; |
|
138 |
|
139 class CApaScanningDataRecognizerExtra : public CBase |
|
140 { |
|
141 private: |
|
142 CApaBackupOperationObserver* iObserver; |
|
143 TBool iRecognizersLoaded; |
|
144 friend class CApaScanningDataRecognizer; |
|
145 friend class CApaBackupOperationObserver; |
|
146 }; |
|
147 |
|
148 // |
|
149 public: |
|
150 IMPORT_C static CApaScanningDataRecognizer* NewL(RFs& aFs); |
|
151 IMPORT_C static CApaScanningDataRecognizer* NewL(RFs& aFs, TBool aLoadDataRecognizers); |
|
152 IMPORT_C ~CApaScanningDataRecognizer(); |
|
153 IMPORT_C void ScanForRecognizersL(); |
|
154 IMPORT_C TInt RecognizerCount(); |
|
155 IMPORT_C CRecognizerArray* RecognizerListLC()const; |
|
156 IMPORT_C const TRecognizer& operator[](TInt aIndex)const; |
|
157 IMPORT_C TInt UpdateCounter()const; |
|
158 IMPORT_C void LoadRecognizersL(); |
|
159 IMPORT_C void UnloadRecognizers(); |
|
160 |
|
161 protected: |
|
162 IMPORT_C CApaScanningDataRecognizer(RFs& aFs); |
|
163 IMPORT_C void ConstructL(); |
|
164 private: |
|
165 void ConstructL(TBool aLoadDataRecognizers); |
|
166 void ScanDriveL(TInt aDriveNum); |
|
167 void LoadRecognizerL(const TDesC& aFullName,TUid aUid, const TTime& aTime); |
|
168 TInt RemoveRecognizer(CApaRecognizerDll* aDll); |
|
169 void LoadEcomRecognizerL(TDriveUnit& aDrive,TUid aUid); |
|
170 void ScanForEcomRecognizersL(); |
|
171 public: |
|
172 IMPORT_C void SetEcomRecognizersFromListL(const CRecognizerArray& aList); |
|
173 IMPORT_C void SetEcomRecognizerL(const TRecognizer& aRecognizer); |
|
174 private: |
|
175 friend class CApaBackupObserver; |
|
176 RPointerArray<CApaRecognizerDll> iRecognizerLib; |
|
177 CApaScanningDataRecognizerExtra* iExtra; |
|
178 }; |
|
179 |
|
180 //gmahe. This is not moved. Because it is not possible to forward declare |
|
181 //the nested class used here - CApaScanningDataRecognizer::TRecognizer. |
|
182 |
|
183 class CApaRecognizerDll : public CBase |
|
184 /** |
|
185 @internalTechnology |
|
186 */ |
|
187 { |
|
188 public: |
|
189 CApaRecognizerDll(HBufC* aName); |
|
190 ~CApaRecognizerDll(); // closes lib and deletes next |
|
191 public: |
|
192 enum TPresence { ENotPresent, EIsPresent, ESuperseded }; |
|
193 public: |
|
194 RLibrary iLibrary; |
|
195 CApaRecognizerDll* iNext; |
|
196 CApaScanningDataRecognizer::TRecognizer iId; // cached so that this data can be accessed from other threads (RLibrary cant be used in this case) |
|
197 CApaDataRecognizerType* iRec; // not ownership |
|
198 TPresence iPresent; |
|
199 TInt iVersion; |
|
200 }; |
|
201 |
|
202 // |
|
203 // inlines |
|
204 // |
|
205 |
|
206 inline const TDesC& CApaScanningDataRecognizer::TRecognizer::Name() const |
|
207 { |
|
208 return *iName; |
|
209 } |
|
210 |
|
211 inline CApaScanningDataRecognizer::TRecognizer::TRecognizer() |
|
212 { |
|
213 } |
|
214 |
|
215 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
216 // Deprecated - Use CApaDataRecognizer::AddDataRecognizerTypeL instead |
|
217 // as adding a concrete recognizer into the list could leave. |
|
218 /** |
|
219 @deprecated 7.0s |
|
220 */ |
|
221 inline void CApaDataRecognizer::AddDataRecognizerType(CApaDataRecognizerType* aDataRecognizerType) |
|
222 { |
|
223 AddDataRecognizerTypeL(aDataRecognizerType); |
|
224 } |
|
225 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
226 |
|
227 #endif |