1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/biodb.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,221 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __BIODB_H__
1.20 +#define __BIODB_H__
1.21 +
1.22 +#include <bif.h> // the bif reader
1.23 +#include <f32file.h>
1.24 +
1.25 +class CBifEntry;
1.26 +
1.27 +/** UID of the BIODB.DLL. */
1.28 +const TUid KUidBioDBDll ={0x10005542};
1.29 +
1.30 +/** Buffer to hold BIF identification text. */
1.31 +typedef TBuf<KMaxBioIdText> TBioMsgIdText;
1.32 +
1.33 +/** BIO information file (BIF) database.
1.34 +
1.35 +This class reads the installed BIF files and allows information from them
1.36 +to be easily extracted.
1.37 +
1.38 +@see BIO_INFO_FILE
1.39 +@publishedAll
1.40 +@released
1.41 +*/
1.42 +class CBIODatabase : public CBase
1.43 + {
1.44 +public:
1.45 + /** Search methods. */
1.46 + enum TSearchList
1.47 + {
1.48 + /** Begin search from the start. */
1.49 + EStart,
1.50 + /** Begin search from the last index position. */
1.51 + ENext
1.52 + };
1.53 +public:
1.54 + IMPORT_C static CBIODatabase* NewLC(RFs& afileSystem);
1.55 + IMPORT_C static CBIODatabase* NewL(RFs& afileSystem);
1.56 + IMPORT_C ~CBIODatabase();
1.57 +
1.58 +public:
1.59 + // BIF files contain all the information that needs to be registered
1.60 + // for each BIO Message type
1.61 +
1.62 + // Completely refresh the database will all the BIF Files in the
1.63 + // default directory
1.64 + IMPORT_C void AddAllBifsL(RFs& afileSystem);
1.65 +
1.66 + // Add one bifFile using the file name, then using Neil's handy
1.67 + // class to read it
1.68 + // This will add the Parser
1.69 + IMPORT_C void AddBifL(CBioInfoFileReader* aBifReader);
1.70 + IMPORT_C void RemoveBifL(TUid aMsgID);
1.71 + IMPORT_C void RemoveBifL(TInt aIndex);
1.72 +
1.73 + // BIO Messages are determined to of a BIO type if we have the BIO
1.74 + // Parser identified by a WAP/NBS port, IANA MIME type or a Pattern
1.75 + IMPORT_C TInt BIOCount();
1.76 +
1.77 + // Get the BioEntry at this index
1.78 + // Return Index if found, NULL if not
1.79 + IMPORT_C const CArrayFix<TBioMsgId>* BIOEntryLC(TInt index);
1.80 +
1.81 +
1.82 + // Get the whole bif file class
1.83 + IMPORT_C const CBioInfoFileReader& BifReader(TInt aIndex) const;
1.84 +
1.85 + // Get the BIO Entry based on what type it is, pos indicates where to start looking
1.86 + // after, and will get updated to current pos
1.87 + IMPORT_C const CArrayFix<TBioMsgId>* BioEntryByTypeLC(
1.88 + TSearchList aSearchType,
1.89 + TBioMsgIdType portType,
1.90 + TInt& rIndex);
1.91 +
1.92 + IMPORT_C void GetBioIndexWithMsgIDL(TUid aMsgID, TInt& rIndex);
1.93 +
1.94 + // Get the BioMessageID for the Index
1.95 + IMPORT_C void GetBioMsgID(TInt aIndex, TUid& rMsgID);
1.96 +
1.97 + // Get the BioParserName for the Index
1.98 + IMPORT_C const TPtrC GetBioParserName(TInt aIndex);
1.99 +
1.100 + // Get the BioParserName for the BioMessageID
1.101 + IMPORT_C const TPtrC GetBioParserNameL(TUid aMsgID);
1.102 +
1.103 + // Get the ControlID for the Index
1.104 + IMPORT_C void GetBioControlID(TInt aIndex, TUid& rControlID);
1.105 +
1.106 + // Get the ControlID for the BioMessageID
1.107 + IMPORT_C void GetBioControlIDL(TUid aMsgID, TUid& rControlID);
1.108 +
1.109 + IMPORT_C const TPtrC GetBioControlName(TInt aIndex);
1.110 + IMPORT_C const TPtrC GetBioControlNameL(TUid aMsgID);
1.111 +
1.112 + // Get the String Extension for the BioMessageID
1.113 + IMPORT_C const TPtrC GetFileExtL(TUid aMsgID);
1.114 +
1.115 + IMPORT_C void GetDefaultSendBearerL(TUid aBioUID, TBioMsgId& rBioMsgIdentifier);
1.116 + IMPORT_C void GetDefaultSendBearerTypeL(TUid aBioUID, TBioMsgIdType& rPortType);
1.117 + IMPORT_C void GetDefaultSendBearerByTypeL(TUid aBioUID, TBioMsgIdType aPortType, TBioMsgId& rBioMsgIdentifier);
1.118 +
1.119 + // BIO Messages are determined to of a BIO type if we have the BIO
1.120 + // Parser identified by a WAP/NBS port, IANA MIME type or a Pattern
1.121 + // Return an Index
1.122 +
1.123 + // Get the Port# or Identifying string for sending
1.124 + IMPORT_C void GetPortNumberL(TUid aMsgID, TBioMsgIdType aPortType, TInt& aPortNumber);
1.125 + IMPORT_C void GetIdentifierTextL(TUid aMsgID, TBioMsgIdType aPortType, TBioMsgIdText& aText);
1.126 +
1.127 + // Test to see if this is a BioMessage
1.128 + // Pass in the type ... if its NBS or IANA pass in the string pattern
1.129 + // if its WAP or SecureWap, pass in the port number
1.130 + // return kErrNone if success, kErrNotFound if it fails
1.131 + IMPORT_C TInt IsBioMessageL(TBioMsgIdType aPortType, const TDesC& aPattern, TUint16 aPort, TUid& rBioMsgUID);
1.132 +
1.133 + IMPORT_C TInt IsBioMessageL(TBioMsgId bioMessageData, TUid& rBioMsgUID);
1.134 +
1.135 +private:
1.136 + CBIODatabase();
1.137 + void ConstructL(RFs& afileSystem);
1.138 +
1.139 +private:
1.140 + //Utilities
1.141 + void GetTransportIDL(TInt aIndex, TBioMsgIdType aPortType, TBioMsgId& aBioMsgID);
1.142 + TBool IsLanguageFileL(const TDesC& aFileName, TInt& aExtLength) const;
1.143 + // If Persistence is required...
1.144 + // void InternalizeL(RReadStream& aStream);
1.145 + // void ExternalizeL(RWriteStream& aStream) const;
1.146 +
1.147 +private:
1.148 + CArrayPtrFlat<CBioInfoFileReader>* iBifReaders;
1.149 +
1.150 +};
1.151 +
1.152 +/** Callback interface implemented by classes to receive notifications of BIF files
1.153 +changes from CBifChangeObserver.
1.154 +
1.155 +@publishedPartner
1.156 +@released
1.157 +*/
1.158 +class MBifChangeObserver
1.159 + {
1.160 +public:
1.161 + /** BIF change events. */
1.162 + enum TBifChangeEvent
1.163 + {
1.164 + /** Unknown change. */
1.165 + EBifChangeUnknown = 0,
1.166 + /** BIF added. */
1.167 + EBifAdded,
1.168 + /** BIF deleted. */
1.169 + EBifDeleted,
1.170 + /** BIF changed. */
1.171 + EBifChanged
1.172 + };
1.173 +
1.174 +public:
1.175 + /** Called when a BIF change occurs.
1.176 +
1.177 + @param aEvent Change event type
1.178 + @param aBioID BIO message type of changed BIF */
1.179 + virtual void HandleBifChangeL(TBifChangeEvent aEvent, TUid aBioID)=0;
1.180 + };
1.181 +
1.182 +/** Active object that watches for changes made to the installed BIF files.
1.183 +
1.184 +@publishedPartner
1.185 +@released
1.186 +*/
1.187 +class CBifChangeObserver : public CActive
1.188 + {
1.189 +public:
1.190 + IMPORT_C static CBifChangeObserver* NewL(MBifChangeObserver& aObserver, RFs& aFs);
1.191 + IMPORT_C void Start();
1.192 + ~CBifChangeObserver();
1.193 +
1.194 + static void CleanupBifArray(TAny* aBifArray);
1.195 +
1.196 +private:
1.197 + // from CActive
1.198 + virtual void RunL();
1.199 + virtual void DoCancel();
1.200 +
1.201 +private:
1.202 + CBifChangeObserver(MBifChangeObserver& aObserver, RFs& aFs);
1.203 + void ConstructL();
1.204 +
1.205 + void NotifyObserverL();
1.206 + void WaitForFileNotification();
1.207 + void DoRunL();
1.208 + void CopyEntriesL(const CDir& aDir, CArrayFixFlat<TEntry>& aEntries);
1.209 + TBool CompareReaders(const CBioInfoFileReader& aReader1, const CBioInfoFileReader& aReader2) const;
1.210 +
1.211 + TInt FindEntry(const CBifEntry& aBifEntry, const RPointerArray<CBifEntry>& aEntries, TInt& aIndex) const;
1.212 +
1.213 +private:
1.214 + MBifChangeObserver& iChangeObserver;
1.215 + RFs& iFs;
1.216 +
1.217 + RPointerArray<CBifEntry> iEntries;
1.218 +
1.219 + CBIODatabase* iBioDB;
1.220 + RTimer iTimer;
1.221 + TInt iRetryCount;
1.222 + };
1.223 +
1.224 +#endif // __BIODB_H__