epoc32/include/mw/fepbconfig.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/fepbconfig.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
// Copyright (c) 1997-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 __FEPBCONFIG_H__
williamr@2
    17
#define __FEPBCONFIG_H__
williamr@2
    18
williamr@2
    19
#include <e32base.h>
williamr@2
    20
#include <coemain.h>	// class CCoeEnv
williamr@2
    21
williamr@2
    22
class CRepository;
williamr@2
    23
williamr@2
    24
/** Specifies the maximum size of a FEP attribute in bytes.
williamr@2
    25
williamr@2
    26
@publishedAll
williamr@2
    27
@released */
williamr@2
    28
const TInt KCoeFepMaxAttribDataSize = 200;
williamr@2
    29
williamr@2
    30
williamr@2
    31
/** On or off key data for FEPs. 
williamr@2
    32
williamr@2
    33
The CCoeFep class uses instances of this class to specify the key combination which 
williamr@2
    34
is used to turn the FEP on and off. These values are initialised during construction 
williamr@2
    35
of the FEP (see CCoeFep::BaseConstructL()).
williamr@2
    36
williamr@2
    37
The class consists of three TUints. They represent: 
williamr@2
    38
williamr@2
    39
- the character code of the key combination
williamr@2
    40
williamr@2
    41
- a modifier mask which indicates which modifiers are relevant to the key combination
williamr@2
    42
williamr@2
    43
- the modifier values which indicate which of the modifiers specified in the 
williamr@2
    44
modifier mask must be on and which must be off
williamr@2
    45
williamr@2
    46
For example, if the key combination to turn the FEP off is Fn+Enter, where 
williamr@2
    47
the Shift modifier must not be down (and the state of all other modifiers 
williamr@2
    48
is irrelevant), the TFepOnOrOffKeyData object would be constructed as follows:
williamr@2
    49
williamr@2
    50
@code
williamr@2
    51
TFepOnOrOffKeyData(EKeyEnter, EModifierFunc|EModifierShift, EModifierFunc) 
williamr@2
    52
@endcode
williamr@2
    53
williamr@2
    54
Note that modifiers should not be set in the values if they are not also set 
williamr@2
    55
in the mask. 
williamr@2
    56
williamr@2
    57
@publishedAll 
williamr@2
    58
@released */
williamr@2
    59
class TFepOnOrOffKeyData
williamr@2
    60
	{
williamr@2
    61
public:
williamr@2
    62
	inline TFepOnOrOffKeyData(TUint aCharacterCodeForFoldedMatch, TUint aModifierMask, TUint aModifierValues) :iCharacterCodeForFoldedMatch(aCharacterCodeForFoldedMatch), iModifierMask(aModifierMask), iModifierValues(aModifierValues) 
williamr@2
    63
	/** The C++ constructor is used to construct the key data object with the character 
williamr@2
    64
	code, the modifier mask and the modifier values.
williamr@2
    65
	
williamr@2
    66
	@param aCharacterCodeForFoldedMatch The character code.
williamr@2
    67
	@param aModifierMask The modifier mask.
williamr@2
    68
	@param aModifierValues The modifier values. */
williamr@2
    69
		{}
williamr@2
    70
williamr@2
    71
	inline TUint CharacterCodeForFoldedMatch() const 
williamr@2
    72
	/** Gets the character code.
williamr@2
    73
	
williamr@2
    74
	@return The character code. */
williamr@2
    75
		{return iCharacterCodeForFoldedMatch;}
williamr@2
    76
	inline TUint ModifierMask() const 
williamr@2
    77
	/** Gets the modifier mask.
williamr@2
    78
	
williamr@2
    79
	@return The modifier mask. */
williamr@2
    80
		{return iModifierMask;}
williamr@2
    81
	inline TUint ModifierValues() const 
williamr@2
    82
	/** Gets the modifier values.
williamr@2
    83
	
williamr@2
    84
	@return The modifier values. */
williamr@2
    85
		{return iModifierValues;}
williamr@2
    86
	/**
williamr@2
    87
	Checks if 2 TFepOnOrOffKeyData objects have the same values.
williamr@2
    88
williamr@2
    89
	returns Etrue if the 2 objects have the same values, EFalse otherwise
williamr@2
    90
	*/
williamr@2
    91
	IMPORT_C TBool operator==(const TFepOnOrOffKeyData& aAnother) const;
williamr@2
    92
	
williamr@2
    93
	
williamr@2
    94
	/**
williamr@2
    95
	Checks if 2 TFepOnOrOffKeyData objects do not have the the same values.
williamr@2
    96
	
williamr@2
    97
	returns Etrue if the 2 objects have the same values, EFalse otherwise
williamr@2
    98
	*/
williamr@2
    99
	IMPORT_C TBool operator!=(const TFepOnOrOffKeyData& aAnother) const;
williamr@2
   100
private:
williamr@2
   101
	TUint iCharacterCodeForFoldedMatch;
williamr@2
   102
	TUint iModifierMask;
williamr@2
   103
	TUint iModifierValues;
williamr@2
   104
	};
