diff -r 000000000000 -r 5e5d6b214f4f instantmessagesalert/tsrc/testinstantmsgalert/data/Branch_Coverage/indexD1.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/instantmessagesalert/tsrc/testinstantmsgalert/data/Branch_Coverage/indexD1.html Tue Feb 02 10:12:18 2010 +0200 @@ -0,0 +1,996 @@ + + +CTC++ Coverage Report - Execution Profile - cimalertmanager.cpp + + + + + + + + +CTC++ Coverage Report - +Execution Profile +   #1/8

+Directory Summary | Files Summary | Functions Summary | Execution Profile
+To files: First | Previous | Next | Last | Index | No Index


+File: \meco_domain\conversations\instantmessagesalert\src\cimalertmanager.cpp
+Instrumentation mode: function-decision
+TER: 46 % ( 78/168)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Start/ End/    
True False - Line Source

  1 /*
  2  * ==============================================================================
  3  *  Name        : cimalertmanager.cpp
  4  *  Part of     : conversations/instantmessagesalert
  5  *  Description : This class gives interface to play IM message alert
  6  *  Version     : %version: 3 %
  7  *
  8  *  Copyright © 2009 Nokia. All rights reserved..
  9  *  This material, including documentation and any related 
  10  *  computer programs, is protected by copyright controlled by 
  11  *  Nokia Corporation. All rights are reserved. Copying, 
  12  *  including reproducing, storing, adapting or translating, any 
  13  *  or all of this material requires the prior written consent of 
  14  *  Nokia Corporation. This material also contains confidential 
  15  *  information which may not be disclosed to others without the 
  16  *  prior written consent of Nokia Corporation.
  17  * ==============================================================================
  18  */
  19 
  20 // INCLUDE FILES
  21 #include    "cimalertmanager.h"
  22 #include    "imalertdebugprint.h"      
  23 #include    "mimalertmanagerobserver.h"
  24 #include    "mimalertnotifierinterface.h"
  25 #include    "imalertnotifierfactory.h"
  26 
  27 #include    <MProfileEngine.h>
  28 #include   <pathinfo.h>
  29 #include    <mda/common/resource.h>
  30 #include    <audiopreference.h>
  31 #include    <bautils.h>
  32 #include    <hwrmvibrasdkcrkeys.h>
  33 #include    <coreapplicationuisdomainpskeys.h>
  34 #include    <ProfileEngineSDKCRKeys.h>
  35 #include    <MProfileTones.h>
  36 #include    <TProfileToneSettings.h>
  37 #include    <MProfile.h>
  38 #include    <HWRMVibra.h>
  39 
  40 //to get message tone file
  41 #include <cvimpstsettingsstore.h>
  42 
  43 
  44 // CONSTANTS
  45 const TInt KMinVolumeLevel( 1 );
  46 const TInt KMaxVolumeLevel( 10 );
  47 const TInt KToneInterval( 1000000 ); // 1 second pause between tones
  48 
  49 _LIT( KChatRngMimeType, "application/vnd.nokia.ringing-tone" );
  50 _LIT( KBeepOnceSound, "beep.rng" );
  51 _LIT( KProfileSilentTone, "No_Sound.wav" ); 
  52 
  53     
  54 // ============================ MEMBER FUNCTIONS ===============================
  55 
  56 // -----------------------------------------------------------------------------
  57 // CIMAlertManager::CIMAlertManager
  58 // C++ default constructor can NOT contain any code, that
  59 // might leave.
  60 // -----------------------------------------------------------------------------
  61 //
Top
17 17   62 CIMAlertManager::CIMAlertManager()
  63     :   iAudioPlayerStatus( EAudioPlayerNotCreated ),
  64       iTonePlayerStatus( EAudioPlayerNotCreated ),
  65         iIsPlayingDefaultIMSound( EFalse ),
  66         iCallState (EFalse)
  67     {
  68     }
  69 
  70 // ---------------------------------------------------------
  71 // CIMAlertManager::ConstructL
  72 // (other items were commented in a header).
  73 // ---------------------------------------------------------
  74 //
  75 
