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