williamr@2
   105
williamr@2
   106
class CDictionaryStore;
williamr@2
   107
class RWriteStream;
williamr@2
   108
class RReadStream;
williamr@2
   109
williamr@2
   110
williamr@2
   111
/** Reads and writes generic FEP settings.
williamr@2
   112
williamr@2
   113
Used by the CCoeFep class. The generic FEP settings are whether the FEP is 
williamr@2
   114
on or off and what key combinations should turn the FEP on or off. Also used 
williamr@2
   115
to synchronise these settings across all running instances of the FEP. These 
williamr@2
   116
settings are generic, unlike FEP attributes which are FEP-specific. FEP attributes 
williamr@2
   117
are stored, restored and synchronised using class MFepAttributeStorer. Generic 
williamr@2
   118
FEP settings are changed locally using the Set...() member functions. Then, 
williamr@2
   119
to store these as the system settings and to apply them globally, call StoreChangesAndBroadcastL().
williamr@2
   120
williamr@2
   121
Class CCoeFep initialises its generic FEP settings from the global system 
williamr@2
   122
settings during construction. Its generic FEP settings are updated when the 
williamr@2
   123
settings are changed by a call to StoreChangesAndBroadcastL() by another running 
williamr@2
   124
instance of the FEP. 
williamr@2
   125
williamr@2
   126
@publishedAll
williamr@2
   127
@released */
williamr@2
   128
class CFepGenericGlobalSettings : public CBase
williamr@2
   129
	{
williamr@2
   130
public:
williamr@2
   131
	IMPORT_C static CFepGenericGlobalSettings* NewL(CCoeEnv& aConeEnvironment, const TFepOnOrOffKeyData& aDefaultOnKeyData, const TFepOnOrOffKeyData& aDefaultOffKeyData, TBool aDefaultIsOn);
williamr@2
   132
	IMPORT_C static CFepGenericGlobalSettings* NewLC(CCoeEnv& aConeEnvironment, const TFepOnOrOffKeyData& aDefaultOnKeyData, const TFepOnOrOffKeyData& aDefaultOffKeyData, TBool aDefaultIsOn);
williamr@2
   133
	IMPORT_C static CFepGenericGlobalSettings* NewL();
williamr@2
   134
	IMPORT_C static CFepGenericGlobalSettings* NewLC();
williamr@2
   135
	IMPORT_C TFepOnOrOffKeyData OnKeyData() const;
williamr@2
   136
	IMPORT_C void SetOnKeyData(const TFepOnOrOffKeyData& aOnKeyData);
williamr@2
   137
	IMPORT_C TFepOnOrOffKeyData OffKeyData() const;
williamr@2
   138
	IMPORT_C void SetOffKeyData(const TFepOnOrOffKeyData& aOffKeyData);
williamr@2
   139
	IMPORT_C TBool IsOn() const;
williamr@2
   140
	IMPORT_C void SetIsOn(TBool aIsOn);
williamr@2
   141
	IMPORT_C void StoreChangesAndBroadcastL();
williamr@2
   142
	IMPORT_C void RefreshL();
williamr@2
   143
public: // not for external use
williamr@2
   144
	IMPORT_C static void ReadOnState(CRepository& aRepository, TBool& aOnState, TInt* aError=NULL);
williamr@2
   145
	IMPORT_C static void ReadOnOrOffKeyData(CRepository& aRepository, TFepOnOrOffKeyData& aOnOrOffKeyData, TUint32 aRepositoryKeyMask_OnOrOff, TInt* aError=NULL);
williamr@2
   146
	IMPORT_C static void WriteOnStateAndBroadcastL(CRepository& aRepository, TBool aOnState, TUint32 aRepositoryKeyMask_DefaultOrDynamic);
williamr@2
   147
	IMPORT_C static void WriteOnOrOffKeyDataAndBroadcastL(CRepository& aRepository, const TFepOnOrOffKeyData& aOnOrOffKeyData, TUint32 aRepositoryKey);
williamr@2
   148
private:
williamr@2
   149
	CFepGenericGlobalSettings();
williamr@2
   150
	void ConstructL();
williamr@2
   151
private:
williamr@2
   152
	enum
williamr@2
   153
		{
williamr@2
   154
		EFlagIsOn				=0x00000001,
williamr@2
   155
		// the EFlagStoreXxx flags below indicate whether this object has had any SetXxx functions called on it, which can be used to optimize what work StoreChangesAndBroadcastL has to do
williamr@2
   156
		EFlagStoreIsOn			=0x00000002,
williamr@2
   157
		EFlagStoreOnKeyData		=0x00000004,
williamr@2
   158
		EFlagStoreOffKeyData	=0x00000008
williamr@2
   159
		};
williamr@2
   160
private:
williamr@2
   161
	TUint iFlags;
williamr@2
   162
	TFepOnOrOffKeyData iOnKeyData;
williamr@2
   163
	TFepOnOrOffKeyData iOffKeyData;
williamr@2
   164
	};
