Nokia N97 SDK
Example Applications Guide

CLandmarksApplicationEngine Class Reference

#include <LandmarksApplicationEngine.h>

Inheritance diagram for CLandmarksApplicationEngine:

List of all members.

Detailed Description

CLandmarksApplicationEngine provides the main interface to the application engine component.

CLandmarksApplicationEngine is the only engine class UI-components need to interact with. It uses the default landmark database for reading/writing landmarks and categories.

Definition at line 46 of file LandmarksApplicationEngine.h.


Public Member Functions

  ~CLandmarksApplicationEngine ()
void  NotifyViewActivated (TUid aViewId, TBool aIsActive)
TBool  StartInitializeDbIfNecessaryL (MLandmarksOperationObserver *aObserver)
void  AddDbObserverL (MLandmarksDbObserver *aObserver)
CPosLandmark *  LandmarkLC (TPosLmItemId aItemId)
void  CommitLandmarkL (const CPosLandmark &aLandmark)
void  DeleteLandmarkL (TPosLmItemId aItemId)
void  AddLandmarkL (CPosLandmark &aLandmark)
void  StartSearchingLandmarksL (MLandmarksOperationObserver *aObserver)
void  StartSearchingLandmarksL (const TDesC &aSearchPattern, TBool aSearchOnlyInPreviousMatches, MLandmarksOperationObserver *aObserver)
RArray< TPosLmItemId > *  FetchLandmarkSearchResult ()
void  StartReadingLandmarksL (TInt aNrOfItemsToReadPerBundle, MLandmarksOperationObserver *aObserver)
CArrayPtr< CPosLandmark > *  FetchLandmarksLC ()
CPosLandmarkCategory *  CategoryLC (TPosLmItemId aItemId)
void  DeleteCategoryL (TPosLmItemId aItemId)
void  UpdateCategoryL (const CPosLandmarkCategory &aCategory)
void  AddCategoryL (CPosLandmarkCategory &aCategory)
void  StartSearchingCategoriesL (MLandmarksOperationObserver *aObserver)
void  StartSearchingCategoriesL (const TDesC &aSearchPattern, TBool aSearchOnlyInPreviousMatches, MLandmarksOperationObserver *aObserver)
RArray< TPosLmItemId > *  FetchCategorySearchResult ()
void  StartReadingCategoriesL (TInt aNrOfItemsToReadPerBundle, MLandmarksOperationObserver *aObserver)
CArrayPtr< CPosLandmarkCategory > *  FetchCategoriesLC ()
CArrayPtr< CPosLandmarkCategory > *  CategoriesL ()

Static Public Member Functions

static CLandmarksApplicationEngine *  NewL ()

Private Member Functions

  CLandmarksApplicationEngine ()
void  ConstructL ()
void  CompactIfNeededL ()

Private Attributes

CPosLandmarkDatabase *  iDb
  Default landmark database.
CLandmarksEngine *  iLandmarksEngine
  Landmarks engine part.
CLandmarksCategoriesEngine *  iCategoriesEngine
  Categories engine part.
CLandmarksDbEventHandler *  iDbEventHandler
  Database event handler.


Constructor & Destructor Documentation

CLandmarksApplicationEngine::~CLandmarksApplicationEngine (   ) 
 

Destructor.

Definition at line 66 of file LandmarksApplicationEngine.cpp.

References iCategoriesEngine, iDb, iDbEventHandler, and iLandmarksEngine.

00067     {
00068     delete iLandmarksEngine;
00069     delete iCategoriesEngine;
00070     delete iDbEventHandler;
00071     delete iDb;
00072     }

CLandmarksApplicationEngine::CLandmarksApplicationEngine (   )  [private]
 

C++ default constructor.

Definition at line 34 of file LandmarksApplicationEngine.cpp.

Referenced by NewL().

00035     {
00036     }


Member Function Documentation

CLandmarksApplicationEngine * CLandmarksApplicationEngine::NewL (   )  [static]
 

Two-phased constructor.

Returns:
A new instance of this class.

Definition at line 55 of file LandmarksApplicationEngine.cpp.