Top
17 17   76 void CIMAlertManager::ConstructL()
  77     {
  78     CHAT_DP_FUNC_ENTER("ConstructL");    
  79     iProfileApi = CreateProfileEngineL();
  80         
  81     User::LeaveIfError( iFs.Connect() );
  82 
  83     CHAT_DP_TXT("CMdaAudioPlayerUtility::NewL()" );
  84 
  85    iAudioPlayer = CMdaAudioPlayerUtility::NewL( *this );
  86    iAudioPlayerStatus = EAudioPlayerReady;
  87 
  88     CHAT_DP_TXT("CMdaAudioToneUtility::NewL()" );
  89    iTonePlayer = CMdaAudioToneUtility::NewL( *this );
  90    iTonePlayerStatus = EAudioPlayerReady;
  91  
  92     iProfilesRepository = CRepository::NewL( KCRUidProfileEngine );
  93     iVibraRepository = CRepository::NewL( KCRUidVibraCtrl );
  94  
  95     // Get initial settings from active profile
  96     iRingingVolumeNotifyHandler = CCenRepNotifyHandler::NewL( *this, 
  97                                               *iProfilesRepository,
  98                                               CCenRepNotifyHandler::EIntKey,
  99                                               KProEngActiveRingingVolume );
  100     iRingingVolumeNotifyHandler->StartListeningL();
  101     
  102     
  103     iRingingTypeNotifyHandler = CCenRepNotifyHandler::NewL( *this, 
  104                                               *iProfilesRepository,
  105                                               CCenRepNotifyHandler::EIntKey,
  106                                               KProEngActiveRingingType );
  107     iRingingTypeNotifyHandler->StartListeningL();
  108     
  109     
  110     iVibraNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iVibraRepository,
  111                                               CCenRepNotifyHandler::EIntKey,
  112                                               KVibraCtrlProfileVibraEnabled );
  113     iVibraNotifyHandler->StartListeningL();
  114     
  115     User::LeaveIfError( iProfilesRepository->Get( KProEngActiveRingingVolume, 
  116                                                   iRingingVolume ) );
  117                                                  
  118     User::LeaveIfError( iVibraRepository->Get( KVibraCtrlProfileVibraEnabled, 
  119                                                iVibra ) );
  120     
  121     User::LeaveIfError( iApaSession.Connect() );
  122 
  123     // register for changes in message Tone quitting
  124     iNotifierAPI = IMAlertNotifierFactory::CreateNotifierL( this );
  125     iNotifierAPI->ListenKeyChanges( MIMAlertNotifierInterface::EMSGToneQuitKey );
  126     // also register for changes in call state 
  127     iNotifierAPI->ListenKeyChanges( MIMAlertNotifierInterface::ECallState );
  128     iToneFileName = HBufC::NewL( KMaxPath );
  129 
  130     // Get path to beep once ringing tone, first check simple sound folder.
  131     TFileName beepFile = PathInfo::RomRootPath();
  132     beepFile.Append( PathInfo::SimpleSoundsPath() );
  133     beepFile.Append( KBeepOnceSound );
  134     RFile file;
  135     TInt openErr = file.Open( iFs, beepFile, EFileRead );
  136     file.Close();
  137     
17 - 138     if ( openErr == KErrNotFound || openErr == KErrPathNotFound )
  139         {
  140         // Check digital sounds folder
  141         beepFile.Zero();
  142         beepFile.Append( PathInfo::RomRootPath() );
  143         beepFile.Append( PathInfo::DigitalSoundsPath() );
  144         beepFile.Append( KBeepOnceSound );
  145         openErr = file.Open( iFs, beepFile, EFileRead );
  146         file.Close();
  147         }    
  148     
  149     CHAT_DP( D_PLAIN_LIT( "CIMAlertManager::ConstructL() openErr = %d" ), openErr );
  150     
17 - 151     if ( openErr == KErrNone )
  152         {
  153         iBeepRingingTone = beepFile.AllocL();
  154         TPtrC ptr = iBeepRingingTone->Des();
  155         CHAT_DP( D_PLAIN_LIT( "CIMAlertManager::ConstructL() iBeepRingingTone = %S" ), &ptr );
  156         }
    157     else
  158         {
  159         HandleError( openErr );
  160         }
  161 
  162     // get active ringing type, change events come to us later...
  163     iActiveProfile = iProfileApi->ActiveProfileL();
  164     const MProfileTones& profileTones = iActiveProfile->ProfileTones();
  165     const TProfileToneSettings& profileSettings = profileTones.ToneSettings();
  166     iRingingType = profileSettings.iRingingType;
  167     iActiveProfile->Release();
  168     iActiveProfile = NULL; // prevent further usage
  169     // after this, active ringing type changes are notified via the cenrep
  170     // notify handler callback through HandleNotifyInt
  171     
  172     // TRAP to catch leaves, leaves with KErrNotSupported if vibra
  173     // is not supported
17 17   174     TRAPD( err, iVibrator = CHWRMVibra::NewL() );
 - 174   catch (XLeaveException & l)
 - 174   catch (...)
17 - 175     if ( err == KErrNotSupported )
  176         {
  177         // Make sure it's NULL
  178         iVibrator = NULL;
  179         }
    180     else
  181         {
  182         // Leave with other errors e.g. KErrNoMemory
  183         User::LeaveIfError( err );
  184         }
  185     iSettingsStore = CVIMPSTSettingsStore::NewL();
  186     CHAT_DP_FUNC_DONE("ConstructL");
  187     }
  188 
  189 // ---------------------------------------------------------
  190 // CIMAlertManager::NewL
  191 // (other items were commented in a header).
  192 // ---------------------------------------------------------
