Example Application Guide

- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

# CGeoProfilesEngine Class Reference

`#include <geoprofilesengine.h>`

Inheritance diagram for CGeoProfilesEngine:

List of all members.

## Detailed Description

Geo Profile Engine

Definition at line 47 of file geoprofilesengine.h.

## Public Types
enum | TGeoProfileEngState { ENoAction, ECreateProfile, EUpdateProfile, EDeleteProfile }
## Public Member Functions
virtual | ~CGeoProfilesEngine ()
void | AddProfileL (CGeoProfile &aProfile)
void | UpdateProfileL (CGeoProfile &aProfile)
void | RemoveProfileL (CGeoProfile &aProfile)
void | ListProfilesL (RPointerArray< CGeoProfile > &aGeoProfiles)
void | TriggerChangedL (const TLbtTriggerChangeEvent &aEvent)
## Static Public Member Functions
static CGeoProfilesEngine * | NewL (MGeoProfilesEngineObserver &aObserver)
## Private Member Functions
| CGeoProfilesEngine (MGeoProfilesEngineObserver &aObserver)
void | ConstructL ()
void | RunL ()
void | DoCancel ()
void | LaunchWaitDialogL (TInt aResource)
void | DismissWaitDialogL ()
void | DoUpdateProfileL (CGeoProfile &aProfile)
## Private Attributes
MGeoProfilesEngineObserver & | iObserver
RLbt | iLbt
RLbt | iLbtNotifier
RLbtServer | iLbtServer
CLbtTriggerChangeEventNotifier * | iNotifier
CLbtStartupTrigger * | iStartupTrigger
TUint32 | iTriggerId
CGeoProfile * | iProfile
TGeoProfileEngState | iEngineState
CAknWaitDialog * | iWaitDialog

## Constructor & Destructor Documentation

CGeoProfilesEngine::~CGeoProfilesEngine | ( |  | ) | `[virtual]`

| C++ Destructor. Frees all the resources Definition at line 62 of file geoprofilesengine.cpp. References iLbt, iLbtNotifier, iLbtServer, iNotifier, and iStartupTrigger.
    00063     {
    00064     GEOPROFILEDEBUG("+ CGeoProfilesEngine::~CGeoProfilesEngine" )
    00065
    00066     Cancel();
    00067
    00068     // Close the notifier handle
    00069     iNotifier->Cancel();
    00070     delete iNotifier;
    00071
    00072     delete iStartupTrigger;
    00073
    00074     // Close the server handles
    00075     iLbt.Close();
    00076     iLbtNotifier.Close();
    00077     iLbtServer.Close();
    00078
    00079     GEOPROFILEDEBUG("- CGeoProfilesEngine::~CGeoProfilesEngine" )
    00080     }

CGeoProfilesEngine::CGeoProfilesEngine | ( | MGeoProfilesEngineObserver & | aObserver | ) | `[private]`

| C++ Constructor Definition at line 51 of file geoprofilesengine.cpp. Referenced by NewL().
    00052     :CActive( EPriorityStandard ),
    00053     iObserver( aObserver ),
    00054     iEngineState( CGeoProfilesEngine::ENoAction )
    00055     {
    00056     }

## Member Function Documentation

CGeoProfilesEngine * CGeoProfilesEngine::NewL | ( | MGeoProfilesEngineObserver & | aObserver | ) | `[static]`

| Constructs a new instance of CGeoProfilesEngine Definition at line 86 of file geoprofilesengine.cpp. References CGeoProfilesEngine(). Referenced by CGeoProfilesView::ConstructL().
    00087     {
    00088     GEOPROFILEDEBUG("+ CGeoProfilesEngine::NewL" )
    00089
    00090     CGeoProfilesEngine* self = new ( ELeave ) CGeoProfilesEngine( aObserver );
    00091     CleanupStack::PushL( self );
    00092     self->ConstructL();
    00093     CleanupStack::Pop( self );
    00094
    00095     GEOPROFILEDEBUG("- CGeoProfilesEngine::NewL" )
    00096     return self;
    00097     }

void CGeoProfilesEngine::AddProfileL | ( | CGeoProfile & | aProfile | ) |

