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