Top
17   193 EXPORT_C CIMAlertManager* CIMAlertManager::NewL()
  194     {
  195     CIMAlertManager* self = new( ELeave ) CIMAlertManager();
  196 
  197     CleanupStack::PushL( self );
  198     self->ConstructL();
  199     CleanupStack::Pop( self );
  200 
17    201     return self;
  202     }
  203 
  204 
  205 // ---------------------------------------------------------
  206 // CIMAlertManager::~CIMAlertManager
  207 // (other items were commented in a header).
  208 // ---------------------------------------------------------
Top
17 17   209 CIMAlertManager::~CIMAlertManager()
  210     {
  211     CHAT_DP_FUNC_ENTER("~CIMAlertManager");
  212     Stop(); // Stops possible playback
  213 
17 - 214     if ( iActiveProfile )
  215         {
  216         iActiveProfile->Release();
  217         iActiveProfile = NULL; // prevent further usage
  218         }
  219 
17 - 220     if ( iProfileApi ) 
  221         {
  222         iProfileApi->Release();
  223         iProfileApi = NULL;
  224         }
  225 
17 - 226     if ( iVibraNotifyHandler )
  227         {
  228         iVibraNotifyHandler->StopListening();
  229         delete iVibraNotifyHandler;
  230         iVibraNotifyHandler = NULL;
  231         }
  232     
17 - 233     if ( iRingingTypeNotifyHandler )
  234         {
  235         iRingingTypeNotifyHandler->StopListening();
  236         delete iRingingTypeNotifyHandler;
  237         iRingingTypeNotifyHandler = NULL;
  238         }
  239     
  240 
17 - 241     if ( iRingingVolumeNotifyHandler )
  242         {
  243         iRingingVolumeNotifyHandler->StopListening();
  244         delete iRingingVolumeNotifyHandler;
  245         iRingingVolumeNotifyHandler = NULL;
  246         }
17 - 247     if(iProfilesRepository)
  248         {
  249         delete iProfilesRepository;
  250         iProfilesRepository = NULL;
  251         }
17 - 252     if(iVibraRepository)
  253         {
  254         delete iVibraRepository;
  255         iVibraRepository = NULL;
  256         }
  257     
  258     iApaSession.Close();
  259     
17 - 260     if(iNotifierAPI)
  261         {
  262         delete iNotifierAPI;
  263         iNotifierAPI = NULL;
  264         }
  265     
17 - 266     if(iAudioPlayer)
  267         {
  268         CHAT_DP_TXT( "delete CMdaAudioPlayerUtility" );
  269         iAudioPlayer->Close();
  270         delete iAudioPlayer;
  271         iAudioPlayer = NULL;
  272         }
17 - 273     if(iTonePlayer)
  274         {
  275         CHAT_DP_TXT( "delete CMdaAudioToneUtility" );
  276         delete iTonePlayer;
  277         iTonePlayer = NULL;
  278         }
  279     
  280     iObservers.Close();
  281 
17 - 282     if(iToneFileName)
  283         {
  284         delete iToneFileName;
  285         iToneFileName = NULL;
  286         }
  287 
17 - 288     if(iVibrator)
  289         {
  290         delete iVibrator;
  291         iVibrator = NULL;
  292         }
  293 
17 - 294     if(iBeepRingingTone)
  295         {
  296         delete iBeepRingingTone;
  297         iBeepRingingTone = NULL;
  298         }
  299 
  300     iFs.Close();
  301     
17 - 302     if(iSettingsStore)
  303         {
  304         delete iSettingsStore;
  305         iSettingsStore = NULL;
  306         }
  307     
  308     CHAT_DP_FUNC_DONE("~CIMAlertManager");
  309     }
  310 
  311 
  312 // ---------------------------------------------------------
  313 // CIMAlertManager::Play
  314 // (other items were commented in a header).
  315 // ---------------------------------------------------------
  316 //
Top
  317 EXPORT_C void CIMAlertManager::PlayL(TUint32 aServiceId)
  318     {
  319     CHAT_DP_FUNC_ENTER("Play");
- 320     if( !iCallState )
  321         {
  322         Stop();
  323         TRAPD( err, DoPlayL(aServiceId) );
   323     catch (XLeaveException & l)
 - 323     catch (...)
- 324         if( err )
  325             {
  326             HandleError( err );
  327             }
  328         }
  329     CHAT_DP_FUNC_DONE("Play");
  330     }
  331 
  332 // ---------------------------------------------------------
  333 // CIMAlertManager::DoPlayL
  334 // (other items were commented in a header).
  335 // ---------------------------------------------------------
  336 //
