locationcentre/lcserver/src/lcregistryupdate.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 00:16:03 +0200
changeset 0 522cd55cc3d7
permissions -rw-r--r--
Revision: 201003 Kit: 201005

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Location Centre Server object.
*
*/


// SYSTEM INCLUDES

// USER INCLUDES
#include "lcregistryupdate.h"
#include "lcregistrationupdatenotifier.h"
#include "lcdebug.h"

// CONSTANT DEFINTIONS
_LIT(KFileName,"?:\\private\\10283138\\import\\");

const TInt KLCUpdateDelay = 2000000;


// ============================ MEMBER FUNCTIONS ==============================
// ----------------------------------------------------------------------------
// CLcRegistryUpdate::CLcRegistryUpdate
// C++ default constructor can NOT contain any code, that
// might leave.
// ----------------------------------------------------------------------------
//
CLcRegistryUpdate::CLcRegistryUpdate(MLcRegistryUpdateNotifier& aFileNotifier,
    								 RFs& aFs)
    :CActive(EPriorityStandard),
    iFileNotifier( aFileNotifier ),
    iFs( aFs )
    {
    TInt err = iTimer.CreateLocal();
    CActiveScheduler::Add( this );    
    }
    
// ----------------------------------------------------------------------------
// CLcRegistryUpdate::NewL
// Two-phased constructor.
// ----------------------------------------------------------------------------
//
CLcRegistryUpdate* CLcRegistryUpdate::NewL(MLcRegistryUpdateNotifier& aFileNotifier,
    								   	   RFs& aFs)
    {
    CLcRegistryUpdate* self = new( ELeave ) CLcRegistryUpdate( aFileNotifier, aFs );    
    return self;
    }    
    
    
// ----------------------------------------------------------------------------
// CLcRegistryUpdate::~CLcRegistryUpdate
// ----------------------------------------------------------------------------
//
CLcRegistryUpdate::~CLcRegistryUpdate()
    {
    Cancel();
    }  

// ----------------------------------------------------------------------------
// CLcRegistryUpdate::ConstructL
// ----------------------------------------------------------------------------
//
void CLcRegistryUpdate::ConstructL()
    {    
    }
    
// ----------------------------------------------------------------------------
// CLcRegistryUpdate::RunL
// ----------------------------------------------------------------------------
//
void CLcRegistryUpdate::RunL()
    { 
    if ( iFileNotifyPending )
        {    
        StartFileNotifation();
        iFileNotifier.HandleDynamicRegistrationL();
        iFileNotifyPending = EFalse;       
        }
    else
        {
        iTimer.After( iStatus, KLCUpdateDelay );
        SetActive();
        iFileNotifyPending = ETrue;
        }
    }
    

// ----------------------------------------------------------------------------
// CLcRegistryUpdate::DoCancel
// ----------------------------------------------------------------------------
//
void CLcRegistryUpdate::DoCancel()
    {
    iTimer.Cancel();
    iFs.NotifyChangeCancel();
    }

// ---------------------------------------------------------------------------
// CLcRegistryUpdate::RunError
// ---------------------------------------------------------------------------
//        
TInt CLcRegistryUpdate::RunError( TInt aError )
    {
    return aError;
    }


// ----------------------------------------------------------------------------
// CLcRegistryUpdate::StartFileNotifation
// ----------------------------------------------------------------------------
//
void CLcRegistryUpdate::StartFileNotifation()
    {
    SetActive();  
    iFs.NotifyChange(ENotifyEntry,iStatus,KFileName);
    }
    
//End of File