locationmanager/server/inc/clocationmanagerserver.h
branchRCL_3
changeset 63 e538444823de
parent 47 b73252188534
equal deleted inserted replaced
57:2872ae438bf7 63:e538444823de
    22 #include <e32base.h>
    22 #include <e32base.h>
    23 #include <etel3rdparty.h>
    23 #include <etel3rdparty.h>
    24 #include <centralrepository.h>
    24 #include <centralrepository.h>
    25 #include <locationdatatype.h>
    25 #include <locationdatatype.h>
    26 #include <locationeventdef.h>
    26 #include <locationeventdef.h>
    27 #ifdef LOC_REVERSEGEOCODE
       
    28 #include <geotagger.h>
       
    29 #endif //LOC_REVERSEGEOCODE
       
    30 
    27 
    31 #include "rlocationtrail.h"
    28 #include "rlocationtrail.h"
    32 #include "rlocationobjectmanipulator.h"
    29 #include "rlocationobjectmanipulator.h"
    33 #include "clocationrecord.h"
    30 #include "clocationrecord.h"
    34 #include "ctracklog.h"
    31 #include "ctracklog.h"
    36 #include "mdsutils.h"
    33 #include "mdsutils.h"
    37 #include "mdesession.h"
    34 #include "mdesession.h"
    38 #include "mdequery.h"
    35 #include "mdequery.h"
    39 #include "mderelationquery.h"
    36 #include "mderelationquery.h"
    40 #include "locationmanagerdefs.h"
    37 #include "locationmanagerdefs.h"
    41 #include "clocationservertimerhandler.h"
    38 
    42 
    39 
    43 class CMdESession;
    40 class CMdESession;
    44 class CLocationGeoTagTimerAO;
       
    45 class CGeoTagger;
       
    46 class REComSession;
       
    47 class CNwRegistrationStatusHandler;
       
    48 
    41 
    49 // Total number of ranges
    42 // Total number of ranges
    50 const TUint KLocationManagerRangeCount = 1;
    43 const TUint KLocationManagerRangeCount = 1;
    51 
    44 
    52 // Definition of the ranges of IPC numbers
    45 // Definition of the ranges of IPC numbers
    90 class CLocationManagerServer : public CPolicyServer,
    83 class CLocationManagerServer : public CPolicyServer,
    91                                public MLocationTrailObserver,
    84                                public MLocationTrailObserver,
    92                                public MMdESessionObserver,
    85                                public MMdESessionObserver,
    93                                public MMdEQueryObserver,
    86                                public MMdEQueryObserver,
    94                                public MMdEObjectObserver,
    87                                public MMdEObjectObserver,
    95                                public MGpxConversionObserver,
    88                                public MGpxConversionObserver
    96                                public MGeoTaggerObserver,
       
    97                                public MLocationServerTimerObserver
       
    98     {
    89     {
    99 private:
    90 private:
   100 	struct TMessageQuery
    91 	struct TMessageQuery
   101 		{
    92 		{
   102 		CMdERelationQuery* iQuery;
    93 		CMdERelationQuery* iQuery;
   266 	 * @since S60 3.2
   257 	 * @since S60 3.2
   267 	 * @param aObjectId
   258 	 * @param aObjectId
   268 	 * @return None.
   259 	 * @return None.
   269 	 */ 
   260 	 */ 
   270 	void RemoveLocationObjectL(TUint& aObjectId);
   261 	void RemoveLocationObjectL(TUint& aObjectId);
   271 
       
   272 	/**
       
   273 	  * Copies the location object
       
   274 	  * @param aSource source location object
       
   275 	  *	@param aTargets target location object
       
   276 	  * @param aQuery message query type
       
   277 
       
   278 	  */	
       
   279 	void CopyLocationObjectL( TItemId aSource, const RArray<TItemId>& aTargets, TMessageQuery& aQuery );
   262 	void CopyLocationObjectL( TItemId aSource, const RArray<TItemId>& aTargets, TMessageQuery& aQuery );
   280 
       
   281 	/**
       
   282 	  * Copies the location object
       
   283 	  * @param aSource The source location object
       
   284 	  *	@param aTargets target location object
       
   285 	  * @param aQuery message query type
       
   286 	  */
       
   287 	void CopyLocationObjectL( const TDesC& aSource, const RArray<TPtrC>& aTargets, TMessageQuery& aQuery );
   263 	void CopyLocationObjectL( const TDesC& aSource, const RArray<TPtrC>& aTargets, TMessageQuery& aQuery );
   288 
   264 	
   289 	/**
       
   290 	  * checks if the session is ready
       
   291 	  * @return ETrue if Session is ready
       
   292 	  */	
       
   293 	TBool IsSessionReady();
   265 	TBool IsSessionReady();
   294 
   266 	
   295 	/**
       
   296 	  * Start track log
       
   297 	  *
       
   298 	  * @return The itemId
       
   299 	  */	
       
   300 	TItemId StartTrackLogL();
   267 	TItemId StartTrackLogL();
   301 
   268 	
   302 	/** 
       
   303 	  * Stop track log
       
   304 	  *
       
   305 	  */	
       
   306 	void StopTrackLogL();
   269 	void StopTrackLogL();
   307 
   270 	
   308 	/**
       
   309 	  * IsTrackLogRecording
       
   310 	  *
       
   311 	  * @param aRec
       
   312 	  */	
       
   313 	void IsTrackLogRecording( TBool &aRec );
   271 	void IsTrackLogRecording( TBool &aRec );
   314 	
   272 	
   315 	/**
       
   316 	  * Retrieve track log status
       
   317 	  *
       
   318 	  * @param aRecording 
       
   319 	  * @param aFixQuality
       
   320 	  */
       
   321 	TInt GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality);
   273 	TInt GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality);
   322 
   274 	
   323 	/**
       
   324 	  * Delete track log
       
   325 	  *
       
   326 	  * @param aUri 
       
   327 	  */	
       
   328 	TInt DeleteTrackLogL(const TDesC& aUri);
   275 	TInt DeleteTrackLogL(const TDesC& aUri);
   329 
   276 	
   330 	/**
       
   331 	  * Track log name
       
   332 	  *
       
   333 	  * @param aFileName name of file used to track log
       
   334 	  */	
       
   335 	TInt TrackLogName(TFileName& aFileName);
   277 	TInt TrackLogName(TFileName& aFileName);
   336 	
   278 	
   337 	/**
       
   338 	  * Gets the location trail capture settings
       
   339 	  * @param aCaptureSetting The location trail capture settings
       
   340 	  */	
       
   341 	void GetCaptureSetting( RLocationTrail::TTrailCaptureSetting& aCaptureSetting );
   279 	void GetCaptureSetting( RLocationTrail::TTrailCaptureSetting& aCaptureSetting );
   342 
   280 	
   343 	/**
       
   344 	  * Adds an observer  for Gpx conversion
       
   345 	  * @param aObserver the observer for Gpx conversion
       
   346 	  */
       
   347 	void AddGpxObserver( MGpxConversionObserver* aObserver );
   281 	void AddGpxObserver( MGpxConversionObserver* aObserver );
   348 	
   282 	
   349 	/**
       
   350 	  * Copy location by Id
       
   351 	  * @param aMessage
       
   352 	  */	
       
   353 	void InitCopyLocationByIdL( const RMessage2& aMessage );
   283 	void InitCopyLocationByIdL( const RMessage2& aMessage );
   354 	
       
   355 	/**
       
   356 	  * Copy Location by Uri
       
   357 	  * @param aMessage
       
   358 	  */
       
   359 	void InitCopyLocationByURIL( const RMessage2& aMessage );
   284 	void InitCopyLocationByURIL( const RMessage2& aMessage );
   360 
   285 
   361 	/**
       
   362 	  * Handles tag pending request
       
   363 	  *
       
   364 	  * @param aMessage IPC message
       
   365 	  */	
       
   366     void TagPendingRequestL( const RMessage2& aMessage );
       
   367 
       
   368 	/**
       
   369 	  * Cancels the tag pending request
       
   370 	  * @param aMessage IPC message
       
   371 	  */	
       
   372     void CancelTagPendingRequest( const RMessage2& aMessage );
       
   373 
       
   374 	/**
       
   375 	  * Cancels the geotagging request
       
   376 	  * @param aMessage IPC message
       
   377 	  */
       
   378 	void CancelGeoTaggingRequest( const RMessage2& aMessage );
       
   379 
       
   380 
       
   381 	/**
       
   382 	  * Handle starts geotagging request
       
   383 	  * @param aMessage IPC message
       
   384 	  */
       
   385     void StartGeoTaggingL( const RMessage2& aMessage );
       
   386     
       
   387 public: // from MLocationTrailObserver.
   286 public: // from MLocationTrailObserver.
   388     /**
   287     /**
   389      * Callback method to get notification about trail state change.
   288      * Callback method to get notification about trail state change.
   390      * @since S60 3.1
   289      * @since S60 3.1
   391      * @param None.
   290      * @param None.
   439 public: // from MGpxConversionObserver
   338 public: // from MGpxConversionObserver
   440 
   339 
   441 	void GpxFileCreated( const TDesC& aFileName, TItemId aTagId, TReal32 aLength,
   340 	void GpxFileCreated( const TDesC& aFileName, TItemId aTagId, TReal32 aLength,
   442 			TTime aStart, TTime aEnd );
   341 			TTime aStart, TTime aEnd );
   443 
   342 
   444 protected:  //From MGeoTaggerObserver
       
   445 
       
   446 	/**
       
   447 	  * This method is called on completion of geotagging
       
   448 	  * and also completes start geotagging IPC message
       
   449 	  * @param aError The err code for geotagging if any
       
   450 	  */
       
   451      void GeoTaggingCompleted( const TInt aError );   
       
   452      /**
       
   453       * This method is used for notifying completion of query for pending geo tags
       
   454 	  * @param aError The err code for geotagging if any           
       
   455       */
       
   456      void PendingGeoTagReqComplete( const TInt aError );
       
   457 
       
   458     /*
       
   459     * Get registrer network country code
       
   460     *
       
   461     * @return current register n/w info
       
   462     */
       
   463     RMobilePhone::TMobilePhoneNetworkInfoV2& GetCurrentRegisterNw();
       
   464 
       
   465 
       
   466     /*
       
   467     * Get home network country code
       
   468     * @param aHomeNwInfoAvailableFlag ETrue if home n/w info available else EFalse
       
   469     * @return user home n/w info
       
   470     */
       
   471     const RMobilePhone::TMobilePhoneNetworkInfoV1& 
       
   472         GetHomeNetworkInfo(TBool& aHomeNwInfoAvailableFlag);
       
   473 
       
   474     
       
   475     /*
       
   476     * UE is registered to home network?
       
   477     *
       
   478     * @return ETrue if UE is registered at home network else EFalse
       
   479     */
       
   480     TBool IsRegisteredAtHomeNetwork();
       
   481 
       
   482 public: //MLocationServerTimerObserver
       
   483     /**
       
   484         * Timer call back
       
   485         * @param aLocationServerTimerType timer type
       
   486         * @param aErrorCode error code
       
   487         */
       
   488     void LocationServerTimerCallBackL
       
   489         (const TLocationServerTimerType aLocationServerTimerType, const TInt aErrorCode);
       
   490 private:    
   343 private:    
   491     /**
   344     /**
   492     * C++ constructor.
   345     * C++ constructor.
   493     */
   346     */
   494     CLocationManagerServer();
   347     CLocationManagerServer();
   495     
   348     
   496     /**
   349     /**
   497     * 2nd phase constructor.
   350     * 2nd phase constructor.
   498     */
   351     */
   499     void ConstructL();
   352     void ConstructL();
   500 
   353     
   501 	/**
       
   502 	  * Copies the location
       
   503 	  * @param aQuery The query
       
   504 	  */	
       
   505     void CopyLocationL( CMdEQuery& aQuery );
   354     void CopyLocationL( CMdEQuery& aQuery );
   506 
   355 
   507     /**
   356     /**
   508      * Go through all messages in lists, complete request
   357      * Go through all messages in lists, complete request
   509      * with KErrCancel status and remove items from list.
   358      * with KErrCancel status and remove items from list.
   510      */ 
   359      */ 
   511     void CancelRequests(RArray<RMessage2>& aMessagesList);
   360     void CancelRequests(RArray<RMessage2>& aMessagesList);
   512     
   361     
   513     /**
   362     
   514 	  * cancels the list of copy requests
       
   515 	  * @param aMessageList  the list of query 
       
   516 	  */
       
   517     void CancelCopyRequests(RArray<TMessageQuery>& aMessageList);
   363     void CancelCopyRequests(RArray<TMessageQuery>& aMessageList);
   518     
   364     
   519     /**
   365     /**
   520      * Create a new tracklog tag object in the database.
   366      * Create a new tracklog tag object in the database.
   521      * @return TItemId tag ID in the database
   367      * @return TItemId tag ID in the database
   548     /**
   394     /**
   549      * Callback function for positioning stop timer.
   395      * Callback function for positioning stop timer.
   550      * @param aAny, a pointer to CLocationRecord object
   396      * @param aAny, a pointer to CLocationRecord object
   551      * @return Error code
   397      * @return Error code
   552      */
   398      */
   553    void PositioningStopTimeout();
   399     static TInt PositioningStopTimeout( TAny* aAny );
   554     
   400     
   555     /**
   401     /**
   556      * Callback function to check if files were added to remapping queue with delay
   402      * Callback function to check if files were added to remapping queue with delay
   557      * @param aAny, a pointer to CLocationRecord object
   403      * @param aAny, a pointer to CLocationRecord object
   558      * @return Error code
   404      * @return Error code
   559      */
   405      */
   560     void CheckForRemappingCallback();
   406     static TInt CheckForRemappingCallback( TAny* aAny );
   561 
       
   562     
   407     
   563     /**
   408     /**
   564      * Stops location trail and deletes the positioning stop timer.
   409      * Stops location trail and deletes the positioning stop timer.
   565      */
   410      */
   566     void StopRecording();
   411     void StopRecording();
   567 
   412     
   568 	/**
       
   569 	  * Complete notify request
       
   570 	  *
       
   571 	  * @param aEventType, returns the event type
       
   572 	  * @param aError, return error type for this call.
       
   573 	  */	
       
   574     void CompleteNotifyRequest( TEventTypes aEventType, TInt aError );
   413     void CompleteNotifyRequest( TEventTypes aEventType, TInt aError );
   575 
       
   576     /**
       
   577       * Get supported TSY name
       
   578       *@param aTsyName - buffer to store the supported tsy name
       
   579       */  
       
   580     void GetCommDbTSYnameL(TDes& aTsyName);
       
   581 
       
   582     /**
       
   583       * Initialize etel to access modem parameters
       
   584       */  
       
   585     void InitialisePhoneL();
       
   586 
       
   587     /**
       
   588       * Retrieve home network
       
   589       */  
       
   590     void RetrieveHomeNetwork();
       
   591     
       
   592     /**
       
   593       * Stop the server (if possible)
       
   594       */  
       
   595     void StopServer();
       
   596 
   414 
   597 private:
   415 private:
   598     /**
   416     /**
   599      * A class for recording and storing locations.
   417      * A class for recording and storing locations.
   600      * Own.
   418      * Own.
   646     
   464     
   647     /**
   465     /**
   648      * A timer to stop location trail.
   466      * A timer to stop location trail.
   649      * Own.
   467      * Own.
   650      */
   468      */
   651     CLocationServerTimerHandler* iTimer;
   469     CPeriodic* iTimer;
   652     
   470     
   653     TBool iClientSwitch;    
   471     TBool iClientSwitch;    
   654     TInt iSessionCount;
   472     TInt iSessionCount;
   655     TBool iSessionReady;  
   473     TBool iSessionReady;  
   656     
   474     
   658     TItemId iTagId;
   476     TItemId iTagId;
   659     TInt iLocManStopDelay;
   477     TInt iLocManStopDelay;
   660     TInt iLocManStopRemapDelay;
   478     TInt iLocManStopRemapDelay;
   661     
   479     
   662     RLocationTrail::TTrailCaptureSetting iCaptureSetting;
   480     RLocationTrail::TTrailCaptureSetting iCaptureSetting;
   663     TBool iRemoveLocation;    
   481     TBool iRemoveLocation;   
   664     
   482     
   665     /**
   483     /**
   666      * A flag for state of waiting for position stop timeout.
   484      * A flag for state of waiting for position stop timeout.
   667      */
   485      */
   668     TBool iWaitForPositioningStopTimeout;
   486     TBool iWaitForPositioningStopTimeout;
   669 	RTelServer		iTelServer;
       
   670 	RMobilePhone	iPhone;	
       
   671 	TBool			iTelServerIsOpen;
       
   672 	TBool			iPhoneIsOpen;
       
   673     CNwRegistrationStatusHandler *iNwRegistrationStatusHandler;
       
   674     RMobilePhone::TMobilePhoneNetworkInfoV1 iHomeNetwork;
       
   675     TBool iHomeNwInfoAvailableFlag;
       
   676   
       
   677     CLocationGeoTagTimerAO* iGeoTagTimer;
       
   678     
       
   679 #ifdef LOC_REVERSEGEOCODE
       
   680     CGeoTagger* iGeoTaggingPendingReqObj;
       
   681     RMessage2 iTagPendingMessage;
       
   682     RMessage2 iGeoTaggingMessage;
       
   683     REComSession* iEcomSession; 
       
   684 #endif //LOC_REVERSEGEOCODE
       
   685     };
   487     };
   686 
   488 
   687 
   489 
   688 #endif // C_CLOCATIONMANAGERSERVER_H
   490 #endif // C_CLOCATIONMANAGERSERVER_H
   689 
   491