| Add a new profile Definition at line 208 of file geoprofilesengine.cpp. References CGeoProfile::GeoPositionType(). Referenced by CGeoProfilesView::HandleCommandL().
    00209     {
    00210     GEOPROFILEDEBUG("+ CGeoProfilesEngine::AddProfileL")
    00211
    00212     if ( aProfile.GeoPositionType() == CGeoProfile::EUndefined )
    00213         {
    00214         User::Leave( KErrArgument );
    00215         }
    00216
    00217     if ( IsActive())
    00218         {
    00219         User::Leave( KErrInUse );
    00220         }
    00221
    00222     CLbtTriggerConditionArea* condition = NULL;
    00223
    00224     // Currently only co-ordinates are supported
    00225     if( Math::IsNaN( aProfile.GeoPositionInfo().Latitude() ) ||
    00226         Math::IsNaN( aProfile.GeoPositionInfo().Longitude()))
    00227         {
    00228         User::Leave( KErrArgument );
    00229         }
    00230     TInt radius = aProfile.GeoProfileRadius();
    00231     if ( !Math::IsNaN( aProfile.GeoPositionInfo().HorizontalAccuracy()))
    00232         {
    00233         radius += aProfile.GeoPositionInfo().HorizontalAccuracy();
    00234         }
    00235
    00236     //Define the triggering area
    00237     CLbtGeoCircle * trigArea = CLbtGeoCircle ::NewLC( aProfile.GeoPositionInfo(),
    00238                                                       radius );
    00239     //Construct trigger condition.
    00240
    00241     CLbtTriggerConditionArea::TDirection triggerType = CLbtTriggerConditionArea::EFireOnEnter;
    00242     if (aProfile.TriggerType() == CGeoProfile::EExitTrigger )
    00243         {
    00244         triggerType = CLbtTriggerConditionArea::EFireOnExit;
    00245         }
    00246     // Currently only Entry type Triggers are suppored
    00247     condition = CLbtTriggerConditionArea::NewL( trigArea,
    00248                                                 triggerType );
    00249
    00250     //ownership of trigArea is transferred.
    00251     CleanupStack::Pop( trigArea );
    00252
    00253     // Load Command line arguments
    00254     HBufC* cmdLineArg = aProfile.PartialExternalizeLC();
    00255
    00256     // Create the startup trigger
    00257     iStartupTrigger = CLbtStartupTrigger::NewL( aProfile.GeoPlaceName(),
    00258                                                 CLbtTriggerEntry::EStateEnabled,
    00259                                                 CRequestorBase::ERequestorService,
    00260                                                 CRequestorBase::EFormatApplication,
    00261                                                 KMyGeoProfile,
    00262                                                 managerProcessSID,
    00263                                                 condition,
    00264                                                 KTriggerHandlingProcessName,
    00265                                                 triggerHandlingProcessSID,
    00266                                                 *cmdLineArg );
    00267     CleanupStack::PopAndDestroy( cmdLineArg );
    00268
    00269
    00270     iTriggerId = 0xFFFFFFFF;
    00271     iEngineState = ECreateProfile;
    00272
    00273     // Create the trigger
    00274     iLbt.CreateTrigger( *iStartupTrigger, iTriggerId, ETrue, iStatus );
    00275     SetActive();
    00276
    00277     // Launch the Wait Dialog
    00278     LaunchWaitDialogL( R_LBL_GEOPROFILES_WAITDLG_CREATE );
    00279
    00280     GEOPROFILEDEBUG("- CGeoProfilesEngine::AddProfileL")
    00281     }

void CGeoProfilesEngine::UpdateProfileL | ( | CGeoProfile & | aProfile | ) |

| Updates a profile Definition at line 287 of file geoprofilesengine.cpp. References iEngineState, iProfile, and LaunchWaitDialogL(). Referenced by CGeoProfilesView::ContainerCommandL().
    00288     {
    00289     GEOPROFILEDEBUG("+ CGeoProfilesEngine::UpdateProfileL")
    00290
    00291     if ( IsActive())
    00292         {
    00293         User::Leave( KErrInUse );
    00294         }
    00295
    00296     iEngineState = EUpdateProfile;
    00297     iProfile = &aProfile;
    00298
    00299     SetActive();
    00300     TRequestStatus* status = &iStatus;
    00301     User::RequestComplete( status, KErrNone );
    00302
    00303     // Launch the Wait Dialog
    00304     LaunchWaitDialogL( R_LBL_GEOPROFILES_WAITDLG_UPDATE );
    00305
    00306     GEOPROFILEDEBUG("- CGeoProfilesEngine::UpdateProfileL")
    00307     }

