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: #if !defined(__EIKSSND_H__) williamr@2: #define __EIKSSND_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@4: #include williamr@2: williamr@2: williamr@2: /** williamr@2: Specifies a system sound for a ring, alarm, message, error or event. williamr@2: "bafl.lib" williamr@2: @since 6.0 williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: typedef TUid TBaSystemSoundUid; williamr@2: williamr@2: /** williamr@2: Specifies a system sound file name. williamr@2: "bafl.lib" williamr@2: @since 6.0 williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: typedef TFileName TBaSystemSoundName; williamr@2: williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: #define KSystemSoundDefaultVolume 1 williamr@2: #define KSystemSoundDefaultPriority 0 williamr@2: williamr@2: /** williamr@2: this dll may use uids 48aa to 48ca williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: const TBaSystemSoundUid KSystemSoundRingUID = {0x100048AB}; williamr@2: const TBaSystemSoundUid KSystemSoundAlarmUID = {0x100048AC}; williamr@2: const TBaSystemSoundUid KSystemSoundMessageUID = {0x100048AD}; williamr@2: williamr@2: const TBaSystemSoundUid KUidSystemSoundError={0x1000609E}; williamr@2: const TBaSystemSoundUid KUidSystemSoundEvent={0x1000609F}; williamr@2: williamr@2: williamr@2: williamr@2: class TBaSystemSoundType williamr@2: /** williamr@2: Provides a logical sound wrapper. A sound is specified logically using two williamr@2: UIDs. The first UID specifies the sound's category which can be a file, tone williamr@2: or sequence; the second, which is optional, specifies an instance of that williamr@2: category. The pair of UIDs is encapsulated in a TBaSystemSoundType object. williamr@2: williamr@2: Once a TBaSystemSoundType object is constructed, the sound player class CoeSoundPlayer williamr@2: is used to play the sound. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBaSystemSoundType(); williamr@2: IMPORT_C TBaSystemSoundType(TBaSystemSoundUid aMajor,TUid aMinor=KNullUid); williamr@2: public: williamr@2: inline TBool IsNull() const; williamr@2: IMPORT_C TBool operator==(const TBaSystemSoundType& aType) const; williamr@2: public: williamr@2: /** Specifies a sound's category. */ williamr@2: TBaSystemSoundUid iMajor; williamr@2: /** Specifies an instance of a sound's category. */ williamr@2: TUid iMinor; williamr@2: }; williamr@2: williamr@2: williamr@2: class TBaSystemSoundInfo williamr@2: /** williamr@2: Provides functions that contain the information for a system sound. A sound williamr@2: may be a file, a tone or a fixed sequence. williamr@2: williamr@2: The characteristics of a physical sound that corresponds to a logical sound williamr@2: are encapsulated in a TBaSystemSoundInfo object. You can get and set the physical williamr@2: sound for a logical sound through the functions provided by the BaSystemSound williamr@2: class. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: class TTone williamr@2: /** williamr@2: Provides functions to define a tone. Once defined, the tone can be encapsulated williamr@2: using the TBaSystemSoundInfo class and subsequently played. williamr@2: @publishedAll williamr@2: @released williamr@2: williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: inline TTone(); williamr@2: inline TTone(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration); williamr@2: public: williamr@2: williamr@2: TBool IsNull() const; williamr@2: public: williamr@2: williamr@2: void InternalizeL(RReadStream& aStream); williamr@2: williamr@2: void ExternalizeL(RWriteStream& aStream) const; williamr@2: public: williamr@2: /** Frequency of the tone. */ williamr@2: TInt iFrequency; williamr@2: /** Duration of the tone. */ williamr@2: TTimeIntervalMicroSeconds32 iDuration; williamr@2: }; williamr@2: public: williamr@2: /** Specifies the category of the system sound. */ williamr@2: enum TSoundCategory williamr@2: { williamr@2: /** Specifies no system sound. */ williamr@2: ENull, williamr@2: williamr@2: /** Specifies a file as the system sound. */ williamr@2: EFile, williamr@2: williamr@2: /** Specifies a sequence as the system sound. */ williamr@2: ESequence, williamr@2: williamr@2: /** Specifies a tone as the system sound. */ williamr@2: ETone williamr@2: }; williamr@2: public: williamr@2: IMPORT_C TBaSystemSoundInfo(); williamr@2: IMPORT_C TBaSystemSoundInfo(const TBaSystemSoundType& aType,const TBaSystemSoundName& aName, williamr@2: TInt aVolume=KSystemSoundDefaultVolume,TInt aPriority=KSystemSoundDefaultPriority); williamr@2: IMPORT_C TBaSystemSoundInfo(const TBaSystemSoundType& aType,TInt aFixedSequence, williamr@2: TInt aVolume=KSystemSoundDefaultVolume,TInt aPriority=KSystemSoundDefaultPriority); williamr@2: IMPORT_C TBaSystemSoundInfo(const TBaSystemSoundType& aType,TTone aTone, williamr@2: TInt aVolume=KSystemSoundDefaultVolume,TInt aPriority=KSystemSoundDefaultPriority); williamr@2: public: williamr@2: IMPORT_C TSoundCategory SoundCategory() const; williamr@2: inline TInt FixedSequenceNumber() const; williamr@2: inline TBaSystemSoundName FileName() const; williamr@2: inline TTone Tone() const; williamr@2: IMPORT_C void SetFixedSequenceNumber(TInt aNumber); williamr@2: IMPORT_C void SetFileName(const TBaSystemSoundName& aFileName); williamr@2: IMPORT_C void SetTone(const TTone& aTone); williamr@2: williamr@2: void InternalizeL(RReadStream& aStream); williamr@2: void ExternalizeL(RWriteStream& aStream) const; williamr@2: public: williamr@2: TBaSystemSoundType iType; williamr@2: TInt iVolume; williamr@2: TInt iPriority; williamr@2: private: williamr@2: TBaSystemSoundName iName; williamr@2: TInt iFixedSequence; williamr@2: TTone iTone; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: API class to retrieve and modify the system sounds settings. williamr@2: williamr@2: Note that SystemSoundFile() is now deprecated and will be removed in a future williamr@2: release. The filename it returns is no longer valid but is kept for backwards williamr@2: compatibility. The system sounds settings are no longer stored in a data file. williamr@2: williamr@2: @see BaSystemSound::SystemSoundFile williamr@2: @see KSystemSoundRepositoryUID williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class BaSystemSound williamr@2: { williamr@2: public: williamr@2: IMPORT_C static TInt GetSound(RFs& aFsSession,const TBaSystemSoundType& aType,TBaSystemSoundInfo& aInfo); williamr@2: IMPORT_C static void SetSoundL(RFs& aFsSession,const TBaSystemSoundInfo& aInfo); williamr@2: IMPORT_C static TFileName SystemSoundFile(); // Deprecated williamr@2: private: williamr@2: TBaSystemSoundName static DefaultSound(TBaSystemSoundUid aSSUid); williamr@2: }; williamr@2: williamr@2: williamr@2: class CBaSystemSoundArray: public CBase williamr@2: /** williamr@2: * An array to contain the set of system sounds for a TBaSystemSoundUid williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: CBaSystemSoundArray(); williamr@2: ~CBaSystemSoundArray(); williamr@2: public: williamr@2: IMPORT_C static CBaSystemSoundArray* NewL(); williamr@2: IMPORT_C static CBaSystemSoundArray* NewLC(); williamr@2: IMPORT_C void RestoreL(RFs& aFsSession,TBaSystemSoundUid aSSUid); williamr@2: IMPORT_C TInt Count() ; williamr@2: IMPORT_C TBaSystemSoundInfo At(TInt aIndex); williamr@2: williamr@2: private: williamr@2: TBaSystemSoundUid iUid; williamr@2: CArrayFixFlat iSystemSounds; williamr@2: }; williamr@2: williamr@2: williamr@2: class TBaSoundPriorityBase williamr@2: /** williamr@2: Utility class to bundle up priority, priority preference and device specific data williamr@2: Only intended to be used in conjunction with TBaSystemSoundInfo::iPriority williamr@2: williamr@2: Layout of class is williamr@2: bits 31 -> 16: Device specific priority preference data williamr@2: bits 15 -> 8: Standard Epoc TMdaPriorityPreference setting williamr@2: bits 7 -> 0: Priority value stored as a TInt8. Maximum range possible is -256 -> +255 williamr@2: Note that MediaSvr currently defines a narrower range than this williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: inline TInt Int() const; williamr@2: inline TInt Priority() const; williamr@2: IMPORT_C TMdaPriorityPreference PriorityPreference() const; williamr@2: protected: williamr@2: inline TBaSoundPriorityBase(); williamr@2: void Set(TInt aPriority,TMdaPriorityPreference aPriorityPreference=EMdaPriorityPreferenceTimeAndQuality); williamr@2: protected: williamr@2: TInt iPriority; williamr@2: }; williamr@2: williamr@2: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: #include williamr@4: #endif williamr@4: williamr@2: class TBaSoundPriorityEncoder : public TBaSoundPriorityBase williamr@2: /** williamr@2: Encode TBaSystemSoundInfo::iPriority before persisting a sound preference williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBaSoundPriorityEncoder(TInt aPriority,TMdaPriorityPreference aPriorityPreference=EMdaPriorityPreferenceTimeAndQuality); williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: inline TBool TBaSystemSoundType::IsNull() const williamr@2: /** Tests whether the sound's category and instance are null. williamr@2: williamr@2: @return ETrue if the sound's category and instance are null, EFalse otherwise. */ williamr@2: {return iMajor==KNullUid && iMinor==KNullUid;} williamr@2: williamr@2: williamr@2: inline TBaSystemSoundInfo::TTone::TTone() williamr@2: : iFrequency(0), iDuration(0) williamr@2: /** Default constructor. Sets up a TTone object with null frequency and duration. */ williamr@2: {} williamr@2: inline TBaSystemSoundInfo::TTone::TTone(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration) williamr@2: : iFrequency(aFrequency), iDuration(aDuration) williamr@2: /** Constructor which sets up a TTone object with specified frequency and duration. williamr@2: williamr@2: @param aFrequency The tone's frequency. williamr@2: @param aDuration The tone's duration. */ williamr@2: {} williamr@2: williamr@2: inline TInt TBaSystemSoundInfo::FixedSequenceNumber() const williamr@2: /** Gets the current sound's sequence. williamr@2: williamr@2: @return The current sound's sequence. */ williamr@2: {return iFixedSequence;} williamr@2: williamr@2: inline TBaSystemSoundName TBaSystemSoundInfo::FileName() const williamr@2: /** Gets the current sound's file. williamr@2: williamr@2: @return The current sound's file. */ williamr@2: {return iName;} williamr@2: williamr@2: inline TBaSystemSoundInfo::TTone TBaSystemSoundInfo::Tone() const williamr@2: /** Gets the current system sound's tone. williamr@2: williamr@2: @return The current sound's tone. */ williamr@2: {return iTone;} williamr@2: williamr@2: inline TBaSoundPriorityBase::TBaSoundPriorityBase() williamr@2: {} williamr@2: inline TInt TBaSoundPriorityBase::Int() const williamr@2: {return iPriority;} williamr@2: inline TInt TBaSoundPriorityBase::Priority() const williamr@2: {return (TInt8)iPriority;} williamr@2: williamr@2: williamr@2: #endif