Top
  337 EXPORT_C void CIMAlertManager::DoPlayL(TUint32 aServiceId)
  338     {
  339     CHAT_DP_FUNC_ENTER("DoPlayL");
  340 
  341     TBuf<KMaxPath> toneFileName;
  342 
  343     // check if we're silent or not
  344     iActiveProfile = iProfileApi->ActiveProfileL();
  345     TBool isSilent = iActiveProfile->IsSilent();
  346     iActiveProfile->Release();
  347     iActiveProfile = NULL; // prevent further usage
  348 
  349     // vibrate, if it's allowed
  350     CHWRMVibra::TVibraModeState vibraModeState = iVibrator->VibraSettings();
  351     CHWRMVibra::TVibraStatus vibraStatus = iVibrator->VibraStatus();
  352    
  353     // TODO: Find from Nikhil what the behaviour should be if Vibra is already
  354     // on and you get a new message. Aare you supposed to truncate the existing
  355     // vibration and start afresh or let the existing vibration continue?
  356     if ( vibraModeState == CHWRMVibra::EVibraModeON && 
- 357          vibraStatus == CHWRMVibra::EVibraStatusStopped )
  358         {
  359         iVibrator->StartVibraL( KIMVibraDuration );
  360         }
  361 
  362     // sound ordering:
  363     //  silent: get out.
  364     //  beep once: beep, and if ok, exit.
  365     //  if beep failed, or not active: try to play sound
  366     //  for this server.
  367     //  if it failed, play default sound.
  368 
- 369     if ( isSilent ) 
  370         {
  371         // Silent profile, get out.
  372         CHAT_DP_TXT( "DoPlayL - Returning" );
 - 373         return;
  374         }
  375 
  376     TInt err = KErrNone;
  377 
- 378     if ( iRingingType == EProfileRingingTypeBeepOnce && iBeepRingingTone )
  379         {
  380         // Play beep.rng
- 381         TRAP( err, ProcessFileL( *iBeepRingingTone ) );
 - 381     catch (XLeaveException & l)
 - 381     catch (...)
  382         }
  383     
- 384     if ( err != KErrNone || iRingingType != EProfileRingingTypeBeepOnce )
  385         {
  386         err = KErrNone;
  387 
  388         // Beep once not active, or beep once failed.
  389         // Try to play the sound set for this server
  390         TBuf<KMaxPath> toneFileName;
  391       GetToneFileNameL( toneFileName, aServiceId );
  392       TParsePtr parsedPtr( toneFileName );
  393       
  394       CHAT_DP( D_CHAT_LIT(" file = [%S] "),&toneFileName);
  395 
  396       // If alert tone OFF, don't play anything
- 397         if( parsedPtr.NameAndExt().Compare( KProfileSilentTone ) != 0 )
  398             {
  399             // Not OFF
  400             TRAP( err, ProcessFileL( toneFileName ) );        
   400       catch (XLeaveException & l)
 - 400       catch (...)
  401             }
  402         }
  403 
  404     // Not ringing once, but left
  405     User::LeaveIfError( err );
  406 
  407     CHAT_DP_FUNC_DONE("DoPlayL");
  408     }
  409 
  410 // ---------------------------------------------------------
  411 // CIMAlertManager::Stop
  412 // (other items were commented in a header).
  413 // ---------------------------------------------------------
  414 //
Top
22 22   415 EXPORT_C void CIMAlertManager::Stop()
  416     {
  417     CHAT_DP_FUNC_ENTER("Stop");
  418 
22 - 419     if( iAudioPlayerStatus == EAudioPlayerPlaying )
  420         {
  421         CHAT_DP_TXT( 
  422             "Audio player is playing. CMdaAudioPlayerUtility::Stop()" );
  423         iAudioPlayer->Stop();
  424         iAudioPlayer->Close();        
  425         iAudioPlayerStatus = EAudioPlayerReady;
  426         }
  427     
22 - 428     if( iTonePlayerStatus == EAudioPlayerPlaying )
  429         {
  430         CHAT_DP_TXT( 
  431             "Tone player is playing. CMdaAudioToneUtility::CancelPlay()" );
  432         iTonePlayer->CancelPlay();        
  433         iTonePlayerStatus = EAudioPlayerReady;
  434         }    
  435    
  436     CHAT_DP_FUNC_DONE("Stop");
  437     }
  438 
  439 // ---------------------------------------------------------
  440 // CIMAlertManager::SetVolume
  441 // Set the volume at which the sound is played
  442 // (other items were commented in a header).
  443 // ---------------------------------------------------------
  444 //
Top
  445 EXPORT_C void CIMAlertManager::SetVolume( TInt aVolume )
  446     {
  447     iRingingVolumeNotifyHandler->StopListening();
  448     iRingingVolume = aVolume;
  449     }
  450 
  451 // ---------------------------------------------------------
  452 // CIMAlertManager::SetRingingType
  453 // Sets the ringing type how the sound is played
  454 // (other items were commented in a header).
  455 // ---------------------------------------------------------
  456 //