void CGeoProfilesEngine::RemoveProfileL | ( | CGeoProfile & | aProfile | ) |

| Delete an existing profile Definition at line 313 of file geoprofilesengine.cpp. References iEngineState, iTriggerId, LaunchWaitDialogL(), and CGeoProfile::TriggerId().
    00314     {
    00315     GEOPROFILEDEBUG("+ CGeoProfilesEngine::RemoveProfileL")
    00316
    00317     if ( IsActive())
    00318         {
    00319         User::Leave( KErrInUse );
    00320         }
    00321
    00322     iEngineState = EDeleteProfile;
    00323     iTriggerId = aProfile.TriggerId();
    00324
    00325     SetActive();
    00326     TRequestStatus* status = &iStatus;
    00327     User::RequestComplete( status, KErrNone );
    00328
    00329     // Launch the Wait Dialog
    00330     LaunchWaitDialogL( R_LBL_GEOPROFILES_WAITDLG_DELETE );
    00331
    00332     GEOPROFILEDEBUG("- CGeoProfilesEngine::RemoveProfileL")
    00333     }

void CGeoProfilesEngine::ListProfilesL | ( | RPointerArray< CGeoProfile > & | aGeoProfiles | ) |

| List profiles Definition at line 339 of file geoprofilesengine.cpp. References iLbt, and CGeoProfile::NewL(). Referenced by CGeoProfilesView::ConstructL(), and CGeoProfilesView::ProfileStatusChangedL().
    00340     {
    00341     GEOPROFILEDEBUG("+ CGeoProfilesEngine::ListProfilesL")
    00342
    00343     // Clean up the existing profiles
    00344     aGeoProfiles.ResetAndDestroy();
    00345
    00346     // Fetch the individual list of triggers
    00347     RArray < TLbtTriggerId > aTriggerIdList;
    00348     iLbt.ListTriggerIdsL( aTriggerIdList );
    00349
    00350     // Load the individual profiles
    00351     for ( TInt i = 0; i < aTriggerIdList.Count(); i++ )
    00352         {
    00353         CGeoProfile* profile = CGeoProfile::NewL();
    00354         CleanupStack::PushL( profile );
    00355
    00356         // Fetch the trigger associated with the Id.
    00357         CLbtTriggerInfo* trigger = iLbt.GetTriggerLC( aTriggerIdList[i]);
    00358         CLbtTriggerEntry* triggerEntry = trigger->TriggerEntry();
    00359
    00360         // Set the Location Information
    00361         CLbtTriggerConditionArea* triggArea =
    00362                     static_cast< CLbtTriggerConditionArea*>( triggerEntry->GetCondition());
    00363
    00364         // Set the Trigger Type
    00365         if ( triggArea->Direction() == CLbtTriggerConditionArea::EFireOnEnter )
    00366             {
    00367             profile->SetTriggerType( CGeoProfile::EEntryTrigger );
    00368             }
    00369         else
    00370             {
    00371             profile->SetTriggerType( CGeoProfile::EExitTrigger );
    00372             }
    00373
    00374         CLbtGeoAreaBase* triggGeoArea =
    00375                     static_cast< CLbtGeoAreaBase*>( triggArea->TriggerArea());
    00376
    00377         // Set Coordinate Information
    00378         if ( triggGeoArea->Type() == CLbtGeoAreaBase::ECircle )
    00379             {
    00380             CLbtGeoCircle* loc = static_cast<CLbtGeoCircle*>( triggArea->TriggerArea() );
    00381             TLocality locality;
    00382             locality.SetCoordinate( loc->Center().Latitude(),
    00383                                     loc->Center().Longitude());
    00384             profile->SetGeoPositionInfoL( triggerEntry->Name(), locality );
    00385             }
    00386         // Copy the Trigger Id
    00387         profile->SetTriggerId( triggerEntry->Id());
    00388
    00389         // Load all other information
    00390         CLbtStartupTrigger* startupTrigger = static_cast<CLbtStartupTrigger*>( triggerEntry );
    00391         TPtrC cmdLine = startupTrigger->CommandLine();
    00392         // Internalize the contents
    00393         profile->PartialInternalizeL( cmdLine );
    00394         CleanupStack::PopAndDestroy( trigger );
    00395
    00396         // Append the profile structure to the array
    00397         if ( aGeoProfiles.Append( profile ))
    00398             {
    00399             CleanupStack::PopAndDestroy( profile );
    00400             }
    00401         else
    00402             {
    00403             CleanupStack::Pop( profile );
    00404             }
    00405         }
    00406     aTriggerIdList.Reset();
    00407     aTriggerIdList.Close();
    00408
    00409     GEOPROFILEDEBUG("- CGeoProfilesEngine::ListProfilesL")
    00410     }

