os/mm/devsoundextensions/globalaudiosettings/src/GlobalAudioSettingsImpl.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006 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:   Implementation of the Phone Profile Settings API
    15 *
    16 */
    17 
    18 
    19 
    20 
    21 // INCLUDE FILES
    22 #include "GlobalAudioSettingsImpl.h"
    23 #include <e32std.h>
    24 #include <GlobalAudioSettingsPSKeys.h>
    25 #include <MGlobalAudioSettingsObserver.h>
    26 #include <centralrepository.h>
    27 #include "AudioClientsListManagerAO.h"
    28 #include <AudioClientsListPSKeys.h>
    29 
    30 #ifdef _DEBUG
    31 #define PRINT_MESSAGE
    32 #endif // _DEBUG
    33 
    34 const TInt KMaxLength=256;
    35 _LIT( KNoSound, "z:\\resource\\No_Sound.wav" );
    36 // ============================ MEMBER FUNCTIONS ===============================
    37 
    38 // -----------------------------------------------------------------------------
    39 // CGlobalAudioSettingsImpl::NewL();
    40 // 
    41 // -----------------------------------------------------------------------------
    42 //
    43 CGlobalAudioSettingsImpl::CGlobalAudioSettingsImpl(
    44                             CGlobalAudioSettings &aGlobalAudioSettings,
    45                             MAudioSettingsObserver& aAudioSettingsObserver)
    46 :iGlobalAudioSettings(aGlobalAudioSettings),
    47  iAudioSettingsObserver(aAudioSettingsObserver)
    48 	{
    49 	}
    50 	
    51 // -----------------------------------------------------------------------------
    52 // CGlobalAudioSettingsImpl::NewL();
    53 // 
    54 // -----------------------------------------------------------------------------
    55 //
    56 CGlobalAudioSettingsImpl* CGlobalAudioSettingsImpl::NewL(
    57                                         CGlobalAudioSettings &aGlobalAudioSettings,
    58                                         MAudioSettingsObserver& aAudioSettingsObserver)
    59 	{
    60 	CGlobalAudioSettingsImpl* self = new (ELeave) CGlobalAudioSettingsImpl(
    61 	                                    aGlobalAudioSettings,aAudioSettingsObserver);
    62     CleanupStack::PushL( self );
    63     self->ConstructL();
    64     CleanupStack::Pop( self );
    65     return self;
    66 	}
    67 	
    68 // -----------------------------------------------------------------------------
    69 // CGlobalAudioSettingsImpl::ConstructL();
    70 // 
    71 // -----------------------------------------------------------------------------
    72 //
    73 void CGlobalAudioSettingsImpl::ConstructL()
    74 	{
    75 	iWarningTonesObserverAO = CWarningTonesObserverAO::NewL(
    76                 	                                        iGlobalAudioSettings,
    77                 	                                        iAudioSettingsObserver,
    78                 	                                        iGlobalAudioSettingsData);
    79 	iWarningTonesObserverAO->Subscribe();
    80 	
    81 	iMessagingTonesObserverAO = CMessagingTonesObserverAO::NewL(
    82                                         	                iGlobalAudioSettings,
    83                                         	                iAudioSettingsObserver,
    84                                         	                iGlobalAudioSettingsData);
    85 	iMessagingTonesObserverAO->Subscribe();
    86 
    87 	iSilentProfileObserverAO = CSilentProfileObserverAO::NewL(
    88                                         	                iGlobalAudioSettings,
    89                                         	                iAudioSettingsObserver,
    90                                         	                iGlobalAudioSettingsData);
    91 	iSilentProfileObserverAO->Subscribe();
    92 
    93 	iVibraObserverAO = CVibraObserverAO::NewL(
    94                         	                iGlobalAudioSettings,
    95                         	                iAudioSettingsObserver,
    96                         	                iGlobalAudioSettingsData);
    97 	iVibraObserverAO->Subscribe();
    98 	iRingingTypeObserverAO = CRingingTypeObserverAO::NewL(
    99 	                                            iGlobalAudioSettings,
   100 	                                            iAudioSettingsObserver,
   101 	                                            iGlobalAudioSettingsData);
   102     iRingingTypeObserverAO->Subscribe();
   103      
   104 	iMessageToneObserverAO = CMessageToneObserverAO::NewL(
   105 	                                            iGlobalAudioSettings,
   106 	                                            iAudioSettingsObserver,
   107 	                                            iGlobalAudioSettingsData);
   108 	iMessageToneObserverAO->Subscribe();
   109 	iEmailToneObserverAO = CEmailToneObserverAO::NewL(
   110 	                                                iGlobalAudioSettings,
   111 	                                                iAudioSettingsObserver,
   112 	                                                iGlobalAudioSettingsData);
   113 	iEmailToneObserverAO->Subscribe();   
   114 	
   115 	
   116     iVideoCallObserverAO = CVideoCallToneObserverAO::NewL(
   117                                                             iGlobalAudioSettings,
   118                                                             iAudioSettingsObserver,
   119                                                             iGlobalAudioSettingsData);
   120     iVideoCallObserverAO->Subscribe();  
   121         
   122     iRingingTone1ObserverAO = CRingingTone1ObserverAO::NewL(
   123                                                                     iGlobalAudioSettings,
   124                                                                     iAudioSettingsObserver,
   125                                                                     iGlobalAudioSettingsData);
   126     iRingingTone1ObserverAO->Subscribe();
   127 	
   128     iRingingTone2ObserverAO = CRingingTone2ObserverAO::NewL(
   129                                                                             iGlobalAudioSettings,
   130                                                                             iAudioSettingsObserver,
   131                                                                             iGlobalAudioSettingsData);
   132     iRingingTone2ObserverAO->Subscribe();  
   133 	
   134     iKeypadToneObserverAO = CKeypadToneObserverAO::NewL(
   135                                                                             iGlobalAudioSettings,
   136                                                                             iAudioSettingsObserver,
   137                                                                             iGlobalAudioSettingsData);
   138     iKeypadToneObserverAO->Subscribe();  
   139                 
   140     iSilenceModeObserverAO = CSilenceModeObserverAO::NewL(
   141                                                                                 iGlobalAudioSettings,
   142                                                                                 iAudioSettingsObserver,
   143                                                                                 iGlobalAudioSettingsData);
   144      iSilenceModeObserverAO->Subscribe();  
   145 	                    
   146     RProperty publicSilenceProperty;
   147 	User::LeaveIfError(publicSilenceProperty.Attach(KGASPSUidGlobalAudioSettings, KGASPublicSilence));
   148 	User::LeaveIfError(publicSilenceProperty.Get(iGlobalAudioSettingsData.iPublicSilence));
   149 	publicSilenceProperty.Close();
   150 
   151     iCAudioClientsListManagerAO = CAudioClientsListManagerAO::NewL( iGlobalAudioSettings,iAudioClientsListObserverArray,KAudioPolicyAudioClients);
   152             
   153     iPausedClientsListManagerAO = CAudioClientsListManagerAO::NewL( iGlobalAudioSettings,iAudioClientsListObserverArray,KAudioPolicyApplicationAudioStatePaused );
   154     }
   155     
   156 // Destructor
   157 CGlobalAudioSettingsImpl::~CGlobalAudioSettingsImpl()
   158     {
   159         delete iWarningTonesObserverAO;
   160         delete iMessagingTonesObserverAO;
   161         delete iSilentProfileObserverAO;
   162         delete iVibraObserverAO;
   163         delete iRingingTypeObserverAO;
   164         delete iMessageToneObserverAO;
   165         delete iEmailToneObserverAO;
   166         delete iVideoCallObserverAO;
   167         delete iRingingTone1ObserverAO;
   168         delete iRingingTone2ObserverAO;
   169         delete iKeypadToneObserverAO;
   170         delete iSilenceModeObserverAO;
   171         delete iCAudioClientsListManagerAO;
   172         delete iPausedClientsListManagerAO;
   173         iAudioClientsListObserverArray.Close();
   174     }
   175 
   176 // -----------------------------------------------------------------------------
   177 // CGlobalAudioSettingsImpl::NewL
   178 // Static function for creating an instance of the EnvironmentalReverb object.
   179 // -----------------------------------------------------------------------------
   180 //
   181  TBool CGlobalAudioSettingsImpl::IsWarningTonesEnabled()
   182 	{
   183 	if(iGlobalAudioSettingsData.iWarningTones)
   184 	    return(ETrue);
   185 	else
   186 	    return(EFalse);
   187 	}
   188 
   189 // -----------------------------------------------------------------------------
   190 // CGlobalAudioSettingsImpl::IsMessageTonesEnabled
   191 // 
   192 // -----------------------------------------------------------------------------
   193 //
   194 TBool CGlobalAudioSettingsImpl::IsMessageTonesEnabled()
   195 	{
   196 	if(iGlobalAudioSettingsData.iMessageTones)
   197 	    return(ETrue);
   198 	else
   199 	    return(EFalse);
   200 	}
   201 
   202 // -----------------------------------------------------------------------------
   203 // CGlobalAudioSettingsImpl::IsSilentProfileEnabled
   204 // 
   205 // -----------------------------------------------------------------------------
   206 //
   207 TBool CGlobalAudioSettingsImpl::IsSilentProfileEnabled()
   208 	{
   209 	if(iGlobalAudioSettingsData.iSilentProfile)
   210 	    return(ETrue);
   211 	else
   212 	    return(EFalse);
   213 	}
   214 
   215 // -----------------------------------------------------------------------------
   216 // CGlobalAudioSettingsImpl::IsVibraEnabled
   217 // 
   218 // -----------------------------------------------------------------------------
   219 //
   220  TBool CGlobalAudioSettingsImpl::IsVibraEnabled()
   221 	{
   222 	if(iGlobalAudioSettingsData.iVibra)
   223 	    return(ETrue);
   224 	else
   225 	    return(EFalse);
   226 	}
   227 
   228 // -----------------------------------------------------------------------------
   229 // CGlobalAudioSettingsImpl::IsPublicSilenceEnabled
   230 // 
   231 // -----------------------------------------------------------------------------
   232 //
   233 TBool CGlobalAudioSettingsImpl::IsPublicSilenceEnabled()
   234 	{
   235 	if(iGlobalAudioSettingsData.iPublicSilence)
   236 	    return(ETrue);
   237 	else
   238 	    return(EFalse);
   239 	}
   240 
   241 
   242 
   243 
   244 TDesC& CGlobalAudioSettingsImpl::MessageAlertTone()
   245     {
   246      return *iGlobalAudioSettingsData.iMessageToneName;
   247     
   248     }
   249 
   250 TBool CGlobalAudioSettingsImpl::IsMessageAlertToneEnabled()
   251     {
   252      if(iGlobalAudioSettingsData.iMessageToneName->CompareF(KNoSound)==0)
   253          return EFalse;
   254      else
   255          return ETrue;
   256     
   257     }
   258  TDesC& CGlobalAudioSettingsImpl::EmailAlertTone()
   259     {
   260     return *iGlobalAudioSettingsData.iEmailToneName;
   261         
   262     }
   263  TBool CGlobalAudioSettingsImpl::IsEmailAlertToneEnabled()
   264      {
   265       if(iGlobalAudioSettingsData.iEmailToneName->CompareF(KNoSound)==0)
   266           return EFalse;
   267       else
   268           return ETrue;
   269      
   270      }
   271   CGlobalAudioSettings::TGASRingingType CGlobalAudioSettingsImpl::RingingType()
   272     {
   273     CGlobalAudioSettings::TGASRingingType type;
   274    type= ( CGlobalAudioSettings::TGASRingingType)iGlobalAudioSettingsData.iRingingType;
   275  
   276       return type;
   277     }
   278   
   279   TDesC& CGlobalAudioSettingsImpl::VideoCallAlertTone()
   280       {
   281       return *iGlobalAudioSettingsData.iVideoCallToneName;
   282       }
   283   TBool CGlobalAudioSettingsImpl::IsVideoCallAlertToneEnabled()
   284       {
   285        if(iGlobalAudioSettingsData.iVideoCallToneName->CompareF(KNoSound)==0)
   286            return EFalse;
   287        else
   288            return ETrue;
   289       
   290       }
   291   TDesC& CGlobalAudioSettingsImpl::RingingAlertTone1()
   292      {
   293      return *iGlobalAudioSettingsData.iRingingTone1Name;
   294      }
   295   TBool CGlobalAudioSettingsImpl::IsRingingAlertTone1Enabled()
   296       {
   297        if(iGlobalAudioSettingsData.iRingingTone1Name->CompareF(KNoSound)==0)
   298            return EFalse;
   299        else
   300            return ETrue;
   301       
   302       }
   303   TDesC& CGlobalAudioSettingsImpl::RingingAlertTone2()
   304      {
   305      return *iGlobalAudioSettingsData.iRingingTone2Name;
   306      }
   307   
   308   TBool CGlobalAudioSettingsImpl::IsRingingAlertTone2Enabled()
   309       {
   310        if(iGlobalAudioSettingsData.iRingingTone2Name->CompareF(KNoSound)==0)
   311            return EFalse;
   312        else
   313            return ETrue;
   314       
   315       }
   316  CGlobalAudioSettings::TGASKeypadVolume CGlobalAudioSettingsImpl::KeyPadToneVolume()
   317      {
   318      return (CGlobalAudioSettings::TGASKeypadVolume)iGlobalAudioSettingsData.iKeyPadVolume;
   319      }
   320  
   321  TBool CGlobalAudioSettingsImpl::IsSilenceModeEnabled()
   322      {
   323       return iGlobalAudioSettingsData.iSilenceMode;
   324      }
   325 // -----------------------------------------------------------------------------
   326 // CGlobalAudioSettingsImpl::RegisterAudioClientsListObserver
   327 // 
   328 // -----------------------------------------------------------------------------
   329 //
   330 TInt CGlobalAudioSettingsImpl::RegisterAudioClientsListObserver(
   331                             MAudioClientsListObserver& aObserver )
   332 	{
   333 	TInt status(KErrAlreadyExists);
   334 	if ( iAudioClientsListObserverArray.Find( &aObserver ) == KErrNotFound )
   335 	    {
   336 	    status = iAudioClientsListObserverArray.Append( &aObserver);
   337 	    if ( ( status == KErrNone ) && (iAudioClientsListObserverArray.Count() == 1 ) )
   338 	        {  	       
   339 	 	    iCAudioClientsListManagerAO->MonitorStart();
   340 	        iPausedClientsListManagerAO->MonitorStart();
   341 	        }
   342 	    }
   343 	return status;
   344 	}
   345         
   346 // -----------------------------------------------------------------------------
   347 // CGlobalAudioSettingsImpl::UnregisterAudioClientsListObserver
   348 // 
   349 // -----------------------------------------------------------------------------
   350 //
   351 TInt CGlobalAudioSettingsImpl::UnregisterAudioClientsListObserver(
   352                             MAudioClientsListObserver& aObserver)
   353 	{
   354 	TInt status(KErrNone);
   355 	status = iAudioClientsListObserverArray.Find( &aObserver );
   356 	if ( status != KErrNotFound )
   357 	    {
   358 	    iAudioClientsListObserverArray.Remove( status );
   359 	    if ( iAudioClientsListObserverArray.Count() == 0 )
   360 	        {
   361 	        iCAudioClientsListManagerAO->MonitorStop();
   362 	        iPausedClientsListManagerAO->MonitorStop();	
   363 	        }
   364 	    }
   365 	return status;
   366 	}
   367 
   368 // -----------------------------------------------------------------------------
   369 // CGlobalAudioSettingsImpl::GetAudioClientsList
   370 // 
   371 // -----------------------------------------------------------------------------
   372 //
   373 TInt CGlobalAudioSettingsImpl::GetAudioClientsList(
   374                         CGlobalAudioSettings::TAudioClientListType aType,
   375                         RArray<TProcessId>& aList )
   376 	{
   377 	TInt status(KErrNone);
   378 	
   379 	switch(aType)
   380 		{
   381 		case CGlobalAudioSettings::EActiveAudioClients:
   382 			{
   383 			status = iCAudioClientsListManagerAO->GetAudioClientsList( aType, aList );	
   384 			}
   385 			break;
   386         case CGlobalAudioSettings::EPausedAudioClients:
   387         	{
   388         	status = iPausedClientsListManagerAO->GetAudioClientsList( aType, aList );     	
   389         	}
   390         	break;
   391 		default:		
   392 			break;
   393 			
   394 		}
   395 	 return status;
   396 	
   397 
   398 	}
   399 
   400 //////////////////////////////////////////////////////////////////////
   401 //	CWarningTonesObserverAO											//
   402 //////////////////////////////////////////////////////////////////////
   403 CWarningTonesObserverAO::CWarningTonesObserverAO(
   404                             CGlobalAudioSettings &aGlobalAudioSettings,
   405                             MAudioSettingsObserver& aAudioSettingsObserver,
   406                             TGlobalAudioSettings& aGlobalAudioSettingsData)
   407 :CActive(EPriorityStandard),
   408  iGlobalAudioSettings(aGlobalAudioSettings),
   409  iAudioSettingsObserver(aAudioSettingsObserver),
   410  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
   411 	{
   412 	CActiveScheduler::Add(this);
   413 	}
   414 
   415 CWarningTonesObserverAO::~CWarningTonesObserverAO()
   416 	{
   417 	Cancel();
   418 	iWarningTonesProperty.Close();
   419 	}
   420 
   421 CWarningTonesObserverAO* CWarningTonesObserverAO::NewL(
   422                         CGlobalAudioSettings &aGlobalAudioSettings,
   423                         MAudioSettingsObserver& aAudioSettingsObserver,
   424                         TGlobalAudioSettings& aGlobalAudioSettingsData)
   425 	{
   426 	CWarningTonesObserverAO* self = new (ELeave) CWarningTonesObserverAO(
   427 	                                                    aGlobalAudioSettings, 
   428 	                                                    aAudioSettingsObserver,
   429 	                                                    aGlobalAudioSettingsData);
   430 	CleanupStack::PushL(self);
   431 	self->ConstructL();
   432 	CleanupStack::Pop();
   433 	return self;
   434 	}
   435 
   436 void CWarningTonesObserverAO::ConstructL()
   437 	{
   438 	User::LeaveIfError(iWarningTonesProperty.Attach(KGASPSUidGlobalAudioSettings, KGASWarningTones));
   439     User::LeaveIfError(iWarningTonesProperty.Get(iGlobalAudioSettingsData.iWarningTones));
   440 	}
   441 	
   442 void CWarningTonesObserverAO::Subscribe()
   443 	{
   444 	if (!IsActive())
   445 	    {
   446     	SetActive();
   447     	iWarningTonesProperty.Subscribe(iStatus);
   448 	    }
   449 	}
   450 
   451 void CWarningTonesObserverAO::RunL()
   452 	{
   453 	TInt status(iStatus.Int());
   454 #ifdef PRINT_MESSAGE
   455     RDebug::Print(_L(" CWarningTonesObserverAO::RunL:iStatus[%d]"), status);
   456 #endif // PRINT_MESSAGE
   457     if ( status == KErrNone )
   458         {
   459         Subscribe();
   460         status = iWarningTonesProperty.Get(iGlobalAudioSettingsData.iWarningTones);
   461         if(status == KErrNone)
   462             {
   463         MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASWarningTones;
   464             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
   465             }
   466 #ifdef PRINT_MESSAGE
   467         else
   468             {
   469             RDebug::Print(_L(" CWarningTonesObserverAO::RunL:Property.Get Error[%d]"), status);            
   470             }
   471 #endif // PRINT_MESSAGE
   472         }
   473 	}
   474 
   475 void CWarningTonesObserverAO::DoCancel()
   476 	{
   477 	iWarningTonesProperty.Cancel();
   478 	}
   479 
   480 TInt CWarningTonesObserverAO::RunError(TInt /*aError*/)
   481 	{
   482 	return KErrNone;
   483 	}
   484 
   485 //////////////////////////////////////////////////////////////////////
   486 //	CMessagingTonesObserverAO											//
   487 //////////////////////////////////////////////////////////////////////
   488 CMessagingTonesObserverAO::CMessagingTonesObserverAO(
   489                                 CGlobalAudioSettings &aGlobalAudioSettings,
   490                                 MAudioSettingsObserver& aAudioSettingsObserver,
   491                                 TGlobalAudioSettings& aGlobalAudioSettingsData)
   492 :CActive(EPriorityStandard),
   493  iGlobalAudioSettings(aGlobalAudioSettings),
   494  iAudioSettingsObserver(aAudioSettingsObserver),
   495  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
   496 	{
   497 	CActiveScheduler::Add(this);
   498 	}
   499 
   500 CMessagingTonesObserverAO::~CMessagingTonesObserverAO()
   501 	{
   502 	Cancel();
   503 	iMessagingTonesProperty.Close();
   504 	}
   505 
   506 CMessagingTonesObserverAO* CMessagingTonesObserverAO::NewL(
   507                                                CGlobalAudioSettings &aGlobalAudioSettings,
   508                                                MAudioSettingsObserver& aAudioSettingsObserver,
   509                                                TGlobalAudioSettings& aGlobalAudioSettingsData)
   510 	{
   511 	CMessagingTonesObserverAO* self = new (ELeave) CMessagingTonesObserverAO(
   512                     	                        aGlobalAudioSettings, aAudioSettingsObserver, 
   513                     	                        aGlobalAudioSettingsData);
   514 	CleanupStack::PushL(self);
   515 	self->ConstructL();
   516 	CleanupStack::Pop();
   517 	return self;
   518 	}
   519 
   520 void CMessagingTonesObserverAO::ConstructL()
   521 	{
   522 	User::LeaveIfError(iMessagingTonesProperty.Attach(KGASPSUidGlobalAudioSettings, KGASMessageTones));
   523 	User::LeaveIfError(iMessagingTonesProperty.Get(iGlobalAudioSettingsData.iMessageTones));
   524 	}
   525 	
   526 void CMessagingTonesObserverAO::Subscribe()
   527 	{
   528 	if (!IsActive())
   529 	    {
   530     	SetActive();
   531     	iMessagingTonesProperty.Subscribe(iStatus);
   532 	    }
   533 	}
   534 
   535 void CMessagingTonesObserverAO::RunL()
   536 	{
   537 	TInt status(iStatus.Int());
   538 #ifdef PRINT_MESSAGE
   539     RDebug::Print(_L(" CMessagingTonesObserverAO::RunL:iStatus[%d]"), status);
   540 #endif // PRINT_MESSAGE
   541     if ( status == KErrNone )
   542         {
   543         Subscribe();
   544         status = iMessagingTonesProperty.Get(iGlobalAudioSettingsData.iMessageTones);
   545         if(status == KErrNone)
   546             {
   547         MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASMessageTones;
   548             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
   549             }
   550 #ifdef PRINT_MESSAGE
   551         else
   552             {
   553             RDebug::Print(_L(" CMessagingTonesObserverAO::RunL:Property.Get Error[%d]"), status);
   554             }
   555 #endif // PRINT_MESSAGE
   556         }
   557 	}
   558 
   559 void CMessagingTonesObserverAO::DoCancel()
   560 	{
   561 	iMessagingTonesProperty.Cancel();
   562 	}
   563 
   564 TInt CMessagingTonesObserverAO::RunError(TInt /*aError*/)
   565 	{
   566 	return KErrNone;
   567 	}
   568 	
   569 //////////////////////////////////////////////////////////////////////
   570 //	CSilentProfileObserverAO											//
   571 //////////////////////////////////////////////////////////////////////
   572 CSilentProfileObserverAO::CSilentProfileObserverAO(
   573                                 CGlobalAudioSettings &aGlobalAudioSettings,
   574                                 MAudioSettingsObserver& aAudioSettingsObserver,
   575                                 TGlobalAudioSettings& aGlobalAudioSettingsData)
   576 :CActive(EPriorityStandard),
   577  iGlobalAudioSettings(aGlobalAudioSettings),
   578  iAudioSettingsObserver(aAudioSettingsObserver),
   579  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
   580 	{
   581 	CActiveScheduler::Add(this);
   582 	}
   583 
   584 CSilentProfileObserverAO::~CSilentProfileObserverAO()
   585 	{
   586 	Cancel();
   587 	iSilentProfileProperty.Close();
   588 	}
   589 
   590 CSilentProfileObserverAO* CSilentProfileObserverAO::NewL(
   591                                         CGlobalAudioSettings &aGlobalAudioSettings,
   592                                         MAudioSettingsObserver& aAudioSettingsObserver,
   593                                         TGlobalAudioSettings& aGlobalAudioSettingsData)
   594 	{
   595 	CSilentProfileObserverAO* self = new (ELeave) CSilentProfileObserverAO(
   596                     	                        aGlobalAudioSettings, aAudioSettingsObserver, 
   597                     	                        aGlobalAudioSettingsData);
   598 	CleanupStack::PushL(self);
   599 	self->ConstructL();
   600 	CleanupStack::Pop();
   601 	return self;
   602 	}
   603 
   604 void CSilentProfileObserverAO::ConstructL()
   605 	{
   606 	User::LeaveIfError(iSilentProfileProperty.Attach(KGASPSUidGlobalAudioSettings, KGASSilentProfile));
   607 	User::LeaveIfError(iSilentProfileProperty.Get(iGlobalAudioSettingsData.iSilentProfile));
   608 	}
   609 	
   610 void CSilentProfileObserverAO::Subscribe()
   611 	{
   612 	if (!IsActive())
   613 	    {
   614     	SetActive();
   615     	iSilentProfileProperty.Subscribe(iStatus);
   616 	    }
   617 	}
   618 
   619 void CSilentProfileObserverAO::RunL()
   620 	{
   621 	TInt status(iStatus.Int());
   622 #ifdef PRINT_MESSAGE
   623     RDebug::Print(_L(" CSilentProfileObserverAO::RunL:iStatus[%d]"), status);
   624 #endif // PRINT_MESSAGE
   625     if ( status == KErrNone )
   626         {
   627         Subscribe();
   628         status = iSilentProfileProperty.Get(iGlobalAudioSettingsData.iSilentProfile);
   629         if(status == KErrNone)
   630             {
   631         MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASSilentProfile;
   632             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
   633             }
   634 #ifdef PRINT_MESSAGE
   635         else
   636             {
   637             RDebug::Print(_L(" CSilentProfileObserverAO::RunL:Property.Get Error[%d]"), status);
   638             }
   639 #endif // PRINT_MESSAGE
   640         }
   641 	}
   642 
   643 void CSilentProfileObserverAO::DoCancel()
   644 	{
   645 	iSilentProfileProperty.Cancel();
   646 	}
   647 
   648 TInt CSilentProfileObserverAO::RunError(TInt /*aError*/)
   649 	{
   650 	return KErrNone;
   651 	}
   652 	
   653 //////////////////////////////////////////////////////////////////////
   654 //	CVibraObserverAO											    //
   655 //////////////////////////////////////////////////////////////////////
   656 CVibraObserverAO::CVibraObserverAO(
   657                         CGlobalAudioSettings &aGlobalAudioSettings,
   658                         MAudioSettingsObserver& aAudioSettingsObserver,
   659                         TGlobalAudioSettings& aGlobalAudioSettingsData)
   660 :CActive(EPriorityStandard),
   661  iGlobalAudioSettings(aGlobalAudioSettings),
   662  iAudioSettingsObserver(aAudioSettingsObserver),
   663  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
   664 	{
   665 	CActiveScheduler::Add(this);
   666 	}
   667 
   668 CVibraObserverAO::~CVibraObserverAO()
   669 	{
   670 	Cancel();
   671 	iVibraProperty.Close();
   672 	}
   673 
   674 CVibraObserverAO* CVibraObserverAO::NewL(
   675                             CGlobalAudioSettings &aGlobalAudioSettings,
   676                             MAudioSettingsObserver& aAudioSettingsObserver,
   677                             TGlobalAudioSettings& aGlobalAudioSettingsData)
   678 	{
   679 	CVibraObserverAO* self = new (ELeave) CVibraObserverAO(
   680                 	                        aGlobalAudioSettings,
   681                 	                        aAudioSettingsObserver, 
   682                 	                        aGlobalAudioSettingsData);
   683 	CleanupStack::PushL(self);
   684 	self->ConstructL();
   685 	CleanupStack::Pop();
   686 	return self;
   687 	}
   688 
   689 void CVibraObserverAO::ConstructL()
   690 	{
   691 	User::LeaveIfError(iVibraProperty.Attach(KGASPSUidGlobalAudioSettings, KGASVibra));
   692 	User::LeaveIfError(iVibraProperty.Get(iGlobalAudioSettingsData.iVibra));
   693 	}
   694 	
   695 void CVibraObserverAO::Subscribe()
   696 	{
   697 	if (!IsActive())
   698 	    {
   699     	SetActive();
   700     	iVibraProperty.Subscribe(iStatus);
   701 	    }
   702 	}
   703 
   704 void CVibraObserverAO::RunL()
   705 	{
   706 	TInt status(iStatus.Int());
   707 #ifdef PRINT_MESSAGE
   708     RDebug::Print(_L(" CVibraObserverAO::RunL:iStatus[%d]"), status);
   709 #endif // PRINT_MESSAGE
   710     if ( status == KErrNone )
   711         {
   712         Subscribe();
   713         status = iVibraProperty.Get(iGlobalAudioSettingsData.iVibra);
   714         if( status == KErrNone)
   715             {
   716         MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASVibra;
   717             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings,id);
   718             }
   719 #ifdef PRINT_MESSAGE
   720         else
   721             {
   722             RDebug::Print(_L(" CVibraObserverAO::RunL:Property.Get Error[%d]"), status);
   723             }
   724 #endif // PRINT_MESSAGE
   725         }
   726 	}
   727 
   728 void CVibraObserverAO::DoCancel()
   729 	{
   730 	iVibraProperty.Cancel();
   731 	}
   732 
   733 TInt CVibraObserverAO::RunError(TInt /*aError*/)
   734 	{
   735 	return KErrNone;
   736 	}
   737 
   738 //////////////////////////////////////////////////////////////////////
   739 //  CRingingTypeObserverAO                                                //
   740 //////////////////////////////////////////////////////////////////////
   741 CRingingTypeObserverAO::CRingingTypeObserverAO(
   742                         CGlobalAudioSettings &aGlobalAudioSettings,
   743                         MAudioSettingsObserver& aAudioSettingsObserver,
   744                         TGlobalAudioSettings& aGlobalAudioSettingsData)
   745 :CActive(EPriorityStandard),
   746  iGlobalAudioSettings(aGlobalAudioSettings),
   747  iAudioSettingsObserver(aAudioSettingsObserver),
   748  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
   749     {
   750     CActiveScheduler::Add(this);
   751     }
   752 
   753 CRingingTypeObserverAO::~CRingingTypeObserverAO()
   754     {
   755     Cancel();
   756     iRingingTypeProperty.Close();
   757     }
   758 
   759 CRingingTypeObserverAO* CRingingTypeObserverAO::NewL(
   760                             CGlobalAudioSettings &aGlobalAudioSettings,
   761                             MAudioSettingsObserver& aAudioSettingsObserver,
   762                             TGlobalAudioSettings& aGlobalAudioSettingsData)
   763     {
   764     CRingingTypeObserverAO* self = new (ELeave) CRingingTypeObserverAO(
   765                                             aGlobalAudioSettings,
   766                                             aAudioSettingsObserver, 
   767                                             aGlobalAudioSettingsData);
   768     CleanupStack::PushL(self);
   769     self->ConstructL();
   770     CleanupStack::Pop();
   771     return self;
   772     }
   773 
   774 void CRingingTypeObserverAO::ConstructL()
   775     {
   776     User::LeaveIfError(iRingingTypeProperty.Attach(KGASPSUidGlobalAudioSettings, KGASRingingType));
   777     TInt value=KErrNone;
   778     User::LeaveIfError(iRingingTypeProperty.Get(value));
   779     iGlobalAudioSettingsData.iRingingType=(CGlobalAudioSettings::TGASRingingType)value;
   780     
   781     }
   782     
   783 void CRingingTypeObserverAO::Subscribe()
   784     {
   785     if (!IsActive())
   786         {
   787         SetActive();
   788         
   789         iRingingTypeProperty.Subscribe(iStatus);
   790         }
   791     }
   792 
   793 void CRingingTypeObserverAO::RunL()
   794     {
   795     TInt status(iStatus.Int());
   796 #ifdef PRINT_MESSAGE
   797     RDebug::Print(_L(" CRingingTypeObserverAO::RunL:iStatus[%d]"), status);
   798 #endif // PRINT_MESSAGE
   799     if ( status == KErrNone )
   800         {
   801         Subscribe();
   802         TInt value=KErrNone;
   803         status=(iRingingTypeProperty.Get(value));
   804         iGlobalAudioSettingsData.iRingingType=(CGlobalAudioSettings::TGASRingingType)value;
   805         if( status == KErrNone)
   806             {
   807         MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASRingingType;
   808             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
   809             }
   810 #ifdef PRINT_MESSAGE
   811         else
   812             {
   813             RDebug::Print(_L(" CRingingTypeObserverAO::RunL:Property.Get Error[%d]"), status);
   814             }
   815 #endif // PRINT_MESSAGE
   816         }
   817     }
   818 
   819 void CRingingTypeObserverAO::DoCancel()
   820     {
   821     iRingingTypeProperty.Cancel();
   822     }
   823 
   824 TInt CRingingTypeObserverAO::RunError(TInt /*aError*/)
   825     {
   826     return KErrNone;
   827     }
   828 
   829 //////////////////////////////////////////////////////////////////////
   830 //  CMessageToneObserverAO                                                //
   831 //////////////////////////////////////////////////////////////////////
   832 CMessageToneObserverAO::CMessageToneObserverAO(
   833                         CGlobalAudioSettings &aGlobalAudioSettings,
   834                         MAudioSettingsObserver& aAudioSettingsObserver,
   835                         TGlobalAudioSettings& aGlobalAudioSettingsData)
   836 :CActive(EPriorityStandard),
   837  iGlobalAudioSettings(aGlobalAudioSettings),
   838  iAudioSettingsObserver(aAudioSettingsObserver),
   839  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
   840     {
   841     CActiveScheduler::Add(this);
   842     }
   843 
   844 CMessageToneObserverAO::~CMessageToneObserverAO()
   845     {
   846     Cancel();
   847     iMessageToneNameProperty.Close();
   848     if( iGlobalAudioSettingsData.iMessageToneName)
   849         {
   850           delete  iGlobalAudioSettingsData.iMessageToneName;
   851           iGlobalAudioSettingsData.iMessageToneName=NULL;
   852         }
   853     }
   854 
   855 CMessageToneObserverAO* CMessageToneObserverAO::NewL(
   856                             CGlobalAudioSettings &aGlobalAudioSettings,
   857                             MAudioSettingsObserver& aAudioSettingsObserver,
   858                             TGlobalAudioSettings& aGlobalAudioSettingsData)
   859     {
   860     CMessageToneObserverAO* self = new (ELeave) CMessageToneObserverAO(
   861                                             aGlobalAudioSettings,
   862                                             aAudioSettingsObserver, 
   863                                             aGlobalAudioSettingsData);
   864     CleanupStack::PushL(self);
   865     self->ConstructL();
   866     CleanupStack::Pop();
   867     return self;
   868     }
   869 
   870 void CMessageToneObserverAO::ConstructL()
   871     {
   872     iGlobalAudioSettingsData.iMessageToneName=HBufC::NewL(KMaxLength);
   873     User::LeaveIfError(iMessageToneNameProperty.Attach(KGASPSUidGlobalAudioSettings, KGASMessageToneName));
   874     TPtr16 ptr=iGlobalAudioSettingsData.iMessageToneName->Des();
   875     User::LeaveIfError(iMessageToneNameProperty.Get(ptr));
   876     
   877     }
   878     
   879 void CMessageToneObserverAO::Subscribe()
   880     {
   881     if (!IsActive())
   882         {
   883         SetActive();
   884         
   885         iMessageToneNameProperty.Subscribe(iStatus);
   886         }
   887     }
   888 
   889 void CMessageToneObserverAO::RunL()
   890     {
   891     TInt status(iStatus.Int());
   892 #ifdef PRINT_MESSAGE
   893     RDebug::Print(_L(" CMessageToneObserverAO::RunL:iStatus[%d]"), status);
   894 #endif // PRINT_MESSAGE
   895     if ( status == KErrNone )
   896         {
   897         Subscribe();
   898         delete iGlobalAudioSettingsData.iMessageToneName;
   899         iGlobalAudioSettingsData.iMessageToneName=NULL;
   900         iGlobalAudioSettingsData.iMessageToneName=HBufC::NewL(KMaxLength);
   901         TPtr16 ptr=iGlobalAudioSettingsData.iMessageToneName->Des();
   902         status = iMessageToneNameProperty.Get(ptr);
   903         if( status == KErrNone)
   904             {
   905             MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASMessageToneName;
   906             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
   907             }
   908 #ifdef PRINT_MESSAGE
   909         else
   910             {
   911             RDebug::Print(_L(" CMessageToneObserverAO::RunL:Property.Get Error[%d]"), status);
   912             }
   913 #endif // PRINT_MESSAGE
   914         }
   915     }
   916 
   917 void CMessageToneObserverAO::DoCancel()
   918     {
   919     iMessageToneNameProperty.Cancel();
   920     }
   921 
   922 TInt CMessageToneObserverAO::RunError(TInt /*aError*/)
   923     {
   924     return KErrNone;
   925     }
   926 
   927 
   928 /////////////////////////////////////////////////////////////////////
   929 //  CEmailToneObserverAO                                                //
   930 //////////////////////////////////////////////////////////////////////
   931 CEmailToneObserverAO::CEmailToneObserverAO(
   932                         CGlobalAudioSettings &aGlobalAudioSettings,
   933                         MAudioSettingsObserver& aAudioSettingsObserver,
   934                         TGlobalAudioSettings& aGlobalAudioSettingsData)
   935 :CActive(EPriorityStandard),
   936  iGlobalAudioSettings(aGlobalAudioSettings),
   937  iAudioSettingsObserver(aAudioSettingsObserver),
   938  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
   939     {
   940     CActiveScheduler::Add(this);
   941     }
   942 
   943 CEmailToneObserverAO::~CEmailToneObserverAO()
   944     {
   945     Cancel();
   946     iEmailToneNameProperty.Close();
   947     
   948     if(iGlobalAudioSettingsData.iEmailToneName)
   949         {
   950         delete  iGlobalAudioSettingsData.iEmailToneName;
   951         iGlobalAudioSettingsData.iEmailToneName=NULL;
   952         }
   953    
   954     }
   955 
   956 CEmailToneObserverAO* CEmailToneObserverAO::NewL(
   957                             CGlobalAudioSettings &aGlobalAudioSettings,
   958                             MAudioSettingsObserver& aAudioSettingsObserver,
   959                             TGlobalAudioSettings& aGlobalAudioSettingsData)
   960     {
   961     CEmailToneObserverAO* self = new (ELeave) CEmailToneObserverAO(
   962                                             aGlobalAudioSettings,
   963                                             aAudioSettingsObserver, 
   964                                             aGlobalAudioSettingsData);
   965     CleanupStack::PushL(self);
   966     self->ConstructL();
   967     CleanupStack::Pop();
   968     return self;
   969     }
   970 
   971 void CEmailToneObserverAO::ConstructL()
   972     {
   973     
   974     iGlobalAudioSettingsData.iEmailToneName=HBufC::NewL(KMaxLength);
   975     User::LeaveIfError(iEmailToneNameProperty.Attach(KGASPSUidGlobalAudioSettings, KGASEmailToneName));
   976     TPtr16 ptr=iGlobalAudioSettingsData.iEmailToneName->Des();
   977     User::LeaveIfError(iEmailToneNameProperty.Get(ptr));
   978     
   979     }
   980     
   981 void CEmailToneObserverAO::Subscribe()
   982     {
   983     if (!IsActive())
   984         {
   985         SetActive();
   986         
   987         iEmailToneNameProperty.Subscribe(iStatus);
   988         }
   989     }
   990 
   991 void CEmailToneObserverAO::RunL()
   992     {
   993     TInt status(iStatus.Int());
   994 #ifdef PRINT_MESSAGE
   995     RDebug::Print(_L(" CEmailToneObserverAO::RunL:iStatus[%d]"), status);
   996 #endif // PRINT_MESSAGE
   997     if ( status == KErrNone )
   998         {
   999         Subscribe();
  1000         delete iGlobalAudioSettingsData.iEmailToneName;
  1001         iGlobalAudioSettingsData.iEmailToneName=NULL;
  1002         iGlobalAudioSettingsData.iEmailToneName=HBufC::NewL(KMaxLength);
  1003         TPtr16 ptr=iGlobalAudioSettingsData.iEmailToneName->Des();
  1004         status = iEmailToneNameProperty.Get(ptr);
  1005         if( status == KErrNone)
  1006             {
  1007             MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASEmailToneName;
  1008             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
  1009             }
  1010 #ifdef PRINT_MESSAGE
  1011         else
  1012             {
  1013             RDebug::Print(_L(" CEmailToneObserverAO::RunL:Property.Get Error[%d]"), status);
  1014             }
  1015 #endif // PRINT_MESSAGE
  1016         }
  1017     }
  1018 
  1019 void CEmailToneObserverAO::DoCancel()
  1020     {
  1021     iEmailToneNameProperty.Cancel();
  1022     }
  1023 
  1024 TInt CEmailToneObserverAO::RunError(TInt /*aError*/)
  1025     {
  1026     return KErrNone;
  1027     }
  1028 
  1029 
  1030 /////////////////////////////////////////////////////////////////////
  1031 //  CVideoCallToneObserverAO                                                //
  1032 //////////////////////////////////////////////////////////////////////
  1033 CVideoCallToneObserverAO::CVideoCallToneObserverAO(
  1034                         CGlobalAudioSettings &aGlobalAudioSettings,
  1035                         MAudioSettingsObserver& aAudioSettingsObserver,
  1036                         TGlobalAudioSettings& aGlobalAudioSettingsData)
  1037 :CActive(EPriorityStandard),
  1038  iGlobalAudioSettings(aGlobalAudioSettings),
  1039  iAudioSettingsObserver(aAudioSettingsObserver),
  1040  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
  1041     {
  1042     CActiveScheduler::Add(this);
  1043     }
  1044 
  1045 CVideoCallToneObserverAO::~CVideoCallToneObserverAO()
  1046     {
  1047     Cancel();
  1048     iVideoCallToneNameProperty.Close();
  1049     if( iGlobalAudioSettingsData.iVideoCallToneName)
  1050         {
  1051     delete  iGlobalAudioSettingsData.iVideoCallToneName;
  1052     iGlobalAudioSettingsData.iVideoCallToneName=NULL;
  1053         }
  1054      
  1055     
  1056     }
  1057 
  1058 CVideoCallToneObserverAO* CVideoCallToneObserverAO::NewL(
  1059                             CGlobalAudioSettings &aGlobalAudioSettings,
  1060                             MAudioSettingsObserver& aAudioSettingsObserver,
  1061                             TGlobalAudioSettings& aGlobalAudioSettingsData)
  1062     {
  1063     CVideoCallToneObserverAO* self = new (ELeave) CVideoCallToneObserverAO(
  1064                                             aGlobalAudioSettings,
  1065                                             aAudioSettingsObserver, 
  1066                                             aGlobalAudioSettingsData);
  1067     CleanupStack::PushL(self);
  1068     self->ConstructL();
  1069     CleanupStack::Pop();
  1070     return self;
  1071     }
  1072 
  1073 void CVideoCallToneObserverAO::ConstructL()
  1074     {
  1075     
  1076     iGlobalAudioSettingsData.iVideoCallToneName=HBufC::NewL(KMaxLength);
  1077     User::LeaveIfError(iVideoCallToneNameProperty.Attach(KGASPSUidGlobalAudioSettings, KGASVideoCallToneName));
  1078     TPtr16 ptr=iGlobalAudioSettingsData.iVideoCallToneName->Des();
  1079     User::LeaveIfError(iVideoCallToneNameProperty.Get(ptr));
  1080     
  1081     }
  1082     
  1083 void CVideoCallToneObserverAO::Subscribe()
  1084     {
  1085     if (!IsActive())
  1086         {
  1087         SetActive();
  1088         
  1089         iVideoCallToneNameProperty.Subscribe(iStatus);
  1090         }
  1091     }
  1092 
  1093 void CVideoCallToneObserverAO::RunL()
  1094     {
  1095     TInt status(iStatus.Int());
  1096 #ifdef PRINT_MESSAGE
  1097     RDebug::Print(_L(" CVideocallToneObserverAO::RunL:iStatus[%d]"), status);
  1098 #endif // PRINT_MESSAGE
  1099     if ( status == KErrNone )
  1100         {
  1101         Subscribe();
  1102         delete iGlobalAudioSettingsData.iVideoCallToneName;
  1103         iGlobalAudioSettingsData.iVideoCallToneName=NULL;
  1104         iGlobalAudioSettingsData.iVideoCallToneName=HBufC::NewL(KMaxLength);
  1105         TPtr16 ptr=iGlobalAudioSettingsData.iVideoCallToneName->Des();
  1106         status = iVideoCallToneNameProperty.Get(ptr);
  1107         if( status == KErrNone)
  1108             {
  1109         MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASVideoCallToneName;
  1110             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
  1111             }
  1112 #ifdef PRINT_MESSAGE
  1113         else
  1114             {
  1115             RDebug::Print(_L(" CVideoCallToneObserverAO::RunL:Property.Get Error[%d]"), status);
  1116             }
  1117 #endif // PRINT_MESSAGE
  1118         }
  1119     }
  1120 
  1121 void CVideoCallToneObserverAO::DoCancel()
  1122     {
  1123     iVideoCallToneNameProperty.Cancel();
  1124     }
  1125 
  1126 TInt CVideoCallToneObserverAO::RunError(TInt /*aError*/)
  1127     {
  1128     return KErrNone;
  1129     }
  1130 
  1131 /////////////////////////////////////////////////////////////////////
  1132 //  CRingingToneObserverAO                                                //
  1133 //////////////////////////////////////////////////////////////////////
  1134 CRingingTone1ObserverAO::CRingingTone1ObserverAO(
  1135                         CGlobalAudioSettings &aGlobalAudioSettings,
  1136                         MAudioSettingsObserver& aAudioSettingsObserver,
  1137                         TGlobalAudioSettings& aGlobalAudioSettingsData)
  1138 :CActive(EPriorityStandard),
  1139  iGlobalAudioSettings(aGlobalAudioSettings),
  1140  iAudioSettingsObserver(aAudioSettingsObserver),
  1141  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
  1142     {
  1143     CActiveScheduler::Add(this);
  1144     }
  1145 
  1146 CRingingTone1ObserverAO::~CRingingTone1ObserverAO()
  1147     {
  1148     Cancel();
  1149     iRingingTone1NameProperty.Close();
  1150     if( iGlobalAudioSettingsData.iRingingTone1Name)
  1151         {
  1152         delete  iGlobalAudioSettingsData.iRingingTone1Name;
  1153         iGlobalAudioSettingsData.iRingingTone1Name=NULL;
  1154         }
  1155     }
  1156 
  1157 CRingingTone1ObserverAO* CRingingTone1ObserverAO::NewL(
  1158                             CGlobalAudioSettings &aGlobalAudioSettings,
  1159                             MAudioSettingsObserver& aAudioSettingsObserver,
  1160                             TGlobalAudioSettings& aGlobalAudioSettingsData)
  1161     {
  1162     CRingingTone1ObserverAO* self = new (ELeave) CRingingTone1ObserverAO(
  1163                                             aGlobalAudioSettings,
  1164                                             aAudioSettingsObserver, 
  1165                                             aGlobalAudioSettingsData);
  1166     CleanupStack::PushL(self);
  1167     self->ConstructL();
  1168     CleanupStack::Pop();
  1169     return self;
  1170     }
  1171 
  1172 void CRingingTone1ObserverAO::ConstructL()
  1173     {
  1174     
  1175     iGlobalAudioSettingsData.iRingingTone1Name=HBufC::NewL(KMaxLength);
  1176     User::LeaveIfError(iRingingTone1NameProperty.Attach(KGASPSUidGlobalAudioSettings, KGASRingingTone1Name));
  1177     TPtr16 ptr=iGlobalAudioSettingsData.iRingingTone1Name->Des();
  1178     User::LeaveIfError(iRingingTone1NameProperty.Get(ptr));
  1179     
  1180     }
  1181     
  1182 void CRingingTone1ObserverAO::Subscribe()
  1183     {
  1184     if (!IsActive())
  1185         {
  1186         SetActive();
  1187         
  1188         iRingingTone1NameProperty.Subscribe(iStatus);
  1189         }
  1190     }
  1191 
  1192 void CRingingTone1ObserverAO::RunL()
  1193     {
  1194     TInt status(iStatus.Int());
  1195 #ifdef PRINT_MESSAGE
  1196     RDebug::Print(_L(" CRingingTone1ObserverAO::RunL:iStatus[%d]"), status);
  1197 #endif // PRINT_MESSAGE
  1198     if ( status == KErrNone )
  1199         {
  1200         Subscribe();
  1201         delete iGlobalAudioSettingsData.iRingingTone1Name;
  1202         iGlobalAudioSettingsData.iRingingTone1Name=NULL;
  1203         iGlobalAudioSettingsData.iRingingTone1Name=HBufC::NewL(KMaxLength);
  1204         TPtr16 ptr=iGlobalAudioSettingsData.iRingingTone1Name->Des();
  1205         status = iRingingTone1NameProperty.Get(ptr);
  1206         if( status == KErrNone)
  1207             {
  1208             MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASRingingTone1Name;
  1209             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
  1210             }
  1211 #ifdef PRINT_MESSAGE
  1212         else
  1213             {
  1214             RDebug::Print(_L(" CRingingToneObserverAO::RunL:Property.Get Error[%d]"), status);
  1215             }
  1216 #endif // PRINT_MESSAGE
  1217         }
  1218     }
  1219 
  1220 void CRingingTone1ObserverAO::DoCancel()
  1221     {
  1222     iRingingTone1NameProperty.Cancel();
  1223     }
  1224 
  1225 TInt CRingingTone1ObserverAO::RunError(TInt /*aError*/)
  1226     {
  1227     return KErrNone;
  1228     }
  1229 
  1230 ////////////////////////////////////////////////////////////////////
  1231 //  CRingingToneObserverAO                                                //
  1232 //////////////////////////////////////////////////////////////////////
  1233 CRingingTone2ObserverAO::CRingingTone2ObserverAO(
  1234                         CGlobalAudioSettings &aGlobalAudioSettings,
  1235                         MAudioSettingsObserver& aAudioSettingsObserver,
  1236                         TGlobalAudioSettings& aGlobalAudioSettingsData)
  1237 :CActive(EPriorityStandard),
  1238  iGlobalAudioSettings(aGlobalAudioSettings),
  1239  iAudioSettingsObserver(aAudioSettingsObserver),
  1240  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
  1241     {
  1242     CActiveScheduler::Add(this);
  1243     }
  1244 
  1245 CRingingTone2ObserverAO::~CRingingTone2ObserverAO()
  1246     {
  1247     Cancel();
  1248     iRingingTone2NameProperty.Close();
  1249     if(iGlobalAudioSettingsData.iRingingTone2Name)
  1250         {
  1251     delete iGlobalAudioSettingsData.iRingingTone2Name;
  1252     iGlobalAudioSettingsData.iRingingTone2Name=NULL;
  1253         }
  1254      
  1255     
  1256     }
  1257 
  1258 CRingingTone2ObserverAO* CRingingTone2ObserverAO::NewL(
  1259                             CGlobalAudioSettings &aGlobalAudioSettings,
  1260                             MAudioSettingsObserver& aAudioSettingsObserver,
  1261                             TGlobalAudioSettings& aGlobalAudioSettingsData)
  1262     {
  1263     CRingingTone2ObserverAO* self = new (ELeave) CRingingTone2ObserverAO(
  1264                                             aGlobalAudioSettings,
  1265                                             aAudioSettingsObserver, 
  1266                                             aGlobalAudioSettingsData);
  1267     CleanupStack::PushL(self);
  1268     self->ConstructL();
  1269     CleanupStack::Pop();
  1270     return self;
  1271     }
  1272 
  1273 void CRingingTone2ObserverAO::ConstructL()
  1274     {
  1275     
  1276     iGlobalAudioSettingsData.iRingingTone2Name=HBufC::NewL(KMaxLength);
  1277     User::LeaveIfError(iRingingTone2NameProperty.Attach(KGASPSUidGlobalAudioSettings, KGASRingingTone2Name));
  1278     TPtr16 ptr=iGlobalAudioSettingsData.iRingingTone2Name->Des();
  1279     User::LeaveIfError(iRingingTone2NameProperty.Get(ptr));
  1280     
  1281     }
  1282     
  1283 void CRingingTone2ObserverAO::Subscribe()
  1284     {
  1285     if (!IsActive())
  1286         {
  1287         SetActive();
  1288         
  1289         iRingingTone2NameProperty.Subscribe(iStatus);
  1290         }
  1291     }
  1292 
  1293 void CRingingTone2ObserverAO::RunL()
  1294     {
  1295     TInt status(iStatus.Int());
  1296 #ifdef PRINT_MESSAGE
  1297     RDebug::Print(_L(" CRingingTone2ObserverAO::RunL:iStatus[%d]"), status);
  1298 #endif // PRINT_MESSAGE
  1299     if ( status == KErrNone )
  1300         {
  1301         Subscribe();
  1302         delete iGlobalAudioSettingsData.iRingingTone2Name;
  1303         iGlobalAudioSettingsData.iRingingTone2Name=NULL;
  1304         iGlobalAudioSettingsData.iRingingTone2Name=HBufC::NewL(KMaxLength);
  1305         TPtr16 ptr=iGlobalAudioSettingsData.iRingingTone2Name->Des();
  1306         status = iRingingTone2NameProperty.Get(ptr);
  1307         if( status == KErrNone)
  1308             {
  1309         MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASRingingTone2Name;
  1310             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
  1311             }
  1312 #ifdef PRINT_MESSAGE
  1313         else
  1314             {
  1315             RDebug::Print(_L(" CRingingToneObserverAO::RunL:Property.Get Error[%d]"), status);
  1316             }
  1317 #endif // PRINT_MESSAGE
  1318         }
  1319     }
  1320 
  1321 void CRingingTone2ObserverAO::DoCancel()
  1322     {
  1323     iRingingTone2NameProperty.Cancel();
  1324     }
  1325 
  1326 TInt CRingingTone2ObserverAO::RunError(TInt /*aError*/)
  1327     {
  1328     return KErrNone;
  1329     }
  1330 
  1331 /////////////////////////////////////////////////////////////////////
  1332 //  CKeypadToneObserverAO                                                //
  1333 //////////////////////////////////////////////////////////////////////
  1334 CKeypadToneObserverAO::CKeypadToneObserverAO(
  1335                         CGlobalAudioSettings &aGlobalAudioSettings,
  1336                         MAudioSettingsObserver& aAudioSettingsObserver,
  1337                         TGlobalAudioSettings& aGlobalAudioSettingsData)
  1338 :CActive(EPriorityStandard),
  1339  iGlobalAudioSettings(aGlobalAudioSettings),
  1340  iAudioSettingsObserver(aAudioSettingsObserver),
  1341  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
  1342     {
  1343     CActiveScheduler::Add(this);
  1344     }
  1345 
  1346 CKeypadToneObserverAO::~CKeypadToneObserverAO()
  1347     {
  1348     Cancel();
  1349     iKeypadToneVolumeProperty.Close();
  1350     }
  1351 
  1352 CKeypadToneObserverAO* CKeypadToneObserverAO::NewL(
  1353                             CGlobalAudioSettings &aGlobalAudioSettings,
  1354                             MAudioSettingsObserver& aAudioSettingsObserver,
  1355                             TGlobalAudioSettings& aGlobalAudioSettingsData)
  1356     {
  1357     CKeypadToneObserverAO* self = new (ELeave) CKeypadToneObserverAO(
  1358                                             aGlobalAudioSettings,
  1359                                             aAudioSettingsObserver, 
  1360                                             aGlobalAudioSettingsData);
  1361     CleanupStack::PushL(self);
  1362     self->ConstructL();
  1363     CleanupStack::Pop();
  1364     return self;
  1365     }
  1366 
  1367 void CKeypadToneObserverAO::ConstructL()
  1368     {
  1369     
  1370     
  1371     User::LeaveIfError(iKeypadToneVolumeProperty.Attach(KGASPSUidGlobalAudioSettings, KGASKeypadToneVolume));
  1372     TInt value=KErrNone;
  1373     User::LeaveIfError(iKeypadToneVolumeProperty.Get(value));
  1374     iGlobalAudioSettingsData.iKeyPadVolume=(CGlobalAudioSettings::TGASKeypadVolume)value;
  1375     }
  1376     
  1377 void CKeypadToneObserverAO::Subscribe()
  1378     {
  1379     if (!IsActive())
  1380         {
  1381         SetActive();
  1382         
  1383         iKeypadToneVolumeProperty.Subscribe(iStatus);
  1384         }
  1385     }
  1386 
  1387 void CKeypadToneObserverAO::RunL()
  1388     {
  1389     TInt status(iStatus.Int());
  1390 #ifdef PRINT_MESSAGE
  1391     RDebug::Print(_L(" CKeypadToneObserverAO::RunL:iStatus[%d]"), status);
  1392 #endif // PRINT_MESSAGE
  1393     if ( status == KErrNone )
  1394         {
  1395         Subscribe();
  1396         TInt value=KErrNone;
  1397             status=iKeypadToneVolumeProperty.Get(value);
  1398             iGlobalAudioSettingsData.iKeyPadVolume=(CGlobalAudioSettings::TGASKeypadVolume)value;
  1399         
  1400         
  1401         if( status == KErrNone)
  1402             {
  1403             MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASKeyPadVolume;
  1404             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
  1405             }
  1406 #ifdef PRINT_MESSAGE
  1407         else
  1408             {
  1409             RDebug::Print(_L(" CKeypadToneObserverAO::RunL:Property.Get Error[%d]"), status);
  1410             }
  1411 #endif // PRINT_MESSAGE
  1412         }
  1413     }
  1414 
  1415 void CKeypadToneObserverAO::DoCancel()
  1416     {
  1417     iKeypadToneVolumeProperty.Cancel();
  1418     }
  1419 
  1420 TInt CKeypadToneObserverAO::RunError(TInt /*aError*/)
  1421     {
  1422     return KErrNone;
  1423     }
  1424 
  1425 
  1426 /////////////////////////////////////////////////////////////////////
  1427 //  CSilenceModeObserverAO                                                //
  1428 //////////////////////////////////////////////////////////////////////
  1429 CSilenceModeObserverAO::CSilenceModeObserverAO(
  1430                         CGlobalAudioSettings &aGlobalAudioSettings,
  1431                         MAudioSettingsObserver& aAudioSettingsObserver,
  1432                         TGlobalAudioSettings& aGlobalAudioSettingsData)
  1433 :CActive(EPriorityStandard),
  1434  iGlobalAudioSettings(aGlobalAudioSettings),
  1435  iAudioSettingsObserver(aAudioSettingsObserver),
  1436  iGlobalAudioSettingsData(aGlobalAudioSettingsData)
  1437     {
  1438     CActiveScheduler::Add(this);
  1439     }
  1440 
  1441 CSilenceModeObserverAO::~CSilenceModeObserverAO()
  1442     {
  1443     Cancel();
  1444     iSilenceModeProperty.Close();
  1445     }
  1446 
  1447 CSilenceModeObserverAO* CSilenceModeObserverAO::NewL(
  1448                             CGlobalAudioSettings &aGlobalAudioSettings,
  1449                             MAudioSettingsObserver& aAudioSettingsObserver,
  1450                             TGlobalAudioSettings& aGlobalAudioSettingsData)
  1451     {
  1452     CSilenceModeObserverAO* self = new (ELeave) CSilenceModeObserverAO(
  1453                                             aGlobalAudioSettings,
  1454                                             aAudioSettingsObserver, 
  1455                                             aGlobalAudioSettingsData);
  1456     CleanupStack::PushL(self);
  1457     self->ConstructL();
  1458     CleanupStack::Pop();
  1459     return self;
  1460     }
  1461 
  1462 void CSilenceModeObserverAO::ConstructL()
  1463     {
  1464     
  1465     
  1466     User::LeaveIfError(iSilenceModeProperty.Attach(KGASPSUidGlobalAudioSettings, KGASSilenceMode));
  1467    
  1468     User::LeaveIfError(iSilenceModeProperty.Get(iGlobalAudioSettingsData.iSilenceMode));
  1469     RDebug::Printf("in constructL,silence mode %d",iGlobalAudioSettingsData.iSilenceMode);
  1470   
  1471     }
  1472     
  1473 void CSilenceModeObserverAO::Subscribe()
  1474     {
  1475     if (!IsActive())
  1476         {
  1477         SetActive();
  1478         
  1479         iSilenceModeProperty.Subscribe(iStatus);
  1480         }
  1481     }
  1482 
  1483 void CSilenceModeObserverAO::RunL()
  1484     {
  1485     TInt status(iStatus.Int());
  1486 #ifdef PRINT_MESSAGE
  1487     RDebug::Print(_L(" CSilenceModeObserverAO::RunL:iStatus[%d]"), status);
  1488 #endif // PRINT_MESSAGE
  1489     if ( status == KErrNone )
  1490         {
  1491         Subscribe();
  1492        
  1493             status=iSilenceModeProperty.Get(  iGlobalAudioSettingsData.iSilenceMode);
  1494             RDebug::Printf("value of silent mode :%d",iGlobalAudioSettingsData.iSilenceMode);
  1495         
  1496         
  1497         if( status == KErrNone)
  1498             {
  1499             MAudioSettingsObserver::TGASEventId id=MAudioSettingsObserver::EGASSilenceMode;
  1500             iAudioSettingsObserver.SettingsChanged(iGlobalAudioSettings, id);
  1501             }
  1502 #ifdef PRINT_MESSAGE
  1503         else
  1504             {
  1505             RDebug::Print(_L(" CKeypadToneObserverAO::RunL:Property.Get Error[%d]"), status);
  1506             }
  1507 #endif // PRINT_MESSAGE
  1508         }
  1509     }
  1510 
  1511 void CSilenceModeObserverAO::DoCancel()
  1512     {
  1513     iSilenceModeProperty.Cancel();
  1514     }
  1515 
  1516 TInt CSilenceModeObserverAO::RunError(TInt /*aError*/)
  1517     {
  1518     return KErrNone;
  1519     }
  1520 
  1521 //End of file