References CLandmarksApplicationEngine().

Referenced by CLandmarksAppUi::ConstructL().

00056     {
00057     CLandmarksApplicationEngine* self = 
00058         new (ELeave) CLandmarksApplicationEngine();
00059     CleanupStack::PushL(self);
00060     self->ConstructL();
00061     CleanupStack::Pop(self);
00062     return self;
00063     }

void CLandmarksApplicationEngine::NotifyViewActivated (  TUid  aViewId,
TBool  aIsActive
) 
 

NotifyViewActivated notifies the engine which view is in focus. Should be called by views when they are activated/deactivated. This makes it possible for the engine to prioritize its asynchronous operations.

Parameters:
aViewId  the TUid identifying the view
aIsActive  ETrue if view is active, EFalse otherwise

Definition at line 81 of file LandmarksApplicationEngine.cpp.

References iCategoriesEngine, iLandmarksEngine, and CLandmarksEngineBase::SetPrio().

Referenced by CLandmarksView::DoActivateL(), CLandmarksInfoView::DoActivateL(), CLandmarksCategoriesView::DoActivateL(), CLandmarksView::DoDeactivate(), CLandmarksInfoView::DoDeactivate(), and CLandmarksCategoriesView::DoDeactivate().

00084     {
00085     if (aViewId.iUid == ELandmarksViewId)
00086         {
00087         if (aIsActive)
00088             {
00089             iLandmarksEngine->SetPrio(CActive::EPriorityStandard);
00090             }
00091         else
00092             {
00093             iLandmarksEngine->SetPrio(CActive::EPriorityLow);
00094             }
00095         }
00096     else if (aViewId.iUid == ELandmarksCategoriesViewId)
00097         {
00098         if (aIsActive)
00099             {
00100             iCategoriesEngine->SetPrio(CActive::EPriorityStandard);
00101             }
00102         else
00103             {
00104             iCategoriesEngine->SetPrio(CActive::EPriorityLow);
00105             }
00106         }
00107     }

TBool CLandmarksApplicationEngine::StartInitializeDbIfNecessaryL (  MLandmarksOperationObserver *  aObserver  ) 
 

StartInitializeDbIfNecessaryL indicates if the default database needs to be initialised before it can be used. If it needs to be initialized the initialization is started immediately and the supplied observer is notified when initialization is ready.

Parameters:
aObserver  the observer to be notified when initialization is ready
Returns:
ETrue if initializing is necessary, EFalse otherwise

Definition at line 115 of file LandmarksApplicationEngine.cpp.

References iLandmarksEngine, and CLandmarksEngine::StartInitializeDbIfNecessaryL().

Referenced by CLandmarksAppUi::ConstructL().

00117     {
00118     return iLandmarksEngine->StartInitializeDbIfNecessaryL(aObserver);
00119     }

void CLandmarksApplicationEngine::AddDbObserverL (  MLandmarksDbObserver *  aObserver  ) 
 

AddDbObserverL registers the supplied observer as observer of database events.

Parameters:
aObserver  the observer to be notified when a database event occurs

Definition at line 127 of file LandmarksApplicationEngine.cpp.

References CLandmarksDbEventHandler::AddObserverL(), iDb, and iDbEventHandler.

Referenced by CLandmarksContainer::ConstructL(), and CLandmarksCategoriesContainer::ConstructL().

00129     {
00130     if (!iDbEventHandler)
00131         {
00132         iDbEventHandler = new (ELeave) CLandmarksDbEventHandler(*iDb);
00133         }
00134     iDbEventHandler->AddObserverL(aObserver);
00135     }

CPosLandmark * CLandmarksApplicationEngine::LandmarkLC (  TPosLmItemId  aItemId  ) 
 

LandmarkLC reads all fields of a landmark in the default landmark database. Ownership of the returned landmark is transferred to the caller.

Parameters:
aItemId  the ItemId identifying the landmark
Returns:
a landmark

Definition at line 143 of file LandmarksApplicationEngine.cpp.

References iDb.