williamr@2
   165
williamr@2
   166
williamr@2
   167
/** Protocol for storing, restoring and synchronising FEP attributes. 
williamr@2
   168
williamr@2
   169
An abstract base class for CCoeFep, so FEPs must implement the pure virtual 
williamr@2
   170
functions declared in this class.
williamr@2
   171
williamr@2
   172
Rather than using a single device-wide instance of a FEP, each application 
williamr@2
   173
has its own instance of the FEP. MFepAttributeStorer provides a framework 
williamr@2
   174
for synchronising FEP attributes across each running instance of the same 
williamr@2
   175
FEP. For this to happen, the FEP must implement MFepAttributeStorer::WriteAttributeDataToStreamL() 
williamr@2
   176
and MFepAttributeStorer::ReadAttributeDataFromStreamL().
williamr@2
   177
williamr@2
   178
Attributes are FEP-specific, and are identified by a UID which can be accessed 
williamr@2
   179
using AttributeAtIndex(). An example of a FEP attribute might be whether inline 
williamr@2
   180
editing is enabled or disabled. 
williamr@2
   181
williamr@2
   182
@publishedAll 
williamr@2
   183
@released */
williamr@2
   184
class MFepAttributeStorer
williamr@2
   185
	{
williamr@2
   186
public:
williamr@2
   187
	IMPORT_C void ReadAllAttributesL(CCoeEnv& aConeEnvironment);
williamr@2
   188
	IMPORT_C void WriteAttributeDataAndBroadcastL(CCoeEnv& aConeEnvironment, TUid aAttributeUid);
williamr@2
   189
	IMPORT_C void WriteAttributeDataAndBroadcastL(CCoeEnv& aConeEnvironment, const TArray<TUid>& aAttributeUids);
williamr@2
   190
	/** Returns the total number of FEP attributes.
williamr@2
   191
	
williamr@2
   192
	@return The number of FEP attributes. */
williamr@2
   193
	virtual TInt NumberOfAttributes() const=0;
williamr@2
   194
	/** Returns the UID of the FEP attribute at the index specified.
williamr@2
   195
	
williamr@2
   196
	@param aIndex An array index.
williamr@2
   197
	@return The UID of the FEP attribute at aIndex. */
williamr@2
   198
	virtual TUid AttributeAtIndex(TInt aIndex) const=0;
williamr@2
   199
	/** Writes the value of the attribute specified to the specified write stream.
williamr@2
   200
	
williamr@2
   201
	Called by MFepAttributeStorer::WriteAttributeDataAndBroadcastL() for each 
williamr@2
   202
	attribute passed to it.
williamr@2
   203
	
williamr@2
   204
	@param aAttributeUid UID of the attribute to write to the stream.
williamr@2
   205
	@param aStream The stream to which to write the attribute. */
williamr@2
   206
	virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const=0;
williamr@2
   207
	/** Reads the value of the attribute identified by the UID specified in aAttributeUid 
williamr@2
   208
	from the specified read stream.
williamr@2
   209
	
williamr@2
   210
	You should take appropriate action if the attribute has changed, e.g. 
williamr@2
   211
	if inline editing has been disabled, you might cancel the current transaction.
williamr@2
   212
	
williamr@2
   213
	This function is called by MFepAttributeStorer::ReadAllAttributesL() for all 
williamr@2
   214
	attributes. It is also called when the FEP receives a message that an attribute 
williamr@2
   215
	has been changed by another running instance of the FEP (using WriteAttributeDataAndBroadcastL()).
williamr@2
   216
	
williamr@2
   217
	@param aAttributeUid Identifies the attribute whose value should be read.
williamr@2
   218
	@param aStream Read stream from which to read the attribute's value. */
williamr@2
   219
	virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream)=0;
williamr@2
   220
private:
williamr@2
   221
	IMPORT_C virtual void MFepAttributeStorer_Reserved_1();
williamr@2
   222
	IMPORT_C virtual void MFepAttributeStorer_Reserved_2();
williamr@2
   223
	TInt NumberOfOccurrencesOfAttributeUid(TUid aAttributeUid) const;
williamr@2
   224
	};
williamr@2
   225
williamr@2
   226
#endif	// __FEPBCONFIG_H__