locationlandmarksrefappfors60/Src/LandmarksDbEventHandler.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2004-2005 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:  Implements the class CLandmarksDbEventHandler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <EPos_CPosLandmarkDatabase.h>
       
    21 
       
    22 #include "LandmarksDbEventHandler.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CLandmarksDbEventHandler::CLandmarksDbEventHandler(
       
    30     CPosLandmarkDatabase& aDb)
       
    31 : CActive(CActive::EPriorityStandard), iDb(aDb)
       
    32     {
       
    33     CActiveScheduler::Add(this);
       
    34     ObserveEvents();
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CLandmarksDbEventHandler::~CLandmarksDbEventHandler()
       
    41     {
       
    42     Cancel();
       
    43     iDbObservers.Close();
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CLandmarksDbEventHandler::AddObserverL(
       
    50     MLandmarksDbObserver* aObserver)
       
    51     {
       
    52     User::LeaveIfError(iDbObservers.Append(aObserver));
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CLandmarksDbEventHandler::RunL()
       
    59     {
       
    60     for (TInt i = 0; i < iDbObservers.Count(); i++)
       
    61         {
       
    62         // All observers must be notified. We cannot allow the observers to 
       
    63         // leave.
       
    64         TInt err;
       
    65         TRAP(err, iDbObservers[i]->NotifyDbEventL(iEvent, iStatus.Int()));
       
    66         }
       
    67     ObserveEvents();
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CLandmarksDbEventHandler::DoCancel()
       
    74     {
       
    75     iDb.CancelNotifyDatabaseEvent();
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 TInt CLandmarksDbEventHandler::RunError(TInt /*aError*/)
       
    82     {
       
    83     return KErrNone;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CLandmarksDbEventHandler::ObserveEvents()
       
    90     {
       
    91     iStatus = KRequestPending;
       
    92     iDb.NotifyDatabaseEvent(iEvent, iStatus);
       
    93     SetActive();
       
    94     }
       
    95 
       
    96