datasourcemodules/bluetoothgpspositioningmodule/btgpspsy/inc/RequestHandler/BTGPSPsyConnectionManager.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 BTGPSPSYCONNECTIONMANAGER_H
       
    22 #define BTGPSPSYCONNECTIONMANAGER_H
       
    23 
       
    24 //  INCLUDES
       
    25 
       
    26 #include <e32base.h> 
       
    27 
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // DATA TYPES
       
    34 
       
    35 // FUNCTION  PROTOTYPES
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 
       
    39 // CLASS DECLARATION
       
    40 class MBTGPSPositionerExt;
       
    41 class CBTGPSFix;
       
    42 class TPositionModuleStatus;
       
    43 class MBTGPSPsyConnectionListener;
       
    44     
       
    45 
       
    46 /**
       
    47 *  This class defines PSY connection information manager. It manage PSY connection
       
    48 *  informaiton as well as location request and tracking status of each PSY. 
       
    49 *
       
    50 */
       
    51 class CBTGPSPsyConnectionManager: public CBase
       
    52     {
       
    53     public: 
       
    54 
       
    55         /**
       
    56         * Two-phase construction.
       
    57         */
       
    58         static CBTGPSPsyConnectionManager * NewL();
       
    59 
       
    60         /**
       
    61         * Destructor
       
    62         */
       
    63         virtual ~CBTGPSPsyConnectionManager();
       
    64 
       
    65     public:
       
    66         /**
       
    67         * Register PSY
       
    68 		* @param aPSY Pointer to new positioner
       
    69         */
       
    70         void RegisterPSYL(MBTGPSPositionerExt* aPSY);
       
    71 
       
    72         /**
       
    73         * UnregisterPSY
       
    74 		* @param aPSY Pointer to positioner
       
    75         */
       
    76         void UnregisterPSY(MBTGPSPositionerExt* aPSY);
       
    77 
       
    78         /**
       
    79         * PSY start to acquire location
       
    80 		* @param aPSY Pointer to positioner
       
    81         */
       
    82         void AcquireLocation(MBTGPSPositionerExt* aPSY);
       
    83 
       
    84         /**
       
    85         * PSY cancel a location request
       
    86 		* @param aPSY Pointer to positioner
       
    87         */
       
    88         void CancelAcquireLocation(MBTGPSPositionerExt* aPSY);
       
    89 
       
    90         /**
       
    91         * Complete request with error code. This function is called
       
    92 		* when the locaitn request shall be completed with error code.
       
    93 		*
       
    94 		* @param aPSY Reference to positioner
       
    95 		* @param aErr The error code that location request shall be completed.
       
    96         */
       
    97         void CompleteRequest(
       
    98             MBTGPSPositionerExt& aPSY,
       
    99             TInt aErr);
       
   100         
       
   101         /**
       
   102         * Complete all requests with error code
       
   103 		* @param aErr Error code
       
   104         */
       
   105         void CompleteAllRequests(TInt aErr);
       
   106         
       
   107         /**
       
   108         * Location fix update. Inform all PSY that there is location information
       
   109 		* updates.
       
   110 		* @param aFix Reference to location fix information.
       
   111         */
       
   112         void LocationFixUpdate(const CBTGPSFix& aFix);
       
   113         
       
   114         /**
       
   115         * Report posintion module status.
       
   116 		* @param aStatus new position module status.
       
   117         */
       
   118         void ReportStatus(const TPositionModuleStatus& aStatus);
       
   119             
       
   120         /**
       
   121         * Get number of connected PSY
       
   122 		* @return The number of connected PSy
       
   123         */
       
   124         TInt Count() const;
       
   125 
       
   126         /**
       
   127         * Get number of active location requests
       
   128 		* @return The number of PSY that has location requests on going.
       
   129         */
       
   130         TInt LocationRequestCount() const;
       
   131         
       
   132         /**
       
   133         * Get number of tracking session
       
   134 		* @return The number of PSY that has tracking session on going.
       
   135         */
       
   136         TInt TrackingSessionCount() const;
       
   137 
       
   138         /**
       
   139         * Inform a tracking session is started
       
   140 		* @param aPSY Pointer to PSY that starts a tracking session.
       
   141 		* @param aInterval The tracking interval.
       
   142         */
       
   143         void TrackingSessionStartL(
       
   144             MBTGPSPositionerExt* aPSY,
       
   145             TTimeIntervalMicroSeconds aInterval);
       
   146 
       
   147         /**
       
   148         * Tracking session stops
       
   149 		* @param aPSY Pointer to positioner
       
   150         */
       
   151         void TrackingSessionStop(MBTGPSPositionerExt* aPSY);
       
   152         
       
   153         /**
       
   154         * Add PSY connection information change listener
       
   155 		* @param aListener Reference to listener
       
   156         */
       
   157         void AddListenerL(MBTGPSPsyConnectionListener& aListener);
       
   158         
       
   159         /**
       
   160         * Remove PSY connection information change listener
       
   161 		* @param aListener Reference to listener.
       
   162         */
       
   163         void RemoveListener(MBTGPSPsyConnectionListener& aListener);
       
   164     
       
   165     private:
       
   166 		/**
       
   167 		* Structer of connected PSY and it's status
       
   168 		*/
       
   169         struct TPSYStatusStruct
       
   170             {
       
   171             //Pointer to connected PSY
       
   172             MBTGPSPositionerExt* iPsy;
       
   173             
       
   174             //If PSY has a location request on going
       
   175             TBool iLocationRequest;
       
   176             
       
   177             //Tracking Interval. If PSY doesn't has a tracking session,
       
   178             //the value is -1
       
   179             TTimeIntervalMicroSeconds iTrackingInterval;
       
   180             };
       
   181         
       
   182     private:
       
   183 
       
   184         /**
       
   185         * Second phase of the construction
       
   186         */
       
   187         void ConstructL();
       
   188 
       
   189         /**
       
   190         * Private constructor
       
   191         */
       
   192         CBTGPSPsyConnectionManager();
       
   193         
       
   194         /**
       
   195         * Find PSY Status from PSY array
       
   196         */
       
   197         TInt FindPsy(MBTGPSPositionerExt* aPSY);
       
   198         
       
   199         /**
       
   200         * Complete location request with fix or error code
       
   201         */
       
   202         void CompleteLocationRequest(
       
   203             TInt aIndex,
       
   204             const CBTGPSFix* aFix,
       
   205             TInt aErr);
       
   206             
       
   207         /**
       
   208         * Inform listeners the connection status is changed
       
   209         */
       
   210         void InformListenersChange();
       
   211         
       
   212     private:
       
   213         //Connected PSY array
       
   214         RArray<TPSYStatusStruct> iPsyArray;
       
   215         
       
   216         //Listener array
       
   217         RArray<MBTGPSPsyConnectionListener*> iListenerArray;
       
   218 
       
   219     };
       
   220 #endif
       
   221 // End of File
       
   222