Top
  457 EXPORT_C void CIMAlertManager::SetRingingType( TProfileRingingType aRingingType )
  458     {
- 459     if(iRingingTypeNotifyHandler)
  460         {
  461         iRingingTypeNotifyHandler->StopListening();
  462         iRingingType = aRingingType;
  463         }
  464     }
  465 
  466 // ---------------------------------------------------------
  467 // CIMAlertManager::SetVibra
  468 // Sets the vibrating alert on or off
  469 // (other items were commented in a header).
  470 // ---------------------------------------------------------
  471 //
Top
  472 EXPORT_C void CIMAlertManager::SetVibra( TBool aVibra )
  473     {
- 474     if(iVibraNotifyHandler)
  475         {
  476         iVibraNotifyHandler->StopListening();
  477         iVibra = aVibra;
  478         }
  479     }
  480 
  481 // ---------------------------------------------------------
  482 // CIMAlertManager::AddObserverL
  483 // (other items were commented in a header).
  484 // ---------------------------------------------------------
  485 //
Top
  486 EXPORT_C void CIMAlertManager::AddObserverL( const MIMAlertManagerObserver* aObserver )
  487    {
  488     // make sure that aObserver does not get appended in release mode also.
- 489    if( aObserver )  
  490       {
  491          User::LeaveIfError( iObservers.Append( aObserver ) );
  492       }
  493    }
  494 
  495 // ---------------------------------------------------------
  496 // CIMAlertManager::RemoveObserver
  497 // (other items were commented in a header).
  498 // ---------------------------------------------------------
  499 //
Top
  500 EXPORT_C void CIMAlertManager::RemoveObserver( const MIMAlertManagerObserver* aObserver )
  501    {
  502    TInt index( iObservers.Find( aObserver ) );
  503 
- 504    if( index != KErrNotFound )
  505       {
  506       iObservers.Remove( index );
  507       }
  508    }
  509 
  510 // ---------------------------------------------------------
  511 // CIMAlertManager::ProcessFileL
  512 // If filename is defined, prepare the audioplayer.
  513 // (other items were commented in a header).
  514 // ---------------------------------------------------------
  515 //
Top
  516 void CIMAlertManager::ProcessFileL( const TDesC& aFileName )
  517     {
  518     CHAT_DP_FUNC_ENTER("ProcessFileL");
  519 
  520     TFileName *fileName = new (ELeave) TFileName();
  521     CleanupStack::PushL( fileName );
  522 
  523     // if filename is empty, use default sound
- 524     if ( aFileName.Length() == 0 )
  525         {
 - 526         return;
  527         }
    528     else
  529         {
  530         *fileName = aFileName;
  531         }
  532 
  533     TPtr filePtr( NULL, 0 );
- 534     if( !BaflUtils::FileExists( iFs, *fileName ) )
  535         {
  536         CHAT_DP( D_CHAT_LIT( "File does not exist ( %S )" ), &(*fileName) );
  537         User::Leave( KErrNotFound );
  538         }
  539 
  540     Stop(); // Stops possible playback 
  541 
  542     TUid dummyUid( KNullUid );
  543    TDataType dataType;
  544    
  545     User::LeaveIfError( iApaSession.AppForDocument( *fileName, dummyUid, 
  546                                                     dataType ) );
  547 
- 548     if( dataType.Des().CompareF( KChatRngMimeType ) == 0 ) 
  549         {
  550         // making sure that another initializing is not already ongoing
- 551         if( iTonePlayerStatus == EAudioPlayerReady )
  552             {
  553             CHAT_DP( D_CHAT_LIT( 
  554                 "CMdaAudioToneUtility::PrepareToPlayFileSequence( %S )" ), 
  555                 &(*fileName));
  556             iTonePlayerStatus = EAudioPlayerInitializing;
  557             iTonePlayer->PrepareToPlayFileSequence( *fileName );
  558             }
  559         }
    560     else
  561         {
  562         // making sure that another initializing is not already ongoing
- 563         if( iAudioPlayerStatus == EAudioPlayerReady )
  564             {
  565             CHAT_DP( D_CHAT_LIT(
  566                 "FileList - CMdaAudioPlayerUtility::OpenFileL( %S )" ), 
  567                 &(*fileName));
  568             iAudioPlayerStatus = EAudioPlayerInitializing;
- 569             TRAPD( err, iAudioPlayer->OpenFileL( *fileName ) );
 - 569       catch (XLeaveException & l)
 - 569       catch (...)
  570             CHAT_DP( D_CHAT_LIT(
  571                 "FileList - CMdaAudioPlayerUtility::OpenFileL err = %d" ), 
  572                 err );
- 573             if( err )
  574                 {              
  575                 iAudioPlayerStatus = EAudioPlayerReady;
  576                 User::Leave( err );
  577                 }
  578             }
  579         }    
  580 
  581     CleanupStack::PopAndDestroy( fileName );
  582     CHAT_DP_FUNC_DONE("ProcessFileL");
  583     }
  584 
  585 // ---------------------------------------------------------
  586 // CIMAlertManager::DoSetRingingType
  587 // When audioplayer is ready, set its ringing type
  588 // (other items were commented in a header).
  589 // ---------------------------------------------------------
  590 //
  591 
