locationlandmarksrefappfors60/Inc/LandmarksPositionRequest.h
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:  
       
    15 *     See class description below
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __LANDMARKS_POSITION_REQUEST_H__
       
    21 #define __LANDMARKS_POSITION_REQUEST_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <AknProgressDialog.h>
       
    26 #include <lbs.h>
       
    27 
       
    28 
       
    29 class MLandmarksOperationObserver;
       
    30 class CAknWaitDialog;
       
    31 
       
    32 
       
    33 
       
    34 /**
       
    35 *  Provides an interface for retrieving the current location.
       
    36 *  It also manages a floating progress ball for indicating the progress of the 
       
    37 *  location retrieval.
       
    38 */
       
    39 class CLandmarksPositionRequest: public CActive, public MProgressDialogCallback
       
    40     {
       
    41     public: // Constructors and destructor
       
    42 
       
    43         /**
       
    44         * Two-phased constructor.
       
    45         *
       
    46         * @param aAppName the name of this application
       
    47         * @param aObserver observer to callback when locations are retrieved
       
    48         */
       
    49         static CLandmarksPositionRequest* NewL(
       
    50             const TDesC& aAppName,
       
    51             MLandmarksOperationObserver* aObserver);
       
    52 
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56         ~CLandmarksPositionRequest();
       
    57 
       
    58     public: // New Functions
       
    59 
       
    60         /**
       
    61         * Starts the fetching of a location. In the first place the default 
       
    62         * proxy is used for retrieving a location. If fetching default location
       
    63         * fails the last known location is fetched. If fetching last known 
       
    64         * location fails, an error code is returned to the observer.
       
    65         *
       
    66         * @param aMessage the message to present in the progress dialog.
       
    67         * @param aPositionInfo contains the fetched location
       
    68         */
       
    69         void FetchPositionInfoL(
       
    70             const TDesC& aMessage,
       
    71             TPositionInfo& aPositionInfo);
       
    72 
       
    73         /**
       
    74         * Dismisses the wait note.
       
    75         */
       
    76         void DismissWaitNote();
       
    77 
       
    78     protected: // from CActive
       
    79 
       
    80         /**
       
    81         * Implements cancellation of an outstanding request.
       
    82         */
       
    83         void DoCancel();
       
    84 
       
    85         /**
       
    86         * Handles an active object’s request completion event.
       
    87         */
       
    88         void RunL();
       
    89 
       
    90         /**
       
    91         * Handles a leave occurring in the request completion event 
       
    92         * handler RunL().
       
    93         *
       
    94         * @return KErrNone
       
    95         */
       
    96         TInt RunError(TInt aError);
       
    97 
       
    98     public: // from MProgressDialogCallback
       
    99 
       
   100         //! Inherited from MProgressDialogCallback
       
   101         void DialogDismissedL(TInt aButtonId);
       
   102 
       
   103     private:
       
   104 
       
   105         /**
       
   106         * C++ constructor.
       
   107         *
       
   108         * @param aObserver observer to callback when locations are retrieved
       
   109         */
       
   110         CLandmarksPositionRequest(
       
   111             MLandmarksOperationObserver* aObserver);
       
   112 
       
   113         /**
       
   114         * By default Symbian 2nd phase constructor is private.
       
   115         */
       
   116         void ConstructL(const TDesC& aAppName);
       
   117 
       
   118         /**
       
   119         * Executes the next step of the location retrieval.
       
   120         */
       
   121         void ExecuteNextStep();
       
   122 
       
   123         /**
       
   124         * Notifies the observer that the location retrieval is complete.
       
   125         *
       
   126         * @param aError the status of the location retrieval
       
   127         */
       
   128         void NotifyOperationCompleteL(TInt aError);
       
   129 
       
   130         /**
       
   131         * Initializes the class to be ready for location acquisition.
       
   132         */
       
   133         void InitializeL();
       
   134 
       
   135         /**
       
   136         * Informs user about location request failure.
       
   137         */
       
   138         void ShowErrorL(TInt aError);
       
   139 
       
   140     private: // Data types
       
   141 
       
   142         /**
       
   143         * TState defines the different states this object may enter.
       
   144         */
       
   145         enum TState 
       
   146             {
       
   147             EIdle,
       
   148             EAcquiringDefaultLocation,
       
   149             EAcquiringLastKnownLocation,
       
   150             EDismissingDialog
       
   151             };
       
   152 
       
   153     private: // Data
       
   154 
       
   155         //! Contains the location
       
   156         TPositionInfo* iPositionInfo;
       
   157 
       
   158         //! The observer to callback when location retieval is ready
       
   159         MLandmarksOperationObserver* iObserver;
       
   160 
       
   161         //! Reference to the Location Server session
       
   162         RPositionServer iLocationServer;
       
   163 
       
   164         //! Reference to the Location Server subsession
       
   165         RPositioner iPositioner;
       
   166 
       
   167         //! The current state this object has entered
       
   168         TState iState;
       
   169 
       
   170         //! The progress bar displayed when active
       
   171         CAknWaitDialog* iWaitNote;
       
   172 
       
   173         //! The name of this application
       
   174         HBufC* iAppName;
       
   175 
       
   176     };
       
   177 
       
   178 #endif // __LANDMARKS_POSITION_REQUEST_H__
       
   179 
       
   180