epoc32/include/bassnd.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 bassnd.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 #if !defined(__EIKSSND_H__)
       
    17 #define __EIKSSND_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <s32file.h>
       
    21 #include <mda/common/controller.h>
       
    22 
       
    23 
       
    24 /**
       
    25 Specifies a system sound for a ring, alarm, message, error or event.
       
    26 "bafl.lib"
       
    27 @since 6.0
       
    28 @publishedAll
       
    29 @released
       
    30 */
       
    31 typedef TUid TBaSystemSoundUid;
       
    32 
       
    33 /**
       
    34 Specifies a system sound file name.
       
    35 "bafl.lib"
       
    36 @since 6.0
       
    37 @publishedAll
       
    38 @released
       
    39 */
       
    40 typedef TFileName TBaSystemSoundName;
       
    41 
       
    42 /**
       
    43 @publishedAll
       
    44 @released
       
    45 */
       
    46 #define KSystemSoundDefaultVolume	1
       
    47 #define KSystemSoundDefaultPriority	0
       
    48 
       
    49 /**
       
    50 this dll may use uids 48aa to 48ca
       
    51 @publishedAll
       
    52 @released
       
    53 */
       
    54 const TBaSystemSoundUid KSystemSoundRingUID		= {0x100048AB};
       
    55 const TBaSystemSoundUid KSystemSoundAlarmUID	= {0x100048AC};
       
    56 const TBaSystemSoundUid KSystemSoundMessageUID	= {0x100048AD};
       
    57 
       
    58 const TBaSystemSoundUid KUidSystemSoundError={0x1000609E};
       
    59 const TBaSystemSoundUid KUidSystemSoundEvent={0x1000609F};
       
    60 
       
    61 /**
       
    62 This is the UID of the repository where the system sound data is stored.
       
    63 The UID is published to UI platforms to allow them to use the key value in 
       
    64 the CRepository::NotifyRequest() API to monitor for changes in the system
       
    65 sound data.
       
    66 
       
    67 @see CRepository
       
    68 @see BaSystemSound::SystemSoundFile
       
    69 @publishedPartner
       
    70 @released
       
    71 */
       
    72 const TUid KSystemSoundRepositoryUID = {0x100048AA};
       
    73 
       
    74 
       
    75 class TBaSystemSoundType
       
    76 /** 
       
    77 Provides a logical sound wrapper. A sound is specified logically using two 
       
    78 UIDs. The first UID specifies the sound's category which can be a file, tone 
       
    79 or sequence; the second, which is optional, specifies an instance of that 
       
    80 category. The pair of UIDs is encapsulated in a TBaSystemSoundType object.
       
    81 
       
    82 Once a TBaSystemSoundType object is constructed, the sound player class CoeSoundPlayer 
       
    83 is used to play the sound. 
       
    84 @publishedAll
       
    85 @released
       
    86 */
       
    87 	{
       
    88 public:
       
    89 	IMPORT_C TBaSystemSoundType();
       
    90 	IMPORT_C TBaSystemSoundType(TBaSystemSoundUid aMajor,TUid aMinor=KNullUid);
       
    91 public:
       
    92 	inline TBool IsNull() const;
       
    93 	IMPORT_C TBool operator==(const TBaSystemSoundType& aType) const;
       
    94 public:
       
    95 	/** Specifies a sound's category. */
       
    96 	TBaSystemSoundUid iMajor;
       
    97 	/** Specifies an instance of a sound's category. */
       
    98 	TUid iMinor;
       
    99 	};
       
   100 
       
   101 
       
   102 class TBaSystemSoundInfo
       
   103 /** 
       
   104 Provides functions that contain the information for a system sound. A sound 
       
   105 may be a file, a tone or a fixed sequence.
       
   106 
       
   107 The characteristics of a physical sound that corresponds to a logical sound 
       
   108 are encapsulated in a TBaSystemSoundInfo object. You can get and set the physical 
       
   109 sound for a logical sound through the functions provided by the BaSystemSound 
       
   110 class. 
       
   111 @publishedAll
       
   112 @released
       
   113 */
       
   114 	{
       
   115 public:
       
   116 	
       
   117 	class TTone
       
   118 /** 
       
   119 Provides functions to define a tone. Once defined, the tone can be encapsulated 
       
   120 using the TBaSystemSoundInfo class and subsequently played. 
       
   121 @publishedAll
       
   122 @released 
       
   123 
       
   124 */
       
   125 		{
       
   126 	public:
       
   127 	
       
   128 		inline TTone();
       
   129 		inline TTone(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration);
       
   130 	public:
       
   131 	
       
   132 		TBool IsNull() const;
       
   133 	public:
       
   134 
       
   135 		void InternalizeL(RReadStream& aStream);
       
   136 
       
   137 		void ExternalizeL(RWriteStream& aStream) const;
       
   138 	public:
       
   139 	/** Frequency of the tone. */
       
   140 		TInt iFrequency;
       
   141 	/** Duration of the tone. */
       
   142 		TTimeIntervalMicroSeconds32 iDuration;
       
   143 		};
       
   144 public:
       
   145 	/** Specifies the category of the system sound. */
       
   146 	enum TSoundCategory
       
   147 		{
       
   148 		/** Specifies no system sound. */
       
   149 		ENull,
       
   150 
       
   151 		/** Specifies a file as the system sound. */
       
   152 		EFile,
       
   153 
       
   154 		/** Specifies a sequence as the system sound. */
       
   155 		ESequence,
       
   156 
       
   157 		/** Specifies a tone as the system sound. */
       
   158 		ETone
       
   159 		};
       
   160 public:
       
   161 	IMPORT_C TBaSystemSoundInfo();
       
   162 	IMPORT_C TBaSystemSoundInfo(const TBaSystemSoundType& aType,const TBaSystemSoundName& aName,
       
   163 							TInt aVolume=KSystemSoundDefaultVolume,TInt aPriority=KSystemSoundDefaultPriority);
       
   164 	IMPORT_C TBaSystemSoundInfo(const TBaSystemSoundType& aType,TInt aFixedSequence,
       
   165 							TInt aVolume=KSystemSoundDefaultVolume,TInt aPriority=KSystemSoundDefaultPriority);
       
   166 	IMPORT_C TBaSystemSoundInfo(const TBaSystemSoundType& aType,TTone aTone,
       
   167 							TInt aVolume=KSystemSoundDefaultVolume,TInt aPriority=KSystemSoundDefaultPriority);
       
   168 public:
       
   169 	IMPORT_C TSoundCategory SoundCategory() const;
       
   170 	inline TInt FixedSequenceNumber() const;
       
   171 	inline TBaSystemSoundName FileName() const;
       
   172 	inline TTone Tone() const;
       
   173 	IMPORT_C void SetFixedSequenceNumber(TInt aNumber);
       
   174 	IMPORT_C void SetFileName(const TBaSystemSoundName& aFileName);
       
   175 	IMPORT_C void SetTone(const TTone& aTone);
       
   176 
       
   177 	void InternalizeL(RReadStream& aStream);
       
   178 	void ExternalizeL(RWriteStream& aStream) const;
       
   179 public:
       
   180 	TBaSystemSoundType iType;
       
   181 	TInt iVolume;
       
   182 	TInt iPriority;
       
   183 private:
       
   184 	TBaSystemSoundName iName;
       
   185 	TInt iFixedSequence;
       
   186 	TTone iTone;
       
   187 	};
       
   188 
       
   189 
       
   190 /** 
       
   191 API class to retrieve and modify the system sounds settings.
       
   192 
       
   193 Note that SystemSoundFile() is now deprecated and will be removed in a future
       
   194 release. The filename it returns is no longer valid but is kept for backwards 
       
   195 compatibility. The system sounds settings are no longer stored in a data file.
       
   196  
       
   197 @see BaSystemSound::SystemSoundFile
       
   198 @see KSystemSoundRepositoryUID
       
   199 @publishedAll
       
   200 @released
       
   201 */
       
   202 class BaSystemSound
       
   203 	{
       
   204 public:
       
   205 	IMPORT_C static TInt GetSound(RFs& aFsSession,const TBaSystemSoundType& aType,TBaSystemSoundInfo& aInfo);
       
   206 	IMPORT_C static void SetSoundL(RFs& aFsSession,const TBaSystemSoundInfo& aInfo);
       
   207     IMPORT_C static TFileName SystemSoundFile(); // Deprecated
       
   208 private:
       
   209 	TBaSystemSoundName static DefaultSound(TBaSystemSoundUid aSSUid);
       
   210 	};
       
   211 
       
   212 
       
   213 class CBaSystemSoundArray: public CBase
       
   214 /**
       
   215  * An array to contain the set of system sounds for a TBaSystemSoundUid
       
   216 @publishedAll
       
   217 @released
       
   218  */	
       
   219  	{
       
   220 public:
       
   221 	CBaSystemSoundArray();
       
   222 	~CBaSystemSoundArray();
       
   223 public:
       
   224 	IMPORT_C static CBaSystemSoundArray* NewL();
       
   225 	IMPORT_C static CBaSystemSoundArray* NewLC();
       
   226 	IMPORT_C void RestoreL(RFs& aFsSession,TBaSystemSoundUid aSSUid);
       
   227 	IMPORT_C TInt Count() ;
       
   228 	IMPORT_C TBaSystemSoundInfo At(TInt aIndex);
       
   229 
       
   230 private:
       
   231 	TBaSystemSoundUid iUid;
       
   232 	CArrayFixFlat<TBaSystemSoundInfo> iSystemSounds;
       
   233 	};
       
   234 
       
   235 
       
   236 class TBaSoundPriorityBase
       
   237 /**
       
   238 Utility class to bundle up priority, priority preference and device specific data
       
   239 Only intended to be used in conjunction with TBaSystemSoundInfo::iPriority
       
   240 
       
   241 Layout of class is
       
   242 bits 31 -> 16:	Device specific priority preference data
       
   243 bits 15 -> 8:	Standard Epoc TMdaPriorityPreference setting
       
   244 bits 7 -> 0:		Priority value stored as a TInt8.  Maximum range possible is -256 -> +255
       
   245 					Note that MediaSvr currently defines a narrower range than this
       
   246 @publishedAll
       
   247 @released
       
   248 */	
       
   249 	{
       
   250 public:
       
   251 	inline TInt Int() const;
       
   252 	inline TInt Priority() const;
       
   253 	IMPORT_C TMdaPriorityPreference PriorityPreference() const;
       
   254 protected:
       
   255 	inline TBaSoundPriorityBase();
       
   256 	void Set(TInt aPriority,TMdaPriorityPreference aPriorityPreference=EMdaPriorityPreferenceTimeAndQuality);
       
   257 protected:
       
   258 	TInt iPriority;
       
   259 	};
       
   260 
       
   261 
       
   262 class TBaSoundPriorityEncoder : public TBaSoundPriorityBase
       
   263 /**
       
   264 Encode TBaSystemSoundInfo::iPriority before persisting a sound preference
       
   265 @publishedAll
       
   266 @released
       
   267 */
       
   268 	{
       
   269 public:
       
   270 	IMPORT_C TBaSoundPriorityEncoder(TInt aPriority,TMdaPriorityPreference aPriorityPreference=EMdaPriorityPreferenceTimeAndQuality);
       
   271 	};
       
   272 
       
   273 
       
   274 class TBaSoundPriorityDecoder : public TBaSoundPriorityBase
       
   275 /**
       
   276 Decode a restored TBaSystemSoundInfo::iPriority
       
   277 @internalComponent
       
   278 */
       
   279 	{
       
   280 public:
       
   281 	inline TBaSoundPriorityDecoder(TInt aVal);
       
   282 	};
       
   283 
       
   284 
       
   285 inline TBool TBaSystemSoundType::IsNull() const
       
   286 	/** Tests whether the sound's category and instance are null.
       
   287 	
       
   288 	@return ETrue if the sound's category and instance are null, EFalse otherwise. */
       
   289 	{return iMajor==KNullUid && iMinor==KNullUid;}
       
   290 
       
   291 
       
   292 inline TBaSystemSoundInfo::TTone::TTone()
       
   293 	: iFrequency(0), iDuration(0)
       
   294 	/** Default constructor. Sets up a TTone object with null frequency and duration. */
       
   295 	{}
       
   296 inline TBaSystemSoundInfo::TTone::TTone(TInt aFrequency,TTimeIntervalMicroSeconds32 aDuration)
       
   297 	: iFrequency(aFrequency), iDuration(aDuration)
       
   298 	/** Constructor which sets up a TTone object with specified frequency and duration.
       
   299 	
       
   300 	@param aFrequency The tone's frequency. 
       
   301 	@param aDuration The tone's duration. */
       
   302 	{}
       
   303 
       
   304 inline TInt TBaSystemSoundInfo::FixedSequenceNumber() const
       
   305 	/** Gets the current sound's sequence.
       
   306 	
       
   307 	@return The current sound's sequence. */
       
   308 	{return iFixedSequence;}
       
   309 
       
   310 inline TBaSystemSoundName TBaSystemSoundInfo::FileName() const
       
   311 	/** Gets the current sound's file.
       
   312 	
       
   313 	@return The current sound's file. */
       
   314 	{return iName;}
       
   315 
       
   316 inline TBaSystemSoundInfo::TTone TBaSystemSoundInfo::Tone() const
       
   317 	/** Gets the current system sound's tone.
       
   318 	
       
   319 	@return The current sound's tone. */
       
   320 	{return iTone;}
       
   321 
       
   322 inline TBaSoundPriorityBase::TBaSoundPriorityBase()
       
   323 	{}
       
   324 inline TInt TBaSoundPriorityBase::Int() const
       
   325 	{return iPriority;}
       
   326 inline TInt TBaSoundPriorityBase::Priority() const
       
   327 	{return (TInt8)iPriority;}
       
   328 
       
   329 inline TBaSoundPriorityDecoder::TBaSoundPriorityDecoder(TInt aVal)
       
   330 	{iPriority=aVal;}
       
   331 
       
   332 #endif