void CGeoProfilesEngine::TriggerChangedL | ( | const TLbtTriggerChangeEvent & | aEvent | ) |

| Inherited from MLbtTriggerChangeEventObserver Definition at line 416 of file geoprofilesengine.cpp. References iObserver, and MGeoProfilesEngineObserver::ProfileStatusChangedL().
    00417     {
    00418     iObserver.ProfileStatusChangedL();
    00419     }

void CGeoProfilesEngine::ConstructL | ( |  | ) | `[private]`

| Second phase of two phase construction Definition at line 103 of file geoprofilesengine.cpp. References iLbt, iLbtNotifier, iLbtServer, and iNotifier.
    00104     {
    00105     GEOPROFILEDEBUG("- CGeoProfilesEngine::ConstructL" )
    00106
    00107     // Open the LBT server handle
    00108     iLbtServer.Connect();
    00109
    00110     // Open the session handle
    00111     iLbt.Open( iLbtServer );
    00112
    00113     // Open the session for notifiers
    00114     iLbtNotifier.Open( iLbtServer );
    00115
    00116     // Open the Trigger Notifier handle
    00117     iNotifier = CLbtTriggerChangeEventNotifier::NewL( iLbtNotifier, *this );
    00118     iNotifier->Start();
    00119
    00120     CActiveScheduler::Add( this );
    00121
    00122     GEOPROFILEDEBUG("- CGeoProfilesEngine::ConstructL" )
    00123     }

void CGeoProfilesEngine::RunL | ( |  | ) | `[private]`

| Inherited from CActive Definition at line 129 of file geoprofilesengine.cpp. References DismissWaitDialogL(), and iEngineState.
    00130     {
    00131     GEOPROFILEDEBUG1("+ CGeoProfilesEngine::RunL %d", iStatus.Int())
    00132
    00133     if ( iStatus.Int() != KErrNone )
    00134         {
    00135         iEngineState = ENoAction;
    00136
    00137         // Dismiss the Wait dialog if it is Running
    00138         DismissWaitDialogL();
    00139         return;
    00140         }
    00141
    00142     switch ( iEngineState )
    00143         {
    00144         case ECreateProfile:
    00145             {
    00146             // The profile has been successfully created.
    00147             delete iStartupTrigger;
    00148             iStartupTrigger = NULL;
    00149             iEngineState = ENoAction;
    00150
    00151             // Dismiss the Wait Dialog
    00152             DismissWaitDialogL();
    00153
    00154             break;
    00155             }
    00156         case EDeleteProfile:
    00157             {
    00158             // Delet the Trigger
    00159             iLbt.DeleteTriggerL( iTriggerId );
    00160             iEngineState = ENoAction;
    00161
    00162             // Dismiss the Wait Dialog
    00163             DismissWaitDialogL();
    00164             break;
    00165             }
    00166         case EUpdateProfile:
    00167             {
    00168             // Update the Profile
    00169             DoUpdateProfileL( *iProfile );
    00170             iProfile = NULL;
    00171
    00172             iEngineState = ENoAction;
    00173             // Dismiss the Wait Dialog
    00174             DismissWaitDialogL();
    00175
    00176             }
    00177         default:
    00178             {
    00179             iEngineState = ENoAction;
    00180             // Dismiss the Wait Dialog
    00181             DismissWaitDialogL();
    00182             break;
    00183             }
    00184         }
    00185     GEOPROFILEDEBUG("- CGeoProfilesEngine::RunL")
    00186     }

void CGeoProfilesEngine::DoCancel | ( |  | ) | `[private]`

| Inherited from CActive Definition at line 193 of file geoprofilesengine.cpp. References DismissWaitDialogL(), and iLbt.
    00194     {
    00195     GEOPROFILEDEBUG("+ CGeoProfilesEngine::DoCancel")
    00196
    00197     iLbt.CancelAll();
    00198
    00199     DismissWaitDialogL();
    00200
    00201     GEOPROFILEDEBUG("- CGeoProfilesEngine::DoCancel")
    00202     }

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

- geoprofilesengine.h
- geoprofilesengine.cpp

© Nokia 2009 |