menucontentsrv/srvsrc/mcsinstallnotifier.cpp
branchRCL_3
changeset 31 8baec10861af
parent 0 79c6a41cd166
equal deleted inserted replaced
30:a5a39a295112 31:8baec10861af
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <javadomainpskeys.h>
    18 #include <javadomainpskeys.h>
    19 #include "mcsinstallnotifier.h"
    19 #include "mcsinstallnotifier.h"
    20 #include <sacls.h>
    20 #include "mcsinstallstrategy.h"
    21 
    21 
    22 CMcsInstallNotifier* CMcsInstallNotifier::NewL(MMcsInstallListener& aListener, TInt aKey)
       
    23 	{
       
    24 	CMcsInstallNotifier* self = new (ELeave) CMcsInstallNotifier( aListener, aKey );
       
    25 	CleanupStack::PushL( self );
       
    26 	self->ConstructL( );
       
    27 	CleanupStack::Pop( self );
       
    28 
    22 
    29 	return self;
    23 CMcsInstallNotifier* CMcsInstallNotifier::NewL(
    30 	}
    24 		MMcsInstallListener& aListener, TNotificationType aNotificationType )
       
    25     {
       
    26     CMcsInstallNotifier* self = new ( ELeave ) CMcsInstallNotifier( aListener );
       
    27     CleanupStack::PushL( self );
       
    28     self->ConstructL( aNotificationType );
       
    29     CleanupStack::Pop( self );
       
    30     return self;
       
    31     }
    31 
    32 
    32 CMcsInstallNotifier::~CMcsInstallNotifier()
    33 CMcsInstallNotifier::~CMcsInstallNotifier()
    33 	{
    34     {
    34     Cancel( );
    35     Cancel();
    35     iProperty.Close( );
    36     iProperty.Close();
    36 	}
    37     delete iNotifierStrategy;
       
    38     }
    37 
    39 
    38 CMcsInstallNotifier::CMcsInstallNotifier( MMcsInstallListener& aListener, TInt aKey ) : 
    40 CMcsInstallNotifier::CMcsInstallNotifier( MMcsInstallListener& aListener ) :
    39     CActive(EPriorityNormal), iListener(aListener)
    41     CActive( EPriorityNormal ), iListener( aListener )
    40 	{
    42     {
    41 	iKey = aKey;
    43     CActiveScheduler::Add( this );
    42 	// Prepare automatically
    44     SetActive();
    43 	iProperty.Attach( KUidSystemCategory, iKey );
    45     }
    44 	CActiveScheduler::Add( this );
       
    45 	iProperty.Subscribe( iStatus );
       
    46 	SetActive( );
       
    47 	}
       
    48 
    46 
    49 
    47 void CMcsInstallNotifier::ConstructL( TNotificationType aNotificationType )
    50 void CMcsInstallNotifier::ConstructL()
    48     {
    51 	{
    49     switch( aNotificationType )
    52 
    50 		{
    53 	}
    51         case ESisInstallNotification:
    54 
    52         	iNotifierStrategy = CMcsSwiInstallStrategy::NewL(
       
    53         	        iProperty, iListener );
       
    54             break;
       
    55         case EJavaInstallNotification:
       
    56         	iNotifierStrategy = CMcsJavaInstallStrategy::NewL(
       
    57         	        iProperty, iListener );
       
    58             break;
       
    59         default:
       
    60         	User::Leave( KErrNotSupported );
       
    61             break;
       
    62 		}
       
    63     iProperty.Subscribe( iStatus );
       
    64     }
    55 
    65 
    56 void CMcsInstallNotifier::DoCancel()
    66 void CMcsInstallNotifier::DoCancel()
    57 	{
    67     {
    58     iProperty.Cancel( );
    68     iProperty.Cancel();
    59 	}
    69     }
    60 
       
    61 
    70 
    62 void CMcsInstallNotifier::RunL()
    71 void CMcsInstallNotifier::RunL()
    63 	{
    72     {
    64 	SetActive( );
    73     SetActive();
    65 	iProperty.Subscribe( iStatus );
    74     iProperty.Subscribe( iStatus );
    66 	TInt status;
    75     iNotifierStrategy->NotifyListenerL();
    67 	User::LeaveIfError( iProperty.Get( KUidSystemCategory,
    76     }
    68 			iKey, status ) );
       
    69 
    77 
    70 	if (( iKey == KPSUidJavaLatestInstallation ) || 
    78 TInt CMcsInstallNotifier::RunError( TInt /*aError*/)
    71 			((status & EInstOpInstall )||(status & EInstOpUninstall )) && 
    79     {
    72 			  (status & EInstOpStatusSuccess) )
    80     // No need to do anything
    73 		{
    81     return KErrNone;
    74 		iListener.HandleInstallNotifyL(status);
    82     }
    75 		}
       
    76 
    83 
    77 	}
       
    78 
       
    79 
       
    80 TInt CMcsInstallNotifier::RunError( TInt /*aError*/ )
       
    81 	{
       
    82     // No need to do anything      
       
    83     return KErrNone;
       
    84 	}