Referenced by CLandmarksContainer::DeleteLandmarkL(), CLandmarksContainer::IsRefreshNeededL(), CLandmarksInfoContainer::LoadLandmarkL(), and CLandmarksContainer::StoreCurrentLandmarkNameL().

00144     {
00145     return iDb->ReadLandmarkLC(aItemId);
00146     }

void CLandmarksApplicationEngine::CommitLandmarkL (  const CPosLandmark &  aLandmark  ) 
 

CommitLandmarkL commits a modified landmark.

Parameters:
aLandmark  the landmark to commit

Definition at line 154 of file LandmarksApplicationEngine.cpp.

References CLandmarksEngine::CommitLandmarkL(), CompactIfNeededL(), iCategoriesEngine, and iLandmarksEngine.

Referenced by CLandmarksInfoContainer::EditLandmarkL().

00156     {
00157     // We need to cancel any search/read operation in any view engine. 
00158     // Otherwise database will be locked.
00159     iLandmarksEngine->Cancel();
00160     iCategoriesEngine->Cancel();
00161 
00162     iLandmarksEngine->CommitLandmarkL(aLandmark);
00163     CompactIfNeededL();
00164     }

void CLandmarksApplicationEngine::DeleteLandmarkL (  TPosLmItemId  aItemId  ) 
 

DeleteLandmarkL deletes a landmark.

Parameters:
aItemId  the itemId identifying the landmark to be deleted

Definition at line 172 of file LandmarksApplicationEngine.cpp.

References CompactIfNeededL(), CLandmarksEngine::DeleteLandmarkL(), iCategoriesEngine, and iLandmarksEngine.

Referenced by CLandmarksContainer::DeleteLandmarkL().

00173     {
00174     // We need to cancel any search/read operation in any view engine. 
00175     // Otherwise database will be locked.
00176     iLandmarksEngine->Cancel();
00177     iCategoriesEngine->Cancel();
00178 
00179     iLandmarksEngine->DeleteLandmarkL(aItemId);
00180     CompactIfNeededL();
00181     }

void CLandmarksApplicationEngine::AddLandmarkL (  CPosLandmark &  aLandmark  ) 
 

AddLandmarkL adds a landmark to the database.

Parameters:
aLandmark  the landmark to add

Definition at line 189 of file LandmarksApplicationEngine.cpp.

References CLandmarksEngine::AddLandmarkL(), CompactIfNeededL(), iCategoriesEngine, and iLandmarksEngine.

Referenced by CLandmarksView::AddLandmarkL().

00190     {
00191     // We need to cancel any search/read operation in any view engine. 
00192     // Otherwise database will be locked.
00193     iLandmarksEngine->Cancel();
00194     iCategoriesEngine->Cancel();
00195 
00196     iLandmarksEngine->AddLandmarkL(aLandmark);
00197     CompactIfNeededL();
00198     }

void CLandmarksApplicationEngine::StartSearchingLandmarksL (  MLandmarksOperationObserver *  aObserver  ) 
 

StartSearchingLandmarksL starts an asynchronous search operation for landmarks. When the search completes the supplied observer is notified and it is supposed to fetch the matches by calling FetchLandmarkSearchResult(). All landmarks in the database are returned.

Parameters:
aObserver  the observer that is notified when the search operation completes

Definition at line 206 of file LandmarksApplicationEngine.cpp.

References iLandmarksEngine, and CLandmarksEngine::StartSearchingLandmarksL().

Referenced by CLandmarksContainer::StartUpdateListBoxL().

00208     {
00209     iLandmarksEngine->StartSearchingLandmarksL(aObserver);
00210     }

void CLandmarksApplicationEngine::StartSearchingLandmarksL (  const TDesC &  aSearchPattern,
TBool  aSearchOnlyInPreviousMatches,
MLandmarksOperationObserver *  aObserver
) 
 

StartSearchingLandmarksL starts an asynchronous search operation for landmarks. The names of the landmarks are used as criterion for a match. When the search completes the supplied observer is notified and it is supposed to fetch the matches by calling FetchLandmarkSearchResult().

Parameters:
aSearchPattern  search pattern to compare landmarks against
aSearchOnlyInPreviousMatches  boolean indicating that only previous matches should be searched
aObserver  the observer that is notified when the search operation completes

