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