iaupdate/IAD/backgroundchecker/src/iaupdatebgnotifyhandler.cpp
changeset 69 b18a4bf55ddb
equal deleted inserted replaced
64:48c14c385b0e 69:b18a4bf55ddb
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This module contains the implementation of CIAUpdateBGNotifyHandler class 
       
    15 *                member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //INCLUDES
       
    21 #include <e32property.h>
       
    22 
       
    23 #include "iaupdatebgnotifyhandler.h"
       
    24 #include "iaupdateuids.h"
       
    25 #include "iaupdatebglogger.h"
       
    26 
       
    27 //MACROS
       
    28 _LIT_SECURITY_POLICY_PASS( KReadPolicy );
       
    29 _LIT_SECURITY_POLICY_C1( KWritePolicy, ECapabilityWriteDeviceData );
       
    30 
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CIAUpdateBGNotifyHandler::NewL
       
    36 // Two-phased constructor.
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CIAUpdateBGNotifyHandler* CIAUpdateBGNotifyHandler::NewL()
       
    40     {
       
    41     CIAUpdateBGNotifyHandler* self = CIAUpdateBGNotifyHandler::NewLC();
       
    42     CleanupStack::Pop( self );
       
    43     return self;
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CIAUpdateBGNotifyHandler::NewLC
       
    48 // Two-phased constructor.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CIAUpdateBGNotifyHandler* CIAUpdateBGNotifyHandler::NewLC()
       
    52     {
       
    53     CIAUpdateBGNotifyHandler* self = new( ELeave ) CIAUpdateBGNotifyHandler();
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL();
       
    56     return self;
       
    57     }
       
    58 
       
    59 
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 //  CIAUpdateBGNotifyHandler::ConstructL
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CIAUpdateBGNotifyHandler::ConstructL()
       
    66     {
       
    67     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::ConstructL() begin");
       
    68     CActiveScheduler::Add( this );
       
    69     TInt err = RProperty::Define( KPSUidBgc, 
       
    70                                   KIAUpdateBGNotifyIndicatorRemove, 
       
    71                                   RProperty::EInt,
       
    72                                   KReadPolicy,
       
    73                                   KWritePolicy );	
       
    74     if ( err != KErrAlreadyExists )
       
    75         {		
       
    76         User::LeaveIfError( err );	
       
    77         }
       
    78     
       
    79     // If not definined, set initial (dummy) value
       
    80     if ( err == KErrNone )
       
    81         {
       
    82         RProperty::Set(KPSUidBgc, KIAUpdateBGNotifyIndicatorRemove, 0);
       
    83         }
       
    84     
       
    85     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::ConstructL() end");   
       
    86     }    
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CIAUpdateBGNotifyHandler::CIAUpdateBGNotifyHandler
       
    90 // constructor
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CIAUpdateBGNotifyHandler::CIAUpdateBGNotifyHandler()  
       
    94 : CActive( CActive::EPriorityStandard )
       
    95     {
       
    96 
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler
       
   101 // Destructor
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler()
       
   105     {
       
   106     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler() begin");
       
   107     
       
   108     Cancel();
       
   109     iProperty.Close();
       
   110   
       
   111     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler() end");    
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CIAUpdateBGNotifyHandler::StartListeningL()
       
   116 // 
       
   117 // ---------------------------------------------------------------------------
       
   118 // 
       
   119 void CIAUpdateBGNotifyHandler::StartListeningL( MIAUpdateBGNotifyObserver* aObserver )
       
   120     {
       
   121     
       
   122     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::StartListeningL() begin");
       
   123     
       
   124     if ( !iObserver )
       
   125         {
       
   126     	iObserver = aObserver;
       
   127     	User::LeaveIfError( 
       
   128     	        iProperty.Attach( KPSUidBgc, KIAUpdateBGNotifyIndicatorRemove ) );
       
   129         }
       
   130  
       
   131    	Cancel();
       
   132 	iProperty.Subscribe( iStatus );
       
   133     SetActive();
       
   134     
       
   135     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::StartListeningL() end");
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CIAUpdateBGNotifyHandler::DoCancel
       
   140 // 
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CIAUpdateBGNotifyHandler::DoCancel()
       
   144     {
       
   145     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::DoCancel() begin");
       
   146     
       
   147     iProperty.Cancel();
       
   148     
       
   149     
       
   150     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::DoCancel() end");
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CIAUpdateBGNotifyHandler::RunL
       
   155 // 
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 void CIAUpdateBGNotifyHandler::RunL()
       
   159     {
       
   160     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::RunL() begin");
       
   161    	iProperty.Subscribe( iStatus );
       
   162     SetActive();
       
   163     
       
   164     /* No need to read value so far
       
   165     TInt value = 0;
       
   166 	User::LeaveIfError( RProperty::Get( KPSUidBgc, 
       
   167 	                                    KIAUpdateBGNotifyIndicatorRemove, 
       
   168                                         value ) );
       
   169     */
       
   170     
       
   171     iObserver->HandleIndicatorRemoveL();
       
   172     
       
   173     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::RunL() end");
       
   174     }
       
   175 
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CIAUpdateBGNotifyHandler::RunError
       
   179 // 
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 TInt CIAUpdateBGNotifyHandler::RunError( TInt /*aError*/ )
       
   183     {
       
   184     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::RunError()");
       
   185 	return KErrNone;
       
   186     }
       
   187     
       
   188 // End of File