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