Top
  592 void CIMAlertManager::DoSetRingingType( TInt aRingingType )
  593     {
- 594     if( iAudioPlayerStatus == EAudioPlayerInitialized )
  595         {
    596         switch( aRingingType )
  597             {
  598          // Fall through
 - 599             case EProfileRingingTypeRingingOnce:
  600                 {
  601                 iAudioPlayer->SetRepeats( 0, 
  602                         TTimeIntervalMicroSeconds( KToneInterval ) );
 - 603                 break;
  604                 }
 - 605             case EProfileRingingTypeBeepOnce:
  606                 {
  607                 iAudioPlayer->SetRepeats( 0, 
  608                         TTimeIntervalMicroSeconds( KToneInterval ) );
 - 609                 break;
  610                 }
 - 611             default:
  612                 {
 - 613                 break;
  614                 }
  615             }
  616         }
- 617     else if( iTonePlayerStatus == EAudioPlayerInitialized )
  618         {
    619         switch( aRingingType )
  620             {
  621          // Fall through
 - 622             case EProfileRingingTypeRingingOnce:
  623                 {
  624                 iTonePlayer->SetRepeats( 0, 
  625                         TTimeIntervalMicroSeconds( KToneInterval ) );
 - 626                 break;
  627                 }
 - 628             case EProfileRingingTypeBeepOnce:
  629                 {
  630                 iTonePlayer->SetRepeats( 0, 
  631                         TTimeIntervalMicroSeconds( KToneInterval ) );
 - 632                 break;
  633                 }
 - 634             default:
  635                 {
 - 636                 break;
  637                 }
  638             }
  639         }
  640     }
  641 
  642 // ---------------------------------------------------------
  643 // CIMAlertManager::ConvertVolume
  644 // Convert volume to the scale used by hardware.
  645 // E.g. Profiles lets user select volume 1-10, but hw's scale is normally 1-9.
  646 // (other items were commented in a header).
  647 // ---------------------------------------------------------
  648 //
Top
  649 TInt CIMAlertManager::ConvertVolume( TInt aVolume )
  650     {
  651     TInt result( 0 );
  652     // if ringing type is "silent" then volume
  653     // is zero
- 654     if( iRingingType != EProfileRingingTypeSilent )
  655         {
  656         if ( iAudioPlayerStatus == EAudioPlayerInitialized ||
- 657             iAudioPlayerStatus == EAudioPlayerPlaying )
  658             {
  659             result = iAudioPlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
- 660             if ( aVolume == KMinVolumeLevel && result == 0 )
  661                 {
  662                 result = 1;
  663                 }
  664             }
  665         else if( iTonePlayerStatus == EAudioPlayerInitialized ||
- 666             iTonePlayerStatus == EAudioPlayerPlaying )
  667             {
  668             result = iTonePlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
- 669             if ( aVolume == KMinVolumeLevel && result == 0 )
  670                 {
  671                 result = 1;
  672                 }
  673             }
  674         }
   675     return result;
  676     }
  677 
  678 // ---------------------------------------------------------
  679 // CIMAlertManager::HandleError
  680 // Notifies all observers that playing is completed
  681 // (other items were commented in a header).
  682 // ---------------------------------------------------------
  683 //
Top
23 23   684 void CIMAlertManager::HandleError( TInt aError )
  685     {
  686     if ( ( aError == KErrNoMemory ) || 
23 - 687          ( aError == KErrDiskFull ) ) 
  688       {
  689       CActiveScheduler::Current()->Error( aError );
  690       }
  691     }
  692 
  693 // ---------------------------------------------------------
  694 // CIMAlertManager::GetToneFileNameL
  695 // (other items were commented in a header).
  696 // ---------------------------------------------------------
  697 //
Top
  698 void CIMAlertManager::GetToneFileNameL( TDes& aToneFileName ,TUint32 aServiceId)
  699    {
  700     RBuf buffer;
  701     buffer.CreateL( RProperty::KMaxPropertySize ); 
  702     CleanupClosePushL( buffer );
  703     iSettingsStore->GetL(aServiceId, EServiceToneFileName, buffer); 
  704     aToneFileName.Copy( buffer );
  705     CleanupStack::PopAndDestroy();  //buffer
  706     }
  707 
  708 // ---------------------------------------------------------
  709 // CIMAlertManager::MapcInitComplete
  710 // This method is called when the audioplayer initialisation is ready.
  711 // If file format is supported, start playing the sound file.
  712 // (other items were commented in a header).
  713 // ---------------------------------------------------------
  714 //
