datasourcemodules/bluetoothgpspositioningmodule/btgpspsy/inc/RequestHandler/BTGPSRequestManager.h
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef BTGPSREQUESTMANAGER_H
       
    22 #define BTGPSREQUESTMANAGER_H
       
    23 
       
    24 //  INCLUDES
       
    25 
       
    26 #include <e32base.h> 
       
    27 
       
    28 #include "BTGPSMessageListener.h"
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // MACROS
       
    33 
       
    34 // DATA TYPES
       
    35 
       
    36 // FUNCTION  PROTOTYPES
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CBTGPSConnectManager;
       
    40 class CBTGPSConstantsManager;
       
    41 class MBTGPSLocationFixListener;
       
    42 class CBTGPSFix;
       
    43 class CBTGPSNmeaBuffer;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /**
       
    48 *  This class defines locaiton request managers. It's responsible of 
       
    49 *  receiving NMEA sentence and retrieving fix information for sentence
       
    50 *  stream. It also manage GSV sentence life time information.
       
    51 * 
       
    52 */
       
    53 class CBTGPSRequestManager: public CBase, private MBTGPSMessageListener
       
    54     {
       
    55     public: 
       
    56 
       
    57         /**
       
    58         * Two-phase construction.
       
    59 		* @param aConnectManager Reference to connect manager.
       
    60         */
       
    61         static CBTGPSRequestManager * NewL(
       
    62             CBTGPSConnectManager& aConnectManager,
       
    63             CBTGPSConstantsManager& aConstantsManager);
       
    64 
       
    65         /**
       
    66         * Destructor
       
    67         */
       
    68         virtual ~CBTGPSRequestManager();
       
    69 
       
    70     public:
       
    71         /**
       
    72         * Start to retrieve fix
       
    73         */
       
    74         void RetrieveFixL();
       
    75 
       
    76         /**
       
    77         * Stop retrieving fix
       
    78         */
       
    79         void StopRetrievingFix();
       
    80         
       
    81         /**
       
    82         * Receive last location
       
    83 		* @param aFix On return contains pointer to fix information
       
    84 		* @param aMaxAge Max age tath defined by client
       
    85 		* @param aAcceptPartial If the client accept partial updates.
       
    86         */
       
    87         TInt LastLocation(
       
    88             const CBTGPSFix*& aFix,
       
    89             const TTime& aMaxAge,
       
    90             const TBool aAcceptPartial);
       
    91             
       
    92         /**
       
    93         * Invalid last location and GSV life time. This function is used 
       
    94         * by CBTGPSEnvChangeHandler. When system time is changed
       
    95         * last location shall be invalidated.
       
    96         */
       
    97         void SystemTimeChange();
       
    98         
       
    99         /**
       
   100         * Add listener
       
   101 		* @param aListener Reference to listener
       
   102         */
       
   103         void AddListenerL(MBTGPSLocationFixListener& aListener);
       
   104         
       
   105         /**
       
   106         * Remove listener
       
   107 		* @param aListener Reference to listener
       
   108         */
       
   109         void RemoveListener(MBTGPSLocationFixListener& aListener);
       
   110         
       
   111         /**
       
   112         * Get previous NMEA buffer index
       
   113         */
       
   114         TInt GetPreviousNmeaBufferBottom() const;
       
   115 
       
   116     private:
       
   117         /**
       
   118         * From MBTGPSMessageListener
       
   119         */
       
   120         void HandleMessage(const TBTGPSNmeaParser& aParser);
       
   121     
       
   122     private:
       
   123 
       
   124         /**
       
   125         * Second phase of the construction
       
   126         */
       
   127         void ConstructL();
       
   128 
       
   129         /**
       
   130         * Private constructor
       
   131         */
       
   132         CBTGPSRequestManager(
       
   133             CBTGPSConnectManager& aConnectManager,
       
   134             CBTGPSConstantsManager& aConstantsManager);
       
   135 
       
   136         /**
       
   137         * Complete all request
       
   138         */
       
   139         void CompleteAllReqeust(TInt aErr);
       
   140         
       
   141         /**
       
   142         * Inform listners on new fix information
       
   143         */
       
   144         void InformListeners();
       
   145         
       
   146         /**
       
   147         * Timer callback
       
   148         */
       
   149         void TimerTick();
       
   150         
       
   151         /**
       
   152         * Static timer callback
       
   153         */
       
   154         static TInt TimerCallback(TAny* aAny);
       
   155         
       
   156     private:
       
   157         //Connect Manager
       
   158         CBTGPSConnectManager& iConnectManager;
       
   159         
       
   160         //Constants Manager
       
   161         CBTGPSConstantsManager& iConstantsManager;
       
   162 
       
   163         //Location fix listener
       
   164         RArray<MBTGPSLocationFixListener*> iListenerArray;
       
   165 
       
   166         //NMEA buffer. It's a FIFO circulate buffer that
       
   167         //holds all received NMEA message
       
   168         CBTGPSNmeaBuffer* iNmeaBuffer;
       
   169         
       
   170         //Index to the previous bottom in NMEA buffer
       
   171         TInt iPrevBottom;
       
   172         
       
   173         //Current Fix
       
   174         CBTGPSFix* iFix;
       
   175         
       
   176         //Last fix
       
   177         CBTGPSFix* iLastFix;
       
   178 
       
   179         //Start to receive message
       
   180         TBool iReceivingMessage;
       
   181         
       
   182         //GSV Timer
       
   183         CPeriodic* iTimer;
       
   184     };
       
   185 #endif
       
   186 // End of File
       
   187