contentstorage/srvsrc/cainstallnotifier.cpp
changeset 66 32469d7d46ff
parent 60 f62f87b200ec
child 119 50e220be30d1
equal deleted inserted replaced
61:8e5041d13c84 66:32469d7d46ff
    14  * Description:  ?Description
    14  * Description:  ?Description
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 #include "cainstallnotifier.h"
    18 #include "cainstallnotifier.h"
       
    19 #include "cainstallstrategy.h"
    19 
    20 
    20 EXPORT_C CCaInstallNotifier* CCaInstallNotifier::NewL(
    21 EXPORT_C CCaInstallNotifier* CCaInstallNotifier::NewL(
    21         MCaInstallListener& aListener, TNotificationType aNotificationType )
    22         MCaInstallListener& aListener, TNotificationType aNotificationType )
    22     {
    23     {
    23     CCaInstallNotifier* self = new ( ELeave ) CCaInstallNotifier(
    24     CCaInstallNotifier* self = new ( ELeave ) CCaInstallNotifier( aListener );
    24             aListener, aNotificationType );
       
    25     CleanupStack::PushL( self );
    25     CleanupStack::PushL( self );
    26     self->ConstructL();
    26     self->ConstructL( aNotificationType );
    27     CleanupStack::Pop( self );
    27     CleanupStack::Pop( self );
    28     return self;
    28     return self;
    29     }
    29     }
    30 
    30 
    31 CCaInstallNotifier::~CCaInstallNotifier()
    31 CCaInstallNotifier::~CCaInstallNotifier()
    32     {
    32     {
    33     Cancel();
    33     Cancel();
    34     iProperty.Close();
    34     iProperty.Close();
       
    35     delete iNotifierStrategy;
    35     }
    36     }
    36 
    37 
    37 CCaInstallNotifier::CCaInstallNotifier( MCaInstallListener& aListener,
    38 CCaInstallNotifier::CCaInstallNotifier( MCaInstallListener& aListener ) :
    38         TNotificationType aNotificationType ) :
       
    39     CActive( EPriorityNormal ), iListener( aListener )
    39     CActive( EPriorityNormal ), iListener( aListener )
    40     {
    40     {
    41     iRPropertyKey = aNotificationType;
       
    42     iProperty.Attach( KUidSystemCategory, iRPropertyKey );
       
    43     CActiveScheduler::Add( this );
    41     CActiveScheduler::Add( this );
    44     iProperty.Subscribe( iStatus );
       
    45     SetActive();
    42     SetActive();
    46     }
    43     }
    47 
    44 
    48 void CCaInstallNotifier::ConstructL()
    45 void CCaInstallNotifier::ConstructL( TNotificationType aNotificationType )
    49     {
    46     {
       
    47     switch( aNotificationType )
       
    48 		{
       
    49         case ESisInstallNotification:
       
    50         	iNotifierStrategy = CCaSwiInstallStrategy::NewL( iProperty );
       
    51             break;
       
    52         case EUsifUninstallNotification:
       
    53         	iNotifierStrategy = CCaUsifUninstallStrategy::NewL( iProperty );
       
    54             break;
       
    55         case EJavaInstallNotification:
       
    56         	iNotifierStrategy = CCaJavaInstallStrategy::NewL( iProperty );
       
    57             break;
       
    58         default:
       
    59         	User::Leave( KErrNotSupported );
       
    60             break;
       
    61 		}
       
    62     iProperty.Subscribe( iStatus );
    50     }
    63     }
    51 
    64 
    52 void CCaInstallNotifier::DoCancel()
    65 void CCaInstallNotifier::DoCancel()
    53     {
    66     {
    54     iProperty.Cancel();
    67     iProperty.Cancel();
    56 
    69 
    57 void CCaInstallNotifier::RunL()
    70 void CCaInstallNotifier::RunL()
    58     {
    71     {
    59     SetActive();
    72     SetActive();
    60     iProperty.Subscribe( iStatus );
    73     iProperty.Subscribe( iStatus );
    61     TInt appUid;
    74     iNotifierStrategy->NotifyListenerL( iProperty, iListener );
    62     User::LeaveIfError( iProperty.Get( KUidSystemCategory, iRPropertyKey,
       
    63             appUid ) );
       
    64     if( appUid )
       
    65         {
       
    66         iListener.HandleInstallNotifyL( appUid );
       
    67         }
       
    68     }
    75     }
    69 
    76 
    70 TInt CCaInstallNotifier::RunError( TInt /*aError*/)
    77 TInt CCaInstallNotifier::RunError( TInt /*aError*/)
    71     {
    78     {
    72     // No need to do anything
    79     // No need to do anything
    73     return KErrNone;
    80     return KErrNone;
    74     }
    81     }
       
    82