Top
  715 void CIMAlertManager::MapcInitComplete(
  716     TInt aError, const TTimeIntervalMicroSeconds& /* aDuration */ )
  717     {
  718     CHAT_DP( D_CHAT_LIT(
  719         "MMdaAudioPlayerCallback::MapcInitComplete() callback, error == %d" ), 
  720         aError);
  721 
- 722     if ( !aError && iAudioPlayerStatus == EAudioPlayerInitializing )
  723         {
  724         iAudioPlayerStatus = EAudioPlayerInitialized;
  725         // currently IM messages supports only this ringing type
  726         // ringing once
  727         DoSetRingingType( EProfileRingingTypeRingingOnce );
  728         CHAT_DP( D_CHAT_LIT("CMdaAudioPlayerUtility::SetVolume( %d )" ), 
  729                  iRingingVolume);
  730         
  731         iAudioPlayer->SetVolume( ConvertVolume( iRingingVolume ) );
  732         
  733         // TODO: please check the value KAudioPrefNewSpecialMessage.
  734         // WHy does it have this particular value? What is the rationale.
  735         //
  736         CHAT_DP( D_CHAT_LIT("CMdaAudioPlayerUtility::SetPriority( %d, %d )" ),
  737             KAudioPriorityRecvMsg, 
  738             TMdaPriorityPreference( KAudioPrefNewSpecialMessage ) );
  739             
  740         iAudioPlayer->SetPriority( KAudioPriorityRecvMsg,
  741             TMdaPriorityPreference( KAudioPrefNewSpecialMessage ) );
  742             
  743         CHAT_DP_TXT("CMdaAudioPlayerUtility::Play()" );
  744         iAudioPlayer->Play();
  745         iAudioPlayerStatus = EAudioPlayerPlaying;
  746         iNotifierAPI->SetInt( MIMAlertNotifierInterface::EMSGToneQuitKey, 
  747                               ECoreAppUIsTonePlaying );
  748         }
    749     else
  750         {
  751         Stop();
  752         iAudioPlayerStatus = EAudioPlayerReady;
- 753         if( ( ( aError == KErrNotSupported ) || ( aError == KErrCorrupt ) ))
  754             {
 - 755             return;
  756             }
    757         else
  758             {
  759             HandleError( aError );
  760             iIsPlayingDefaultIMSound = EFalse;
  761             }
  762         }
  763     }
  764 
  765 // ---------------------------------------------------------
  766 // CIMAlertManager::MapcPlayComplete
  767 // This method is called when the audioplayer has finished playing a sound
  768 // (other items were commented in a header).
  769 // ---------------------------------------------------------
  770 //
Top
  771 void CIMAlertManager::MapcPlayComplete( TInt aError )
  772     {
  773     CHAT_DP( D_CHAT_LIT(
  774         "MMdaAudioPlayerCallback::MapcPlayComplete() callback, error == %d" ), 
  775         aError);
  776     iNotifierAPI->SetInt( MIMAlertNotifierInterface::EMSGToneQuitKey, ECoreAppUIsTonePlayingUninitialized );
  777     iAudioPlayer->Close();
  778     iAudioPlayerStatus = EAudioPlayerReady;
  779     
- 780     if( ( ( aError == KErrNotSupported ) || ( aError == KErrCorrupt ) ) )
  781         {
 - 782         return;
  783         }
    784     else
  785         {
  786         HandleError( aError );
  787         iIsPlayingDefaultIMSound = EFalse;
  788         }
  789     }
  790 
  791 // ---------------------------------------------------------
  792 // CIMAlertManager::HandleKeyChange
  793 // This method receives notifications from the shared data server
  794 // (other items were commented in a header).
  795 // ---------------------------------------------------------
  796 //
Top
  797 void CIMAlertManager::HandleKeyChange( TUpdatedKey& aUpdatedValues )
  798     {
  799     CHAT_DP_FUNC_ENTER("HandleKeyChange");
  800 
  801     /*Do not play im tone in any of the call state  except EPSCTsyCallStateNone
  802      *     (1) EPSCTsyCallStateNone 
  803      *     (2) EPSCTsyCallStateDialling 
  804      *     (3) EPSCTsyCallStateAlerting 
  805      *     (4) EPSTelephonyCallStateConnected 
  806      *     (5) EPSCTsyCallStateDisconnecting 
  807      *     (6) EPSCTsyCallStateNone
  808      * 
  809      */
- 810     if( aUpdatedValues.iValue == EPSCTsyCallStateNone)
  811         {
  812         iCallState = EFalse;
  813         }
    814     else
  815         {
  816         iCallState = ETrue;       
  817         }
- 818     if(aUpdatedValues.iValue == ECoreAppUIsStopTonePlaying )
  819         {
  820         // Message tone should be stopped
  821         CHAT_DP_TXT( "**stop playing!**" );
  822         Stop();        
  823         }
  824     CHAT_DP_FUNC_DONE("HandleKeyChange");
  825     }
  826 
  827 // ---------------------------------------------------------
  828 // CIMAlertManager::HandleNotifyInt
  829 // (other items were commented in a header).
  830 // ---------------------------------------------------------