Definition at line 218 of file LandmarksApplicationEngine.cpp.

References iLandmarksEngine, and CLandmarksEngine::StartSearchingLandmarksL().

00222     {
00223     iLandmarksEngine->StartSearchingLandmarksL(
00224         aSearchPattern, 
00225         aSearchOnlyInPreviousMatches, 
00226         aObserver);
00227     }

RArray< TPosLmItemId > * CLandmarksApplicationEngine::FetchLandmarkSearchResult (   ) 
 

FetchLandmarkSearchResult should be called after a successful landmark search operation. It returns the matches from the previous landmark search operation. Ownership of the returened array is kept by this class.

Returns:
an array containing matches from a previous landmark search operation

Definition at line 235 of file LandmarksApplicationEngine.cpp.

References CLandmarksEngine::FetchSearchResult(), and iLandmarksEngine.

Referenced by CLandmarksContainer::HandleSearchReadyL().

00236     {
00237     return iLandmarksEngine->FetchSearchResult();
00238     }

void CLandmarksApplicationEngine::StartReadingLandmarksL (  TInt  aNrOfItemsToReadPerBundle,
MLandmarksOperationObserver *  aObserver
) 
 

StartReadingLandmarksL should be called after a successful landmark search operation. It continously reads a number of landmarks partially, i.e. only the name and the icon of the landmarks are read, until all landmarks found in a previous search operation are read. The method is asynchronous and every time a number of landmarks are read the supplied observer is notified, FetchLandmarksLC should be called to fetch the read landmarks.

Parameters:
aNrOfItemsToReadPerBundle  the number of items to read before notifying the supplied observer
aObserver  the observer that is notified every time a bundle of landmarks are read

Definition at line 246 of file LandmarksApplicationEngine.cpp.

References iLandmarksEngine, and CLandmarksEngine::StartReadingLandmarksL().

Referenced by CLandmarksContainer::HandleSearchReadyL().

00249     {
00250     iLandmarksEngine->StartReadingLandmarksL(
00251         aNrOfItemsToReadPerBundle, 
00252         aObserver);
00253     }

CArrayPtr< CPosLandmark > * CLandmarksApplicationEngine::FetchLandmarksLC (   ) 
 

FetchLandmarksLC should be called after a successful landmark read operation. It returns the landmarks that were partially read during a preceding landmark read operation. Ownership of the returned array is transferred to the caller.

Returns:
an array containing partially read landmarks from a previous read operation

Definition at line 261 of file LandmarksApplicationEngine.cpp.

References CLandmarksEngine::FetchLandmarksLC(), and iLandmarksEngine.

Referenced by CLandmarksContainer::HandleReadReadyL().

00262     {
00263     return iLandmarksEngine->FetchLandmarksLC();
00264     }

CPosLandmarkCategory * CLandmarksApplicationEngine::CategoryLC (  TPosLmItemId  aItemId  ) 
 

CategoryLC reads all fields of a category in the default landmark database. Ownership of the returned category is transferred to the caller.

Parameters:
aItemId  the ItemId identifying the category
Returns:
a category

Definition at line 272 of file LandmarksApplicationEngine.cpp.

References CLandmarksCategoriesEngine::CategoryLC(), and iCategoriesEngine.

Referenced by CLandmarksInfoModel::AddCategoryFieldsL(), CLandmarksEditDialog::ConfigureCategoryFieldL(), CLandmarksCategoriesContainer::DeleteCategoryL(), CLandmarksCategoriesContainer::IsGlobalL(), and CLandmarksCategoriesView::RenameCategoryL().

00274     {
00275     return iCategoriesEngine->CategoryLC(aItemId);
00276     }

void CLandmarksApplicationEngine::DeleteCategoryL (  TPosLmItemId  aItemId  ) 
 

DeleteCategoryL deletes a category.

Parameters:
aItemId  the itemId identifying the category to be deleted

Definition at line 284 of file LandmarksApplicationEngine.cpp.

