1 biodb.h |
1 // Copyright (c) 1999-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __BIODB_H__ |
|
17 #define __BIODB_H__ |
|
18 |
|
19 #include <bif.h> // the bif reader |
|
20 #include <f32file.h> |
|
21 |
|
22 class CBifEntry; |
|
23 |
|
24 /** UID of the BIODB.DLL. */ |
|
25 const TUid KUidBioDBDll ={0x10005542}; |
|
26 |
|
27 /** Buffer to hold BIF identification text. */ |
|
28 typedef TBuf<KMaxBioIdText> TBioMsgIdText; |
|
29 |
|
30 /** BIO information file (BIF) database. |
|
31 |
|
32 This class reads the installed BIF files and allows information from them |
|
33 to be easily extracted. |
|
34 |
|
35 @see BIO_INFO_FILE |
|
36 @publishedAll |
|
37 @released |
|
38 */ |
|
39 class CBIODatabase : public CBase |
|
40 { |
|
41 public: |
|
42 /** Search methods. */ |
|
43 enum TSearchList |
|
44 { |
|
45 /** Begin search from the start. */ |
|
46 EStart, |
|
47 /** Begin search from the last index position. */ |
|
48 ENext |
|
49 }; |
|
50 public: |
|
51 IMPORT_C static CBIODatabase* NewLC(RFs& afileSystem); |
|
52 IMPORT_C static CBIODatabase* NewL(RFs& afileSystem); |
|
53 IMPORT_C ~CBIODatabase(); |
|
54 |
|
55 public: |
|
56 // BIF files contain all the information that needs to be registered |
|
57 // for each BIO Message type |
|
58 |
|
59 // Completely refresh the database will all the BIF Files in the |
|
60 // default directory |
|
61 IMPORT_C void AddAllBifsL(RFs& afileSystem); |
|
62 |
|
63 // Add one bifFile using the file name, then using Neil's handy |
|
64 // class to read it |
|
65 // This will add the Parser |
|
66 IMPORT_C void AddBifL(CBioInfoFileReader* aBifReader); |
|
67 IMPORT_C void RemoveBifL(TUid aMsgID); |
|
68 IMPORT_C void RemoveBifL(TInt aIndex); |
|
69 |
|
70 // BIO Messages are determined to of a BIO type if we have the BIO |
|
71 // Parser identified by a WAP/NBS port, IANA MIME type or a Pattern |
|
72 IMPORT_C TInt BIOCount(); |
|
73 |
|
74 // Get the BioEntry at this index |
|
75 // Return Index if found, NULL if not |
|
76 IMPORT_C const CArrayFix<TBioMsgId>* BIOEntryLC(TInt index); |
|
77 |
|
78 |
|
79 // Get the whole bif file class |
|
80 IMPORT_C const CBioInfoFileReader& BifReader(TInt aIndex) const; |
|
81 |
|
82 // Get the BIO Entry based on what type it is, pos indicates where to start looking |
|
83 // after, and will get updated to current pos |
|
84 IMPORT_C const CArrayFix<TBioMsgId>* BioEntryByTypeLC( |
|
85 TSearchList aSearchType, |
|
86 TBioMsgIdType portType, |
|
87 TInt& rIndex); |
|
88 |
|
89 IMPORT_C void GetBioIndexWithMsgIDL(TUid aMsgID, TInt& rIndex); |
|
90 |
|
91 // Get the BioMessageID for the Index |
|
92 IMPORT_C void GetBioMsgID(TInt aIndex, TUid& rMsgID); |
|
93 |
|
94 // Get the BioParserName for the Index |
|
95 IMPORT_C const TPtrC GetBioParserName(TInt aIndex); |
|
96 |
|
97 // Get the BioParserName for the BioMessageID |
|
98 IMPORT_C const TPtrC GetBioParserNameL(TUid aMsgID); |
|
99 |
|
100 // Get the ControlID for the Index |
|
101 IMPORT_C void GetBioControlID(TInt aIndex, TUid& rControlID); |
|
102 |
|
103 // Get the ControlID for the BioMessageID |
|
104 IMPORT_C void GetBioControlIDL(TUid aMsgID, TUid& rControlID); |
|
105 |
|
106 IMPORT_C const TPtrC GetBioControlName(TInt aIndex); |
|
107 IMPORT_C const TPtrC GetBioControlNameL(TUid aMsgID); |
|
108 |
|
109 // Get the String Extension for the BioMessageID |
|
110 IMPORT_C const TPtrC GetFileExtL(TUid aMsgID); |
|
111 |
|
112 IMPORT_C void GetDefaultSendBearerL(TUid aBioUID, TBioMsgId& rBioMsgIdentifier); |
|
113 IMPORT_C void GetDefaultSendBearerTypeL(TUid aBioUID, TBioMsgIdType& rPortType); |
|
114 IMPORT_C void GetDefaultSendBearerByTypeL(TUid aBioUID, TBioMsgIdType aPortType, TBioMsgId& rBioMsgIdentifier); |
|
115 |
|
116 // BIO Messages are determined to of a BIO type if we have the BIO |
|
117 // Parser identified by a WAP/NBS port, IANA MIME type or a Pattern |
|
118 // Return an Index |
|
119 |
|
120 // Get the Port# or Identifying string for sending |
|
121 IMPORT_C void GetPortNumberL(TUid aMsgID, TBioMsgIdType aPortType, TInt& aPortNumber); |
|
122 IMPORT_C void GetIdentifierTextL(TUid aMsgID, TBioMsgIdType aPortType, TBioMsgIdText& aText); |
|
123 |
|
124 // Test to see if this is a BioMessage |
|
125 // Pass in the type ... if its NBS or IANA pass in the string pattern |
|
126 // if its WAP or SecureWap, pass in the port number |
|
127 // return kErrNone if success, kErrNotFound if it fails |
|
128 IMPORT_C TInt IsBioMessageL(TBioMsgIdType aPortType, const TDesC& aPattern, TUint16 aPort, TUid& rBioMsgUID); |
|
129 |
|
130 IMPORT_C TInt IsBioMessageL(TBioMsgId bioMessageData, TUid& rBioMsgUID); |
|
131 |
|
132 private: |
|
133 CBIODatabase(); |
|
134 void ConstructL(RFs& afileSystem); |
|
135 |
|
136 private: |
|
137 //Utilities |
|
138 void GetTransportIDL(TInt aIndex, TBioMsgIdType aPortType, TBioMsgId& aBioMsgID); |
|
139 TBool IsLanguageFileL(const TDesC& aFileName, TInt& aExtLength) const; |
|
140 // If Persistence is required... |
|
141 // void InternalizeL(RReadStream& aStream); |
|
142 // void ExternalizeL(RWriteStream& aStream) const; |
|
143 |
|
144 private: |
|
145 CArrayPtrFlat<CBioInfoFileReader>* iBifReaders; |
|
146 |
|
147 }; |
|
148 |
|
149 /** Callback interface implemented by classes to receive notifications of BIF files |
|
150 changes from CBifChangeObserver. |
|
151 |
|
152 @publishedPartner |
|
153 @released |
|
154 */ |
|
155 class MBifChangeObserver |
|
156 { |
|
157 public: |
|
158 /** BIF change events. */ |
|
159 enum TBifChangeEvent |
|
160 { |
|
161 /** Unknown change. */ |
|
162 EBifChangeUnknown = 0, |
|
163 /** BIF added. */ |
|
164 EBifAdded, |
|
165 /** BIF deleted. */ |
|
166 EBifDeleted, |
|
167 /** BIF changed. */ |
|
168 EBifChanged |
|
169 }; |
|
170 |
|
171 public: |
|
172 /** Called when a BIF change occurs. |
|
173 |
|
174 @param aEvent Change event type |
|
175 @param aBioID BIO message type of changed BIF */ |
|
176 virtual void HandleBifChangeL(TBifChangeEvent aEvent, TUid aBioID)=0; |
|
177 }; |
|
178 |
|
179 /** Active object that watches for changes made to the installed BIF files. |
|
180 |
|
181 @publishedPartner |
|
182 @released |
|
183 */ |
|
184 class CBifChangeObserver : public CActive |
|
185 { |
|
186 public: |
|
187 IMPORT_C static CBifChangeObserver* NewL(MBifChangeObserver& aObserver, RFs& aFs); |
|
188 IMPORT_C void Start(); |
|
189 ~CBifChangeObserver(); |
|
190 |
|
191 static void CleanupBifArray(TAny* aBifArray); |
|
192 |
|
193 private: |
|
194 // from CActive |
|
195 virtual void RunL(); |
|
196 virtual void DoCancel(); |
|
197 |
|
198 private: |
|
199 CBifChangeObserver(MBifChangeObserver& aObserver, RFs& aFs); |
|
200 void ConstructL(); |
|
201 |
|
202 void NotifyObserverL(); |
|
203 void WaitForFileNotification(); |
|
204 void DoRunL(); |
|
205 void CopyEntriesL(const CDir& aDir, CArrayFixFlat<TEntry>& aEntries); |
|
206 TBool CompareReaders(const CBioInfoFileReader& aReader1, const CBioInfoFileReader& aReader2) const; |
|
207 |
|
208 TInt FindEntry(const CBifEntry& aBifEntry, const RPointerArray<CBifEntry>& aEntries, TInt& aIndex) const; |
|
209 |
|
210 private: |
|
211 MBifChangeObserver& iChangeObserver; |
|
212 RFs& iFs; |
|
213 |
|
214 RPointerArray<CBifEntry> iEntries; |
|
215 |
|
216 CBIODatabase* iBioDB; |
|
217 RTimer iTimer; |
|
218 TInt iRetryCount; |
|
219 }; |
|
220 |
|
221 #endif // __BIODB_H__ |