Top
  831 void CIMAlertManager::HandleNotifyInt( TUint32 aId, TInt aNewValue )
  832    {
  833     CHAT_DP_FUNC_ENTER("HandleNotifyL");
  834     CHAT_DP( D_CHAT_LIT("aKey == %d" ), aId);
  835     CHAT_DP( D_CHAT_LIT("aValue == %d" ), aNewValue);
  836     
  837 
- 838     if ( aId == KProEngActiveRingingVolume  )  // Ringing volume has changed
  839         {
  840         iRingingVolume = aNewValue;
  841         }
- 842     else if ( aId == KProEngActiveRingingType )  // Ringing type has changed
  843         {
  844         iRingingType = aNewValue;
  845         }
  846 
- 847     if ( aId == KVibraCtrlProfileVibraEnabled )  // Vibra setting has changed
  848         {
  849         iVibra = aNewValue;
  850         }
  851         
  852     CHAT_DP_FUNC_DONE("HandleNotifyL");
  853    }
  854 
  855 // ---------------------------------------------------------
  856 // CIMAlertManager::MatoPrepareComplete
  857 // (other items were commented in a header).
  858 // ---------------------------------------------------------
  859 //
Top
  860 void CIMAlertManager::MatoPrepareComplete( TInt aError )
  861     {
  862     CHAT_DP( D_CHAT_LIT(
  863         "MMdaAudioToneObserver::MatoPrepareComplete() callback, error == %d" ), 
  864         aError);
  865     
- 866     if ( !aError && iTonePlayerStatus == EAudioPlayerInitializing )
  867         {
  868         iTonePlayerStatus = EAudioPlayerInitialized;
  869         // TODO: confirm with UI spec/Nikhil if only this ringing type is
  870         // supported. If not in writing, get an entry into the UI spec done.
  871         // TODO: where is this requirement specified?
  872         
  873         // currently IM messages supports only this ringing type
  874         // ringing once
  875         DoSetRingingType( EProfileRingingTypeRingingOnce );
  876         CHAT_DP( D_CHAT_LIT("CMdaAudioToneUtility::SetVolume( %d )" ), 
  877                 ConvertVolume( iRingingVolume ));
  878         iTonePlayer->SetVolume( ConvertVolume( iRingingVolume ) );
  879 
  880 
  881         CHAT_DP( D_CHAT_LIT("CMdaAudioToneUtility::SetPriority( %d, %d )" ),
  882                 KAudioPriorityRecvMsg, 
  883                 TMdaPriorityPreference( KAudioPrefNewSpecialMessage ) );
  884                 
  885         iTonePlayer->SetPriority( KAudioPriorityRecvMsg,
  886             TMdaPriorityPreference( KAudioPrefNewSpecialMessage ) );
  887             
  888         CHAT_DP_TXT("CMdaAudioToneUtility::Play()" );
  889         iTonePlayer->Play();
  890         iTonePlayerStatus = EAudioPlayerPlaying;
  891         iNotifierAPI->SetInt( MIMAlertNotifierInterface::EMSGToneQuitKey, 
  892                               ECoreAppUIsTonePlaying );
  893         }
    894     else
  895         {
  896         Stop();
  897         iTonePlayerStatus = EAudioPlayerReady;
  898         
- 899         if( ( ( aError == KErrNotSupported ) || ( aError == KErrCorrupt ) ) )
  900             {
 - 901             return;
  902             }
    903         else
  904             {
  905             HandleError( aError );
  906             iIsPlayingDefaultIMSound = EFalse;
  907             }
  908         }
  909     }
  910 
  911 // ---------------------------------------------------------
  912 // CIMAlertManager::MatoPlayComplete
  913 // (other items were commented in a header).
  914 // ---------------------------------------------------------
  915 //
Top
  916 void CIMAlertManager::MatoPlayComplete( TInt aError )
  917     {
  918     CHAT_DP( D_CHAT_LIT(
  919         "MMdaAudioToneObserver::MatoPlayComplete() callback, error == %d" ), 
  920         aError);
  921     iNotifierAPI->SetInt( MIMAlertNotifierInterface::EMSGToneQuitKey, ECoreAppUIsTonePlayingUninitialized );
  922     iTonePlayerStatus = EAudioPlayerReady;
  923     
- 924     if( ( ( aError == KErrNotSupported ) || ( aError == KErrCorrupt ) ) )
  925         {
 - 926         return ;
  927         }
    928     else
  929         {
  930         HandleError( aError );
  931         iIsPlayingDefaultIMSound = EFalse;
  932         }
  933     }
  934         
  935 //  End of File  
***TER 46% (78/168) of SOURCE FILE cimalertmanager.cpp

+Directory Summary | Files Summary | Functions Summary | Execution Profile
+To files: First | Previous | Next | Last | Top | Index | No Index


+