applayerpluginsandutils/bookmarksupport/src/bkmrkwatcher.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Internal class for catching notifications from bookmark repositories.
       
    15 // @internalComponent
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "bkmrkwatcher.h"
       
    20 
       
    21 const TUint32 KAnyId = 0x00000000; // 0 are wildcards so when used as a mask this will match anything
       
    22 
       
    23 CBkmrkWatcher::CBkmrkWatcher(TBkmrkWatcherType aType, MBkmrkWatcherObserver& aObserver, CRepository& aRepository) 
       
    24 	: CActive(EPriorityStandard), iType(aType), iObserver(aObserver), iRepository(aRepository)
       
    25 	{
       
    26 	CActiveScheduler::Add(this);
       
    27 	}
       
    28 
       
    29 CBkmrkWatcher::~CBkmrkWatcher()
       
    30 	{
       
    31 	Cancel();
       
    32 	}
       
    33 	
       
    34 void CBkmrkWatcher::WatchL()
       
    35 	{
       
    36 	if (IsActive())
       
    37 		{
       
    38 		return;
       
    39 		}
       
    40 	// request to be notified of repository changes
       
    41 	User::LeaveIfError(iRepository.NotifyRequest(KAnyId, KAnyId, iStatus));
       
    42 	SetActive();
       
    43 	}
       
    44 
       
    45 void CBkmrkWatcher::RunL()
       
    46 	{
       
    47 	// re-issue the watching request
       
    48 	WatchL();
       
    49 	// notify observer
       
    50 	iObserver.BWONotify(iType);
       
    51 	}
       
    52 	
       
    53 void CBkmrkWatcher::DoCancel()
       
    54 	{
       
    55 	// cancel request to the repository
       
    56 	iRepository.NotifyCancel(KAnyId, KAnyId);
       
    57 	}