classicui_pub/sounds_api/inc/aknsoundsystem.h
branchRCL_3
changeset 20 d48ab3b357f1
parent 0 2f259fa3e83a
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
       
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Interface for controlling keysounds from Avkon.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __AKNSOUNDSYSTEM_H__
       
    19 #define __AKNSOUNDSYSTEM_H__
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <w32std.h>
       
    24 #include <aknSoundinfo.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CAknSoundPlayer;
       
    28 class CAknKeySoundStack;
       
    29 
       
    30 // CLASS DECLARATION
       
    31 /**
       
    32 *  Interface for controlling keysounds from Avkon.
       
    33 *  Provides support for handling key sounds.
       
    34 *  @since S60 0.9
       
    35 */
       
    36 NONSHARABLE_CLASS(CAknKeySoundSystem) : public CBase
       
    37     {
       
    38 public:
       
    39     /**
       
    40     * Base class default constructor. If a client application is derived from @c CAknAppUi, 
       
    41     * its @c KeySounds() method should be used instead to obtain a key sound system instance.
       
    42     * If this method is used, the client needs explicitly call @c BringToForeground().
       
    43     *
       
    44     * @param aUid Application UID.
       
    45     * @return A pointer to a new @c CAknKeySoundSystem object.
       
    46     */
       
    47     IMPORT_C static CAknKeySoundSystem* NewL(TInt aUid);
       
    48 
       
    49     /**
       
    50     * Destructor.
       
    51     */
       
    52     IMPORT_C ~CAknKeySoundSystem();
       
    53 
       
    54     /**
       
    55     * Reads key sound context from resource file and pushes it to the sound stack.
       
    56     * All key presses for the application produce sounds as specified in this key sound context.
       
    57     * The resource specified must be of the @c AVKON_SKEY_LIST type. There are also some default
       
    58     * Avkon contexts available, e.g. @c R_AVKON_DEFAULT_SKEY_LIST and @c R_AVKON_SILENT_SKEY_LIST.
       
    59     *
       
    60     * @param aResourceId Key sound context resource ID.
       
    61     */
       
    62     IMPORT_C void PushContextL(TInt aResourceId);
       
    63 
       
    64     /**
       
    65     * Pops the top context from the key sound stack.
       
    66     */
       
    67     IMPORT_C void PopContext();
       
    68 
       
    69     /**
       
    70     * Plays a sound corresponding to the given key event. This is called directly by Avkon,
       
    71     * though it can be used in other circumstances in order to play the correct sound
       
    72     * associated with certain key presses.
       
    73     *
       
    74     * @param aKeyEvent The scan code of the key that caused the event.
       
    75     */
       
    76     IMPORT_C void PlaySound(const TKeyEvent& aKeyEvent);
       
    77 
       
    78     /**
       
    79     * Plays a sound corresponding to the given sound ID. The ID can be an application specific ID
       
    80     * or a system specific ID. System specific IDs are specified in Avkon enum @c TAvkonSystemSID.
       
    81     *
       
    82     * @param aSid Sound ID to be played.
       
    83     */
       
    84     IMPORT_C void PlaySound(TInt aSid);
       
    85 
       
    86     /**
       
    87     * Installs an application specific set of sound IDs. The specified resource ID must be
       
    88     * of the type @c AVKON_SOUND_INFO_LIST. The sound IDs contained in the resource are made
       
    89     * available for use in sound contexts within this application only. The method can only be
       
    90     * used to install a single application sound information list. Calling the method a
       
    91     * second time causes the previous sound information list to be replaced. Note also that
       
    92     * application specific SIDs should be less than 1000.
       
    93     *
       
    94     * @param aResourceId Avkon resource ID.
       
    95     */
       
    96     IMPORT_C void AddAppSoundInfoListL(TInt aResourceId);
       
    97 
       
    98     /**
       
    99     * This function brings the sounds back to foreground. This function should
       
   100     * be called from @c HandleForegroundEventL(). @c HandleForegroundEventL() is
       
   101     * implemented in @c CAknAppUi and it is reimplemented in @c CAknViewAppUi.
       
   102     * No need to call this function if using the @c KeySounds() method from @c CAknAppUi instead
       
   103     * of @c CAknKeySoundSystem::NewL(). In such case @c CAknAppUi calls this method automatically.
       
   104     */
       
   105     IMPORT_C void BringToForeground();
       
   106 
       
   107     /**
       
   108     * Stops playing the sound with given ID. Does nothing if a sound matching the ID is
       
   109     * not playing.
       
   110     *
       
   111     * @param aSid Sound ID to stop.
       
   112     */
       
   113     IMPORT_C void StopSound(TInt aSid);
       
   114 
       
   115     /**
       
   116     * Locks sound context, which prevents other instances from bringing their sound contexts
       
   117     * topmost. Only the first call is effective, i.e. if some other instance has already
       
   118     * locked its own context, the function does nothing. This is used in system components,
       
   119     * e.g. in key lock where key tones must be disabled while lock is active.
       
   120     */
       
   121     IMPORT_C void LockContext();
       
   122 
       
   123     /**
       
   124     * Releases the context lock. After calling this method, all instances can freely modify
       
   125     * their sound contexts again. The caller of the method can be some other instance than
       
   126     * the instance that locked the context.
       
   127     */
       
   128     IMPORT_C void ReleaseContext();
       
   129 
       
   130     /**
       
   131     * Reads sound information from given Avkon sound ID. This method is intended for applications
       
   132     * that need Avkon sound definitions for playing sounds with their own audio instances of
       
   133     * Multimedia Framework (such applications should not read Avkon resources as the resource
       
   134     * format can change without any notice but instead use this method).
       
   135     *
       
   136     * @since S60 2.0
       
   137     * @param aAvkonSid ID for Avkon sound whose information is requested.
       
   138     * @param aInfo Sound information will be put in this structure.
       
   139     * @return @c KErrNone if succesful, @c KErrNotFound if requested sound ID is not found.
       
   140     */
       
   141     IMPORT_C TInt RequestSoundInfoL(TInt aAvkonSid, CAknSoundInfo& aInfo);
       
   142 
       
   143     /**
       
   144     * Returns top context id from the session.
       
   145     *
       
   146     * @since S60 3.1
       
   147     * @return The resource id of the context that is at the top of the sound stack.
       
   148     */
       
   149     IMPORT_C TInt TopContext();
       
   150 
       
   151     /**
       
   152     * Disables next matching key sound until next pointer up event.
       
   153     *
       
   154     * @since S60 5.0
       
   155     * @param aScanCode ScanCode of key which sound is disabled.
       
   156     */
       
   157     void DisableNextKeySound(TInt aScanCode);
       
   158 
       
   159 private:
       
   160     CAknKeySoundSystem();
       
   161     void ConstructL(TInt aUid);
       
   162 
       
   163 private:
       
   164     CAknSoundPlayer* iSoundPlayer;
       
   165     TInt iSpare;
       
   166     };
       
   167 
       
   168 #endif // __AKNSOUNDSYSTEM_H__
       
   169 
       
   170 // End of file