williamr@2: /* williamr@2: * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * 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: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Interface for controlling keysounds from Avkon. williamr@2: * williamr@2: */ williamr@2: williamr@2: #ifndef __AKNSOUNDSYSTEM_H__ williamr@2: #define __AKNSOUNDSYSTEM_H__ williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CAknSoundPlayer; williamr@2: class CAknKeySoundStack; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: /** williamr@2: * Interface for controlling keysounds from Avkon. williamr@2: * Provides support for handling key sounds. williamr@2: * @since S60 0.9 williamr@2: */ williamr@2: NONSHARABLE_CLASS(CAknKeySoundSystem) : public CBase williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Base class default constructor. If a client application is derived from @c CAknAppUi, williamr@2: * its @c KeySounds() method should be used instead to obtain a key sound system instance. williamr@2: * If this method is used, the client needs explicitly call @c BringToForeground(). williamr@2: * williamr@2: * @param aUid Application UID. williamr@2: * @return A pointer to a new @c CAknKeySoundSystem object. williamr@2: */ williamr@2: IMPORT_C static CAknKeySoundSystem* NewL(TInt aUid); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CAknKeySoundSystem(); williamr@2: williamr@2: /** williamr@2: * Reads key sound context from resource file and pushes it to the sound stack. williamr@2: * All key presses for the application produce sounds as specified in this key sound context. williamr@2: * The resource specified must be of the @c AVKON_SKEY_LIST type. There are also some default williamr@2: * Avkon contexts available, e.g. @c R_AVKON_DEFAULT_SKEY_LIST and @c R_AVKON_SILENT_SKEY_LIST. williamr@2: * williamr@2: * @param aResourceId Key sound context resource ID. williamr@2: */ williamr@2: IMPORT_C void PushContextL(TInt aResourceId); williamr@2: williamr@2: /** williamr@2: * Pops the top context from the key sound stack. williamr@2: */ williamr@2: IMPORT_C void PopContext(); williamr@2: williamr@2: /** williamr@2: * Plays a sound corresponding to the given key event. This is called directly by Avkon, williamr@2: * though it can be used in other circumstances in order to play the correct sound williamr@2: * associated with certain key presses. williamr@2: * williamr@2: * @param aKeyEvent The scan code of the key that caused the event. williamr@2: */ williamr@2: IMPORT_C void PlaySound(const TKeyEvent& aKeyEvent); williamr@2: williamr@2: /** williamr@2: * Plays a sound corresponding to the given sound ID. The ID can be an application specific ID williamr@2: * or a system specific ID. System specific IDs are specified in Avkon enum @c TAvkonSystemSID. williamr@2: * williamr@2: * @param aSid Sound ID to be played. williamr@2: */ williamr@2: IMPORT_C void PlaySound(TInt aSid); williamr@2: williamr@2: /** williamr@2: * Installs an application specific set of sound IDs. The specified resource ID must be williamr@2: * of the type @c AVKON_SOUND_INFO_LIST. The sound IDs contained in the resource are made williamr@2: * available for use in sound contexts within this application only. The method can only be williamr@2: * used to install a single application sound information list. Calling the method a williamr@2: * second time causes the previous sound information list to be replaced. Note also that williamr@2: * application specific SIDs should be less than 1000. williamr@2: * williamr@2: * @param aResourceId Avkon resource ID. williamr@2: */ williamr@2: IMPORT_C void AddAppSoundInfoListL(TInt aResourceId); williamr@2: williamr@2: /** williamr@2: * This function brings the sounds back to foreground. This function should williamr@2: * be called from @c HandleForegroundEventL(). @c HandleForegroundEventL() is williamr@2: * implemented in @c CAknAppUi and it is reimplemented in @c CAknViewAppUi. williamr@2: * No need to call this function if using the @c KeySounds() method from @c CAknAppUi instead williamr@2: * of @c CAknKeySoundSystem::NewL(). In such case @c CAknAppUi calls this method automatically. williamr@2: */ williamr@2: IMPORT_C void BringToForeground(); williamr@2: williamr@2: /** williamr@2: * Stops playing the sound with given ID. Does nothing if a sound matching the ID is williamr@2: * not playing. williamr@2: * williamr@2: * @param aSid Sound ID to stop. williamr@2: */ williamr@2: IMPORT_C void StopSound(TInt aSid); williamr@2: williamr@2: /** williamr@2: * Locks sound context, which prevents other instances from bringing their sound contexts williamr@2: * topmost. Only the first call is effective, i.e. if some other instance has already williamr@2: * locked its own context, the function does nothing. This is used in system components, williamr@2: * e.g. in key lock where key tones must be disabled while lock is active. williamr@2: */ williamr@2: IMPORT_C void LockContext(); williamr@2: williamr@2: /** williamr@2: * Releases the context lock. After calling this method, all instances can freely modify williamr@2: * their sound contexts again. The caller of the method can be some other instance than williamr@2: * the instance that locked the context. williamr@2: */ williamr@2: IMPORT_C void ReleaseContext(); williamr@2: williamr@2: /** williamr@2: * Reads sound information from given Avkon sound ID. This method is intended for applications williamr@2: * that need Avkon sound definitions for playing sounds with their own audio instances of williamr@2: * Multimedia Framework (such applications should not read Avkon resources as the resource williamr@2: * format can change without any notice but instead use this method). williamr@2: * williamr@2: * @since S60 2.0 williamr@2: * @param aAvkonSid ID for Avkon sound whose information is requested. williamr@2: * @param aInfo Sound information will be put in this structure. williamr@2: * @return @c KErrNone if succesful, @c KErrNotFound if requested sound ID is not found. williamr@2: */ williamr@2: IMPORT_C TInt RequestSoundInfoL(TInt aAvkonSid, CAknSoundInfo& aInfo); williamr@2: williamr@2: /** williamr@2: * Returns top context id from the session. williamr@2: * williamr@2: * @since S60 3.1 williamr@2: * @return The resource id of the context that is at the top of the sound stack. williamr@2: */ williamr@2: IMPORT_C TInt TopContext(); williamr@2: williamr@2: /** williamr@2: * Disables next matching key sound until next pointer up event. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @param aScanCode ScanCode of key which sound is disabled. williamr@2: */ williamr@2: void DisableNextKeySound(TInt aScanCode); williamr@2: williamr@2: private: williamr@2: CAknKeySoundSystem(); williamr@2: void ConstructL(TInt aUid); williamr@2: williamr@2: private: williamr@2: CAknSoundPlayer* iSoundPlayer; williamr@2: TInt iSpare; williamr@2: }; williamr@2: williamr@2: #endif // __AKNSOUNDSYSTEM_H__ williamr@2: williamr@2: // End of file