References CompactIfNeededL(), CLandmarksCategoriesEngine::DeleteCategoryL(), iCategoriesEngine, and iLandmarksEngine.

Referenced by CLandmarksCategoriesContainer::DeleteCategoryL().

00285     {
00286     // We need to cancel any search/read operation in any view engine. 
00287     // Otherwise database will be locked.
00288     iLandmarksEngine->Cancel();
00289     iCategoriesEngine->Cancel();
00290 
00291     iCategoriesEngine->DeleteCategoryL(aItemId);
00292     CompactIfNeededL();
00293     }

void CLandmarksApplicationEngine::UpdateCategoryL (  const CPosLandmarkCategory &  aCategory  ) 
 

UpdateCategoryL updates a modified category.

Parameters:
aCategory  the category to update

Definition at line 301 of file LandmarksApplicationEngine.cpp.

References CompactIfNeededL(), iCategoriesEngine, iLandmarksEngine, and CLandmarksCategoriesEngine::UpdateCategoryL().

Referenced by CLandmarksCategoriesView::RenameCategoryL().

00303     {
00304     // We need to cancel any search/read operation in any view engine. 
00305     // Otherwise database will be locked.
00306     iLandmarksEngine->Cancel();
00307     iCategoriesEngine->Cancel();
00308 
00309     iCategoriesEngine->UpdateCategoryL(aCategory);
00310     CompactIfNeededL();
00311     }

void CLandmarksApplicationEngine::AddCategoryL (  CPosLandmarkCategory &  aCategory  ) 
 

AddCategoryL adds a category to the default database.

Parameters:
aCategory  the category to add

Definition at line 319 of file LandmarksApplicationEngine.cpp.

References CLandmarksCategoriesEngine::AddCategoryL(), CompactIfNeededL(), iCategoriesEngine, and iLandmarksEngine.

Referenced by CLandmarksCategoriesView::AddCategoryL().

00320     {
00321     // We need to cancel any search/read operation in any view engine. 
00322     // Otherwise database will be locked.
00323     iLandmarksEngine->Cancel();
00324     iCategoriesEngine->Cancel();
00325 
00326     iCategoriesEngine->AddCategoryL(aCategory);
00327     CompactIfNeededL();
00328     }

void CLandmarksApplicationEngine::StartSearchingCategoriesL (  MLandmarksOperationObserver *  aObserver  ) 
 

StartSearchingCategoriesL starts an asynchronous search operation for categories. When the search completes the supplied observer is notified and it is supposed to fetch the matches by calling FetchCategorySearchResult. All categoiries in the database are returned.

Parameters:
aObserver  the observer that is notified when the search operation completes

Definition at line 353 of file LandmarksApplicationEngine.cpp.

References iCategoriesEngine, and CLandmarksCategoriesEngine::StartSearchingCategoriesL().

Referenced by CLandmarksCategoriesContainer::StartUpdateListBoxL().

00355     {
00356     iCategoriesEngine->StartSearchingCategoriesL(aObserver);
00357     }

void CLandmarksApplicationEngine::StartSearchingCategoriesL (  const TDesC &  aSearchPattern,
TBool  aSearchOnlyInPreviousMatches,
MLandmarksOperationObserver *  aObserver
) 
 

StartSearchingCategoriesL starts an asynchronous search operation for categories. The names of the categories are used as criterion for a match. When the search completes the supplied observer is notified and it is supposed to fetch the matches by calling FetchLandmarkSearchResult().

Parameters:
aSearchPattern  search pattern to compare landmarks against
aSearchOnlyInPreviousMatches  boolean indicating that only previous matches should be searched
aObserver  the observer that is notified when the search operation completes

Definition at line 336 of file LandmarksApplicationEngine.cpp.

References iCategoriesEngine, and CLandmarksCategoriesEngine::StartSearchingCategoriesL().

00340     {
00341     iCategoriesEngine->StartSearchingCategoriesL(
00342         aSearchPattern, 
00343         aSearchOnlyInPreviousMatches, 
00344         aObserver);
00345     }

RArray< TPosLmItemId > * CLandmarksApplicationEngine::FetchCategorySearchResult (   ) 
 

