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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <bif.h> // the bif reader
24 /** UID of the BIODB.DLL. */
25 const TUid KUidBioDBDll ={0x10005542};
27 /** Buffer to hold BIF identification text. */
28 typedef TBuf<KMaxBioIdText> TBioMsgIdText;
30 /** BIO information file (BIF) database.
32 This class reads the installed BIF files and allows information from them
33 to be easily extracted.
39 class CBIODatabase : public CBase
42 /** Search methods. */
45 /** Begin search from the start. */
47 /** Begin search from the last index position. */
51 IMPORT_C static CBIODatabase* NewLC(RFs& afileSystem);
52 IMPORT_C static CBIODatabase* NewL(RFs& afileSystem);
53 IMPORT_C ~CBIODatabase();
56 // BIF files contain all the information that needs to be registered
57 // for each BIO Message type
59 // Completely refresh the database will all the BIF Files in the
61 IMPORT_C void AddAllBifsL(RFs& afileSystem);
63 // Add one bifFile using the file name, then using Neil's handy
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);
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();
74 // Get the BioEntry at this index
75 // Return Index if found, NULL if not
76 IMPORT_C const CArrayFix<TBioMsgId>* BIOEntryLC(TInt index);
79 // Get the whole bif file class
80 IMPORT_C const CBioInfoFileReader& BifReader(TInt aIndex) const;
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,
89 IMPORT_C void GetBioIndexWithMsgIDL(TUid aMsgID, TInt& rIndex);
91 // Get the BioMessageID for the Index
92 IMPORT_C void GetBioMsgID(TInt aIndex, TUid& rMsgID);
94 // Get the BioParserName for the Index
95 IMPORT_C const TPtrC GetBioParserName(TInt aIndex);
97 // Get the BioParserName for the BioMessageID
98 IMPORT_C const TPtrC GetBioParserNameL(TUid aMsgID);
100 // Get the ControlID for the Index
101 IMPORT_C void GetBioControlID(TInt aIndex, TUid& rControlID);
103 // Get the ControlID for the BioMessageID
104 IMPORT_C void GetBioControlIDL(TUid aMsgID, TUid& rControlID);
106 IMPORT_C const TPtrC GetBioControlName(TInt aIndex);
107 IMPORT_C const TPtrC GetBioControlNameL(TUid aMsgID);
109 // Get the String Extension for the BioMessageID
110 IMPORT_C const TPtrC GetFileExtL(TUid aMsgID);
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);
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
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);
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);
130 IMPORT_C TInt IsBioMessageL(TBioMsgId bioMessageData, TUid& rBioMsgUID);
134 void ConstructL(RFs& afileSystem);
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;
145 CArrayPtrFlat<CBioInfoFileReader>* iBifReaders;
149 /** Callback interface implemented by classes to receive notifications of BIF files
150 changes from CBifChangeObserver.
155 class MBifChangeObserver
158 /** BIF change events. */
161 /** Unknown change. */
162 EBifChangeUnknown = 0,
172 /** Called when a BIF change occurs.
174 @param aEvent Change event type
175 @param aBioID BIO message type of changed BIF */
176 virtual void HandleBifChangeL(TBifChangeEvent aEvent, TUid aBioID)=0;
179 /** Active object that watches for changes made to the installed BIF files.
184 class CBifChangeObserver : public CActive
187 IMPORT_C static CBifChangeObserver* NewL(MBifChangeObserver& aObserver, RFs& aFs);
188 IMPORT_C void Start();
189 ~CBifChangeObserver();
191 static void CleanupBifArray(TAny* aBifArray);
196 virtual void DoCancel();
199 CBifChangeObserver(MBifChangeObserver& aObserver, RFs& aFs);
202 void NotifyObserverL();
203 void WaitForFileNotification();
205 void CopyEntriesL(const CDir& aDir, CArrayFixFlat<TEntry>& aEntries);
206 TBool CompareReaders(const CBioInfoFileReader& aReader1, const CBioInfoFileReader& aReader2) const;
208 TInt FindEntry(const CBifEntry& aBifEntry, const RPointerArray<CBifEntry>& aEntries, TInt& aIndex) const;
211 MBifChangeObserver& iChangeObserver;
214 RPointerArray<CBifEntry> iEntries;
216 CBIODatabase* iBioDB;
221 #endif // __BIODB_H__