|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : LandmarksDbEventHandler.cpp 00004 * Part of : Landmarks Reference Application 00005 * Interface : - 00006 * Description : Implements the class CLandmarksDbEventHandler 00007 * Version : 1.0 00008 * 00009 * Copyright (c) 2004-2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 // INCLUDE FILES 00017 #include <EPos_CPosLandmarkDatabase.h> 00018 00019 #include "LandmarksDbEventHandler.h" 00020 00021 // ============================ MEMBER FUNCTIONS =============================== 00022 00023 // ----------------------------------------------------------------------------- 00024 // CLandmarksDbEventHandler::CLandmarksDbEventHandler 00025 // C++ constructor can NOT contain any code, that 00026 // might leave. 00027 // ----------------------------------------------------------------------------- 00028 // 00029 CLandmarksDbEventHandler::CLandmarksDbEventHandler( 00030 CPosLandmarkDatabase& aDb) 00031 : CActive(CActive::EPriorityStandard), iDb(aDb) 00032 { 00033 CActiveScheduler::Add(this); 00034 ObserveEvents(); 00035 } 00036 00037 // Destructor 00038 CLandmarksDbEventHandler::~CLandmarksDbEventHandler() 00039 { 00040 Cancel(); 00041 iDbObservers.Close(); 00042 } 00043 00044 // ----------------------------------------------------------------------------- 00045 // CLandmarksDbEventHandler::AddObserverL 00046 // 00047 // (other items were commented in a header). 00048 // ----------------------------------------------------------------------------- 00049 // 00050 void CLandmarksDbEventHandler::AddObserverL( 00051 MLandmarksDbObserver* aObserver) 00052 { 00053 User::LeaveIfError(iDbObservers.Append(aObserver)); 00054 } 00055 00056 // ----------------------------------------------------------------------------- 00057 // CLandmarksDbEventHandler::RunL 00058 // 00059 // (other items were commented in a header). 00060 // ----------------------------------------------------------------------------- 00061 // 00062 void CLandmarksDbEventHandler::RunL() 00063 { 00064 for (TInt i = 0; i < iDbObservers.Count(); i++) 00065 { 00066 // All observers must be notified. We cannot allow the observers to 00067 // leave. 00068 TInt err; 00069 TRAP(err, iDbObservers[i]->NotifyDbEventL(iEvent, iStatus.Int())); 00070 } 00071 ObserveEvents(); 00072 } 00073 00074 // ----------------------------------------------------------------------------- 00075 // CLandmarksDbEventHandler::DoCancel 00076 // 00077 // (other items were commented in a header). 00078 // ----------------------------------------------------------------------------- 00079 // 00080 void CLandmarksDbEventHandler::DoCancel() 00081 { 00082 iDb.CancelNotifyDatabaseEvent(); 00083 } 00084 00085 // ----------------------------------------------------------------------------- 00086 // CLandmarksDbEventHandler::RunError 00087 // 00088 // (other items were commented in a header). 00089 // ----------------------------------------------------------------------------- 00090 // 00091 TInt CLandmarksDbEventHandler::RunError(TInt /*aError*/) 00092 { 00093 return KErrNone; 00094 } 00095 00096 // ----------------------------------------------------------------------------- 00097 // CLandmarksDbEventHandler::ObserveEvents 00098 // 00099 // (other items were commented in a header). 00100 // ----------------------------------------------------------------------------- 00101 // 00102 void CLandmarksDbEventHandler::ObserveEvents() 00103 { 00104 iStatus = KRequestPending; 00105 iDb.NotifyDatabaseEvent(iEvent, iStatus); 00106 SetActive(); 00107 } 00108 00109 // End of File 00110
|
© Nokia 2006 |