FetchCategorySearchResult should be called after a successful category search operation. It returns the matches from the previous category search operation. Ownership of the returned array is kept by this class.

Returns:
an array containing matches from a previous categories search operation

Definition at line 365 of file LandmarksApplicationEngine.cpp.

References CLandmarksCategoriesEngine::FetchSearchResult(), and iCategoriesEngine.

Referenced by CLandmarksCategoriesContainer::HandleSearchReadyL().

00366     {
00367     return iCategoriesEngine->FetchSearchResult();
00368     }

void CLandmarksApplicationEngine::StartReadingCategoriesL (  TInt  aNrOfItemsToReadPerBundle,
MLandmarksOperationObserver *  aObserver
) 
 

StartReadingCategoriesL should be called after a successful category search operation. It continously reads a number of categories until all landmarks found in a previous search operation are read. The method is asynchronous and every time a number of categories are read the supplied observer is notified. FetchLandmarksLC should be called to fetch the read categories.

Parameters:
aNrOfItemsToReadPerBundle  the number of categories to read before notifying the supplied observer
aObserver  the observer that is notified every time a bundle of categories are read

Definition at line 376 of file LandmarksApplicationEngine.cpp.

References iCategoriesEngine, and CLandmarksCategoriesEngine::StartReadingCategoriesL().

Referenced by CLandmarksCategoriesContainer::HandleSearchReadyL().

00379     {
00380     iCategoriesEngine->StartReadingCategoriesL(
00381         aNrOfItemsToReadPerBundle, aObserver);
00382     }

CArrayPtr< CPosLandmarkCategory > * CLandmarksApplicationEngine::FetchCategoriesLC (   ) 
 

FetchCategoriesLC should be called after a successful category read operation. It returns the categories that were read during a preceding landmark read operation. Ownership of teh returned array is transferred to the caller.

Returns:
an array containing partially read landmarks from a previous read operation

Definition at line 390 of file LandmarksApplicationEngine.cpp.

References CLandmarksCategoriesEngine::FetchCategoriesLC(), and iCategoriesEngine.

Referenced by CLandmarksCategoriesContainer::HandleReadReadyL().

00391     {
00392     return iCategoriesEngine->FetchCategoriesLC();
00393     }

CArrayPtr< CPosLandmarkCategory > * CLandmarksApplicationEngine::CategoriesL (   ) 
 

CategoriesL reads all categories in the default database synchronously. Ownership of the returned array is transferred to the caller.

Returns:
an array containing all categories in the database.

Definition at line 401 of file LandmarksApplicationEngine.cpp.

References CLandmarksCategoriesEngine::CategoriesL(), and iCategoriesEngine.

Referenced by CLandmarksLmCategoriesModel::ConstructL().

00402     {
00403     return iCategoriesEngine->CategoriesL();
00404     }

void CLandmarksApplicationEngine::ConstructL (   )  [private]
 

By default Symbian 2nd phase constructor is private.

Definition at line 43 of file LandmarksApplicationEngine.cpp.

References iCategoriesEngine, iDb, iLandmarksEngine, CLandmarksCategoriesEngine::NewL(), and CLandmarksEngine::NewL().

00044     {
00045     iDb = CPosLandmarkDatabase::OpenL();
00046     iLandmarksEngine = CLandmarksEngine::NewL(*iDb);
00047     iCategoriesEngine = CLandmarksCategoriesEngine::NewL(*iDb);
00048     }

void CLandmarksApplicationEngine::CompactIfNeededL (   )  [private]
 

CompactIfNeededL compacts the database synchronously if necessary.

Definition at line 412 of file LandmarksApplicationEngine.cpp.

References iDb.

Referenced by AddCategoryL(), AddLandmarkL(), CommitLandmarkL(), DeleteCategoryL(), DeleteLandmarkL(), and UpdateCategoryL().

00413     {
00414     CPosLandmarkDatabase::TSize dbSize = iDb->SizeL();
00415     if (dbSize.iUsage < KDbUsageLimit)
00416         {
00417         ExecuteAndDeleteLD(iDb->CompactL());
00418         }
00419     }


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top