wvuing/wvaudiomanager/Inc/CCAAudioManager.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003-2005 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:  This class gives interface for playing IM message alert
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCAAUDIOMANAGER_H
       
    21 #define CCAAUDIOMANAGER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "MCANotifierKeyObserver.h"
       
    25 #include <apgcli.h>
       
    26 #include <mdaaudiosampleplayer.h>
       
    27 #include <MdaAudioTonePlayer.h>
       
    28 #include <bldvariant.hrh>
       
    29 
       
    30 #include <centralrepository.h>
       
    31 #include <CenRepNotifyHandler.h>
       
    32 #include <barsc.h>
       
    33 #include <Profile.hrh>
       
    34 #include <e32base.h>
       
    35 
       
    36 #include "MCAAudioInterface.h"
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CFLDRingingTonePlayer;
       
    40 class MProfileEngine;
       
    41 class MCAAudioManagerObserver;
       
    42 class MCANotifierInterface;
       
    43 class MProfile;
       
    44 class CHWRMVibra;
       
    45 #include "MCAAudioInterface.h"
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 class CIMPSPresenceConnectionUi;
       
    49 class CIMPSSAPSettings;
       
    50 class CIMPSSAPSettingsStore;
       
    51 
       
    52 // CLASS DECLARATION
       
    53 
       
    54 /**
       
    55  *  This class gives interface to play
       
    56  *  simple sounds
       
    57  *
       
    58  *  @lib chat.app
       
    59  *  @since 1.2
       
    60  */
       
    61 class CCAAudioManager
       
    62             : public CBase,
       
    63             public MMdaAudioPlayerCallback,
       
    64             public MCANotifierKeyObserver,
       
    65             public MMdaAudioToneObserver,
       
    66             public MCenRepNotifyHandlerCallback,
       
    67             public MCAAudioInterface
       
    68     {
       
    69     protected:  // Enumerations
       
    70 
       
    71         enum TAudioPlayerStatus
       
    72             {
       
    73             EAudioPlayerNotCreated,
       
    74             EAudioPlayerInitializing,
       
    75             EAudioPlayerReady,
       
    76             EAudioPlayerPlaying,
       
    77             EAudioPlayerInitialized
       
    78             };
       
    79 
       
    80     public:  // Constructors and destructor
       
    81 
       
    82         /**
       
    83          * Two-phased constructor.
       
    84          * @param aConnUi - Connection UI
       
    85          * @param aIMLauncherInvoked ETrue if invoked from IMLauncher.
       
    86          */
       
    87         IMPORT_C static CCAAudioManager* NewL( CIMPSPresenceConnectionUi& aConnUi,
       
    88                                                TBool aIMLauncherInvoked = EFalse );
       
    89 
       
    90         /**
       
    91          * Destructor.
       
    92          */
       
    93         virtual ~CCAAudioManager();
       
    94 
       
    95     public: // New functions
       
    96 
       
    97         /**
       
    98          * Starts playing the tone that has been set
       
    99          * @since 1.2
       
   100          */
       
   101         IMPORT_C void PlayL();
       
   102 
       
   103         /**
       
   104          * Stops playing
       
   105          * @since 1.2
       
   106          */
       
   107         IMPORT_C void Stop();
       
   108 
       
   109         /**
       
   110         * Set the volume level on which the sound is played
       
   111         * If this method is not called, player uses the setting
       
   112         * in active profile.
       
   113         * @since 2.6
       
   114         * @param aVolume The volume level
       
   115         */
       
   116         IMPORT_C void SetVolume( TInt aVolume );
       
   117 
       
   118         /**
       
   119         * Sets the ringing type
       
   120         * If this method is not called, player uses the setting
       
   121         * in active profile.
       
   122         * @since 2.6
       
   123         * @param aRingingType The ringing type (see enum TProfileRingingType)
       
   124         */
       
   125         IMPORT_C void SetRingingType( TProfileRingingType aRingingType );
       
   126 
       
   127         /**
       
   128         * Sets vibrating alert on or off.
       
   129         * If this method is not called, player uses the
       
   130         * setting in active profile.
       
   131         * @since 2.6
       
   132         * @param aVibra True: Vibra is on. False: Vibra is off.
       
   133         */
       
   134         IMPORT_C void SetVibra( TBool aVibra );
       
   135 
       
   136         /**
       
   137          * Adds observer, which is informed when playing is completed
       
   138          * @since 2.6
       
   139          * @param aObserver observing object
       
   140          */
       
   141         IMPORT_C void AddObserverL( const MCAAudioManagerObserver* aObserver );
       
   142 
       
   143         /**
       
   144          * Removes observer
       
   145          * @since 2.6
       
   146          * @param aObserver observing object
       
   147          */
       
   148         IMPORT_C void RemoveObserver( const MCAAudioManagerObserver* aObserver );
       
   149 
       
   150     private: // constructors
       
   151 
       
   152         /**
       
   153          * C++ default constructor.
       
   154          * @see CCAAudioManager::NewL
       
   155          */
       
   156         CCAAudioManager( CIMPSPresenceConnectionUi& aConnUi,
       
   157                          TBool aIMLauncherInvoked );
       
   158 
       
   159         /**
       
   160          * By default Symbian 2nd phase constructor is private.
       
   161          */
       
   162         void ConstructL();
       
   163 
       
   164     private:
       
   165         /**
       
   166          * Does the actual sound playing
       
   167          * @since 2.1
       
   168          */
       
   169         void DoPlayL();
       
   170 
       
   171         /**
       
   172          * Starts playing the sound sequence
       
   173          * @since 2.6
       
   174          * @param aSequence The sequence to be processed
       
   175          */
       
   176         void ProcessDesSequence( const TDesC8& aSequence );
       
   177 
       
   178         /**
       
   179          * Starts playing default IM alert sound
       
   180          */
       
   181         void ProcessDefaultAlertSound();
       
   182 
       
   183         /**
       
   184          * Starts playing the sound file
       
   185          * @since 2.6
       
   186          * @param aFileName The file to be processed
       
   187          */
       
   188         void ProcessFileL( const TDesC& aFileName );
       
   189 
       
   190         /** When audioplayer is ready, set its ringing type
       
   191          * @since 2.6
       
   192          * @param aRingingType The ringing type (see enum TRingingTypes)
       
   193          */
       
   194         void DoSetRingingType( TInt aRingingType );
       
   195 
       
   196         /**
       
   197         * Converts volume from 1 to 10 to audio driver understandable value.
       
   198         * @since 2.6
       
   199         * @param aVolume Volume level to be converted.
       
   200         * @return Returns converted volume level
       
   201         */
       
   202         TInt ConvertVolume( TInt aVolume );
       
   203 
       
   204         /**
       
   205          * Informs observers when playing is completed
       
   206          * @since 2.6
       
   207          */
       
   208         void NotifyObservers();
       
   209 
       
   210         /**
       
   211          * Passess error to current activescheluder if
       
   212          * error = KErrNoMemory or KErrDiskFull
       
   213          */
       
   214         void HandleError( TInt aError );
       
   215 
       
   216         /**
       
   217          * Gets tone file name from SAP settings
       
   218          * @param aToneFileName After the call this will
       
   219          *                       contain the tone file name
       
   220          */
       
   221         void GetToneFileNameL( TDes& aToneFileName );
       
   222 
       
   223         /**
       
   224          * Gets the default audio file name
       
   225          * @param aSoundFileName After the call this will
       
   226          *                       contain the default file name
       
   227          */
       
   228         void DefaultSoundFile( TDes& aSoundFileName );
       
   229 
       
   230 
       
   231         /**
       
   232         * Gets editable stored SAP
       
   233         */
       
   234         CIMPSSAPSettings* StoredSAPLC();
       
   235 
       
   236         /**
       
   237          * Gets current SAP
       
   238          */
       
   239         CIMPSSAPSettings* CurrentSAPLC();
       
   240 
       
   241 
       
   242     private:    // Methods derived from MMdaAudioPlayerCallback
       
   243 
       
   244         /**
       
   245         * Derived from MMdaAudioPlayerCallback
       
   246         * This method is called when the audio player initialisation is ready
       
   247         * @see MMdaAudioPlayerCallback
       
   248         */
       
   249         void MapcInitComplete( TInt aError,
       
   250                                const TTimeIntervalMicroSeconds& aDuration );
       
   251 
       
   252         /**
       
   253         * Derived from MMdaAudioPlayerCallback
       
   254         * This method is called when the audio player has finished playing
       
   255         * @see MMdaAudioPlayerCallback
       
   256         */
       
   257         void MapcPlayComplete( TInt aError );
       
   258 
       
   259     private:    // Methods derived from MMdaAudioToneObserver
       
   260 
       
   261         /**
       
   262          * Derived from MMdaAudioToneObserver
       
   263          * This method is called when the tone player initialisation is ready
       
   264          * @see MMdaAudioToneObserver
       
   265          */
       
   266         virtual void MatoPrepareComplete( TInt aError );
       
   267 
       
   268         /**
       
   269         * Derived from MMdaAudioToneObserver
       
   270         * This method is called when the tone player has finished playing
       
   271         * @see MMdaAudioToneObserver
       
   272         */
       
   273         virtual void MatoPlayComplete( TInt aError );
       
   274 
       
   275     private:    // Methods derived from MCANotifierKeyObserver
       
   276 
       
   277         /**
       
   278         * Derived from MCANotifierKeyObserver
       
   279         * Receive a notification from publish and subscribe keys
       
   280         */
       
   281         void HandleKeyChange( TUpdatedKey& aUpdatedValues );
       
   282 
       
   283     private:    // Methods derived from MCenRepNotifyHandlerCallback
       
   284         /**
       
   285         * Derived from MCenRepNotifyHandlerCallback
       
   286         * Receive a notification from central repository server
       
   287         */
       
   288         void HandleNotifyInt( TUint32 aId, TInt aNewValue );
       
   289 
       
   290     private:     // Data
       
   291 
       
   292 
       
   293         // Doesn't own. Profile API  if silent then there is no sounds
       
   294         MProfileEngine* iProfileApi;
       
   295 
       
   296         // Used to play other audio files than ringing tones. Owned.
       
   297         CMdaAudioPlayerUtility* iAudioPlayer;
       
   298         TAudioPlayerStatus iAudioPlayerStatus;
       
   299 
       
   300         // Used to play ringing tones. Owned
       
   301         CMdaAudioToneUtility* iTonePlayer;
       
   302         TAudioPlayerStatus iTonePlayerStatus;
       
   303 
       
   304         // Used for follow if user stops audio playing,
       
   305         // also for profile changes in volume level and vibrating alert
       
   306         CCenRepNotifyHandler* iRingingVolumeNotifyHandler;
       
   307         CCenRepNotifyHandler* iRingingTypeNotifyHandler;
       
   308         CCenRepNotifyHandler* iVibraNotifyHandler;
       
   309 
       
   310         CRepository* iProfilesRepository;
       
   311         CRepository* iVibraRepository;
       
   312 
       
   313         // Used to follow tone quit key
       
   314         MCANotifierInterface* iNotifierAPI;
       
   315 
       
   316         // ringing settings
       
   317         TInt iRingingVolume;
       
   318         TInt iRingingType;
       
   319         TBool iVibra;
       
   320 
       
   321         // Used when checking audio file type
       
   322         RApaLsSession iApaSession;
       
   323 
       
   324         // Audiomanager observers
       
   325         RPointerArray<MCAAudioManagerObserver> iObservers;
       
   326 
       
   327         // Used to keep track if current sound is default sound.
       
   328         TBool iIsPlayingDefaultIMSound;
       
   329 
       
   330         // Tone file name
       
   331         HBufC* iToneFileName;
       
   332 
       
   333         // File session for file operations
       
   334         RFs iFs;
       
   335 
       
   336         // currently active profile (ownership transferred)
       
   337         MProfile* iActiveProfile;
       
   338 
       
   339         // owned, vibra API
       
   340         CHWRMVibra* iVibrator;
       
   341 
       
   342         // ETrue if Always Online is active, invoked from IM Launcher
       
   343         TBool iIMLauncherInvoked;
       
   344 
       
   345         // Beep once ringing tone
       
   346         HBufC* iBeepRingingTone;
       
   347 
       
   348         // owns. Access to central repository
       
   349         CRepository* iCenRep;
       
   350 
       
   351         // Doesnt Own. Connection UI
       
   352         CIMPSPresenceConnectionUi& iConnUI;
       
   353 
       
   354         // Owns, sapsettingstore interface
       
   355         CIMPSSAPSettingsStore* iSapSettings;
       
   356 
       
   357 
       
   358         // ETrue if IMPSCUI Session Id should be preserved upon exit
       
   359         TBool iPreserveSessionIdInExit;
       
   360 
       
   361     };
       
   362 
       
   363 #endif      // CCAAUDIOMANAGER_H
       
   364 
       
   365 // End of File