williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __FEPBCONFIG_H__ williamr@2: #define __FEPBCONFIG_H__ williamr@2: williamr@2: #include williamr@2: #include // class CCoeEnv williamr@2: williamr@2: class CRepository; williamr@2: williamr@2: /** Specifies the maximum size of a FEP attribute in bytes. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: const TInt KCoeFepMaxAttribDataSize = 200; williamr@2: williamr@2: williamr@2: /** On or off key data for FEPs. williamr@2: williamr@2: The CCoeFep class uses instances of this class to specify the key combination which williamr@2: is used to turn the FEP on and off. These values are initialised during construction williamr@2: of the FEP (see CCoeFep::BaseConstructL()). williamr@2: williamr@2: The class consists of three TUints. They represent: williamr@2: williamr@2: - the character code of the key combination williamr@2: williamr@2: - a modifier mask which indicates which modifiers are relevant to the key combination williamr@2: williamr@2: - the modifier values which indicate which of the modifiers specified in the williamr@2: modifier mask must be on and which must be off williamr@2: williamr@2: For example, if the key combination to turn the FEP off is Fn+Enter, where williamr@2: the Shift modifier must not be down (and the state of all other modifiers williamr@2: is irrelevant), the TFepOnOrOffKeyData object would be constructed as follows: williamr@2: williamr@2: @code williamr@2: TFepOnOrOffKeyData(EKeyEnter, EModifierFunc|EModifierShift, EModifierFunc) williamr@2: @endcode williamr@2: williamr@2: Note that modifiers should not be set in the values if they are not also set williamr@2: in the mask. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: class TFepOnOrOffKeyData williamr@2: { williamr@2: public: williamr@2: inline TFepOnOrOffKeyData(TUint aCharacterCodeForFoldedMatch, TUint aModifierMask, TUint aModifierValues) :iCharacterCodeForFoldedMatch(aCharacterCodeForFoldedMatch), iModifierMask(aModifierMask), iModifierValues(aModifierValues) williamr@2: /** The C++ constructor is used to construct the key data object with the character williamr@2: code, the modifier mask and the modifier values. williamr@2: williamr@2: @param aCharacterCodeForFoldedMatch The character code. williamr@2: @param aModifierMask The modifier mask. williamr@2: @param aModifierValues The modifier values. */ williamr@2: {} williamr@2: williamr@2: inline TUint CharacterCodeForFoldedMatch() const williamr@2: /** Gets the character code. williamr@2: williamr@2: @return The character code. */ williamr@2: {return iCharacterCodeForFoldedMatch;} williamr@2: inline TUint ModifierMask() const williamr@2: /** Gets the modifier mask. williamr@2: williamr@2: @return The modifier mask. */ williamr@2: {return iModifierMask;} williamr@2: inline TUint ModifierValues() const williamr@2: /** Gets the modifier values. williamr@2: williamr@2: @return The modifier values. */ williamr@2: {return iModifierValues;} williamr@2: /** williamr@2: Checks if 2 TFepOnOrOffKeyData objects have the same values. williamr@2: williamr@2: returns Etrue if the 2 objects have the same values, EFalse otherwise williamr@2: */ williamr@2: IMPORT_C TBool operator==(const TFepOnOrOffKeyData& aAnother) const; williamr@2: williamr@2: williamr@2: /** williamr@2: Checks if 2 TFepOnOrOffKeyData objects do not have the the same values. williamr@2: williamr@2: returns Etrue if the 2 objects have the same values, EFalse otherwise williamr@2: */ williamr@2: IMPORT_C TBool operator!=(const TFepOnOrOffKeyData& aAnother) const; williamr@2: private: williamr@2: TUint iCharacterCodeForFoldedMatch; williamr@2: TUint iModifierMask; williamr@2: TUint iModifierValues; williamr@2: }; williamr@2: williamr@2: class CDictionaryStore; williamr@2: class RWriteStream; williamr@2: class RReadStream; williamr@2: williamr@2: williamr@2: /** Reads and writes generic FEP settings. williamr@2: williamr@2: Used by the CCoeFep class. The generic FEP settings are whether the FEP is williamr@2: on or off and what key combinations should turn the FEP on or off. Also used williamr@2: to synchronise these settings across all running instances of the FEP. These williamr@2: settings are generic, unlike FEP attributes which are FEP-specific. FEP attributes williamr@2: are stored, restored and synchronised using class MFepAttributeStorer. Generic williamr@2: FEP settings are changed locally using the Set...() member functions. Then, williamr@2: to store these as the system settings and to apply them globally, call StoreChangesAndBroadcastL(). williamr@2: williamr@2: Class CCoeFep initialises its generic FEP settings from the global system williamr@2: settings during construction. Its generic FEP settings are updated when the williamr@2: settings are changed by a call to StoreChangesAndBroadcastL() by another running williamr@2: instance of the FEP. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: class CFepGenericGlobalSettings : public CBase williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CFepGenericGlobalSettings* NewL(CCoeEnv& aConeEnvironment, const TFepOnOrOffKeyData& aDefaultOnKeyData, const TFepOnOrOffKeyData& aDefaultOffKeyData, TBool aDefaultIsOn); williamr@2: IMPORT_C static CFepGenericGlobalSettings* NewLC(CCoeEnv& aConeEnvironment, const TFepOnOrOffKeyData& aDefaultOnKeyData, const TFepOnOrOffKeyData& aDefaultOffKeyData, TBool aDefaultIsOn); williamr@2: IMPORT_C static CFepGenericGlobalSettings* NewL(); williamr@2: IMPORT_C static CFepGenericGlobalSettings* NewLC(); williamr@2: IMPORT_C TFepOnOrOffKeyData OnKeyData() const; williamr@2: IMPORT_C void SetOnKeyData(const TFepOnOrOffKeyData& aOnKeyData); williamr@2: IMPORT_C TFepOnOrOffKeyData OffKeyData() const; williamr@2: IMPORT_C void SetOffKeyData(const TFepOnOrOffKeyData& aOffKeyData); williamr@2: IMPORT_C TBool IsOn() const; williamr@2: IMPORT_C void SetIsOn(TBool aIsOn); williamr@2: IMPORT_C void StoreChangesAndBroadcastL(); williamr@2: IMPORT_C void RefreshL(); williamr@2: public: // not for external use williamr@2: IMPORT_C static void ReadOnState(CRepository& aRepository, TBool& aOnState, TInt* aError=NULL); williamr@2: IMPORT_C static void ReadOnOrOffKeyData(CRepository& aRepository, TFepOnOrOffKeyData& aOnOrOffKeyData, TUint32 aRepositoryKeyMask_OnOrOff, TInt* aError=NULL); williamr@2: IMPORT_C static void WriteOnStateAndBroadcastL(CRepository& aRepository, TBool aOnState, TUint32 aRepositoryKeyMask_DefaultOrDynamic); williamr@2: IMPORT_C static void WriteOnOrOffKeyDataAndBroadcastL(CRepository& aRepository, const TFepOnOrOffKeyData& aOnOrOffKeyData, TUint32 aRepositoryKey); williamr@2: private: williamr@2: CFepGenericGlobalSettings(); williamr@2: void ConstructL(); williamr@2: private: williamr@2: enum williamr@2: { williamr@2: EFlagIsOn =0x00000001, williamr@2: // 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: EFlagStoreIsOn =0x00000002, williamr@2: EFlagStoreOnKeyData =0x00000004, williamr@2: EFlagStoreOffKeyData =0x00000008 williamr@2: }; williamr@2: private: williamr@2: TUint iFlags; williamr@2: TFepOnOrOffKeyData iOnKeyData; williamr@2: TFepOnOrOffKeyData iOffKeyData; williamr@2: }; williamr@2: williamr@2: williamr@2: /** Protocol for storing, restoring and synchronising FEP attributes. williamr@2: williamr@2: An abstract base class for CCoeFep, so FEPs must implement the pure virtual williamr@2: functions declared in this class. williamr@2: williamr@2: Rather than using a single device-wide instance of a FEP, each application williamr@2: has its own instance of the FEP. MFepAttributeStorer provides a framework williamr@2: for synchronising FEP attributes across each running instance of the same williamr@2: FEP. For this to happen, the FEP must implement MFepAttributeStorer::WriteAttributeDataToStreamL() williamr@2: and MFepAttributeStorer::ReadAttributeDataFromStreamL(). williamr@2: williamr@2: Attributes are FEP-specific, and are identified by a UID which can be accessed williamr@2: using AttributeAtIndex(). An example of a FEP attribute might be whether inline williamr@2: editing is enabled or disabled. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: class MFepAttributeStorer williamr@2: { williamr@2: public: williamr@2: IMPORT_C void ReadAllAttributesL(CCoeEnv& aConeEnvironment); williamr@2: IMPORT_C void WriteAttributeDataAndBroadcastL(CCoeEnv& aConeEnvironment, TUid aAttributeUid); williamr@2: IMPORT_C void WriteAttributeDataAndBroadcastL(CCoeEnv& aConeEnvironment, const TArray& aAttributeUids); williamr@2: /** Returns the total number of FEP attributes. williamr@2: williamr@2: @return The number of FEP attributes. */ williamr@2: virtual TInt NumberOfAttributes() const=0; williamr@2: /** Returns the UID of the FEP attribute at the index specified. williamr@2: williamr@2: @param aIndex An array index. williamr@2: @return The UID of the FEP attribute at aIndex. */ williamr@2: virtual TUid AttributeAtIndex(TInt aIndex) const=0; williamr@2: /** Writes the value of the attribute specified to the specified write stream. williamr@2: williamr@2: Called by MFepAttributeStorer::WriteAttributeDataAndBroadcastL() for each williamr@2: attribute passed to it. williamr@2: williamr@2: @param aAttributeUid UID of the attribute to write to the stream. williamr@2: @param aStream The stream to which to write the attribute. */ williamr@2: virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const=0; williamr@2: /** Reads the value of the attribute identified by the UID specified in aAttributeUid williamr@2: from the specified read stream. williamr@2: williamr@2: You should take appropriate action if the attribute has changed, e.g. williamr@2: if inline editing has been disabled, you might cancel the current transaction. williamr@2: williamr@2: This function is called by MFepAttributeStorer::ReadAllAttributesL() for all williamr@2: attributes. It is also called when the FEP receives a message that an attribute williamr@2: has been changed by another running instance of the FEP (using WriteAttributeDataAndBroadcastL()). williamr@2: williamr@2: @param aAttributeUid Identifies the attribute whose value should be read. williamr@2: @param aStream Read stream from which to read the attribute's value. */ williamr@2: virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream)=0; williamr@2: private: williamr@2: IMPORT_C virtual void MFepAttributeStorer_Reserved_1(); williamr@2: IMPORT_C virtual void MFepAttributeStorer_Reserved_2(); williamr@2: TInt NumberOfOccurrencesOfAttributeUid(TUid aAttributeUid) const; williamr@2: }; williamr@2: williamr@2: #endif // __FEPBCONFIG_H__ williamr@4: williamr@4: