iaupdate/IAD/backgroundchecker/src/iaupdatbgnotifyhandler.cpp
branchRCL_3
changeset 65 7333d7932ef7
equal deleted inserted replaced
62:5cc91383ab1e 65:7333d7932ef7
       
     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 //CONSTANTS (-> to iaupdaeuids.h)
       
    28 #define KIAUpdateBgcUid1 0x200211f4    // Bg checker UID
       
    29 const TUint32 KIAUpdateBGNotifyIndicatorRemove = 0x00000003;
       
    30 
       
    31 const TUid KPSUid = { KIAUpdateBgcUid1 };
       
    32 
       
    33 //MACROS
       
    34 _LIT_SECURITY_POLICY_PASS( KReadPolicy );
       
    35 _LIT_SECURITY_POLICY_C1( KWritePolicy, ECapabilityWriteDeviceData );
       
    36 
       
    37 
       
    38 // ================= MEMBER FUNCTIONS =======================
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CIAUpdateBGNotifyHandler::NewL
       
    42 // Two-phased constructor.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CIAUpdateBGNotifyHandler* CIAUpdateBGNotifyHandler::NewL()
       
    46     {
       
    47     CIAUpdateBGNotifyHandler* self = CIAUpdateBGNotifyHandler::NewLC();
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CIAUpdateBGNotifyHandler::NewLC
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CIAUpdateBGNotifyHandler* CIAUpdateBGNotifyHandler::NewLC()
       
    58     {
       
    59     CIAUpdateBGNotifyHandler* self = new( ELeave ) CIAUpdateBGNotifyHandler();
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL();
       
    62     return self;
       
    63     }
       
    64 
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 //  CIAUpdateBGNotifyHandler::ConstructL
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void CIAUpdateBGNotifyHandler::ConstructL()
       
    72     {
       
    73     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::ConstructL() begin");
       
    74     CActiveScheduler::Add( this );
       
    75     TInt err = RProperty::Define( KPSUid, 
       
    76                                   KIAUpdateBGNotifyIndicatorRemove, 
       
    77                                   RProperty::EInt,
       
    78                                   KReadPolicy,
       
    79                                   KWritePolicy );	
       
    80     if ( err != KErrAlreadyExists )
       
    81         {		
       
    82         User::LeaveIfError( err );	
       
    83         }
       
    84     
       
    85     // If not definined, set initial (dummy) value
       
    86     if ( err == KErrNone )
       
    87         {
       
    88         RProperty::Set(KPSUid, KIAUpdateBGNotifyIndicatorRemove, 0);
       
    89         }
       
    90     
       
    91     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::ConstructL() end");   
       
    92     }    
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CIAUpdateBGNotifyHandler::CIAUpdateBGNotifyHandler
       
    96 // constructor
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 CIAUpdateBGNotifyHandler::CIAUpdateBGNotifyHandler()  
       
   100 : CActive( CActive::EPriorityStandard )
       
   101     {
       
   102 
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler
       
   107 // Destructor
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler()
       
   111     {
       
   112     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler() begin");
       
   113     
       
   114     Cancel();
       
   115     iProperty.Close();
       
   116   
       
   117     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::~CIAUpdateBGNotifyHandler() end");    
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CIAUpdateBGNotifyHandler::StartListeningL()
       
   122 // 
       
   123 // ---------------------------------------------------------------------------
       
   124 // 
       
   125 void CIAUpdateBGNotifyHandler::StartListeningL( MIAUpdateBGNotifyObserver* aObserver )
       
   126     {
       
   127     
       
   128     //#define KIAHelloWorldUiUid1 0xA000017F
       
   129     //const TUid KPSUid1 = { KIAUpdateUiUid1 };
       
   130     
       
   131     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::StartListeningL() begin");
       
   132     
       
   133     if ( !iObserver )
       
   134         {
       
   135     	iObserver = aObserver;
       
   136     	User::LeaveIfError( 
       
   137     	        iProperty.Attach( KPSUid, KIAUpdateBGNotifyIndicatorRemove ) );
       
   138         }
       
   139  
       
   140    	Cancel();
       
   141 	iProperty.Subscribe( iStatus );
       
   142     SetActive();
       
   143     
       
   144     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::StartListeningL() end");
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CIAUpdateBGNotifyHandler::DoCancel
       
   149 // 
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void CIAUpdateBGNotifyHandler::DoCancel()
       
   153     {
       
   154     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::DoCancel() begin");
       
   155     
       
   156     iProperty.Cancel();
       
   157     
       
   158     
       
   159     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::DoCancel() end");
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CIAUpdateBGNotifyHandler::RunL
       
   164 // 
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 void CIAUpdateBGNotifyHandler::RunL()
       
   168     {
       
   169     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::RunL() begin");
       
   170    	iProperty.Subscribe( iStatus );
       
   171     SetActive();
       
   172     
       
   173     /* No need to read value so far
       
   174     TInt value = 0;
       
   175 	User::LeaveIfError( RProperty::Get( KPSUid, 
       
   176                                         KIAUpdateUiRefresh, 
       
   177                                         wgId ) );
       
   178     */
       
   179     
       
   180     iObserver->HandleIndicatorRemoveL();
       
   181     
       
   182     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::RunL() end");
       
   183     }
       
   184 
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CIAUpdateBGNotifyHandler::RunError
       
   188 // 
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 TInt CIAUpdateBGNotifyHandler::RunError( TInt /*aError*/ )
       
   192     {
       
   193     FLOG("[IAUPDATE] CIAUpdateBGNotifyHandler::RunError()");
       
   194 	return KErrNone;
       
   195     }
       
   196     
       
   197 // End of File