locationmanager/client/src/rlocationtrail.cpp
changeset 0 c53acadfccc6
child 40 910a23996aa0
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2006-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:  An interface to Location Manager server
       
    15 *
       
    16 */
       
    17 
       
    18 #include <f32file.h>
       
    19 #include <s32mem.h>
       
    20 #include <data_caging_path_literals.hrh>
       
    21 
       
    22 #include <locationeventdef.h>
       
    23 #include "rlocationtrail.h"
       
    24 #include "locationmanagerdefs.h"
       
    25 #include "locationmanagerdebug.h"
       
    26 
       
    27 EXPORT_C RLocationTrail::RLocationTrail() : iCurrentLocData( NULL )
       
    28 	{
       
    29 	}
       
    30 
       
    31 EXPORT_C RLocationTrail::~RLocationTrail()
       
    32 	{
       
    33 	delete iCurrentLocData;
       
    34 	}
       
    35 
       
    36 // --------------------------------------------------------------------------
       
    37 // RLocationTrail::StartLocationTrail
       
    38 // --------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C TInt RLocationTrail::StartLocationTrail(TTrailCaptureSetting aState)
       
    41     {
       
    42     LOG( "RLocationTrail::StartLocationTrail()" );
       
    43     TInt ret( KErrDisconnected );
       
    44     TPckg<TTrailCaptureSetting> state( aState );
       
    45     
       
    46     if ( aState == RLocationTrail::EOff )
       
    47     	{
       
    48     	return KErrArgument;
       
    49     	}
       
    50     
       
    51     if ( iHandle )
       
    52         {
       
    53         ret = SendReceive( ELocManStartTrail, TIpcArgs( &state ) );
       
    54         }
       
    55     return ret;
       
    56     }
       
    57 // --------------------------------------------------------------------------
       
    58 // RLocationTrail::StopLocationTrail
       
    59 // --------------------------------------------------------------------------
       
    60 //
       
    61 EXPORT_C TInt RLocationTrail::StopLocationTrail()
       
    62     {
       
    63     LOG( "RLocationTrail::StopLocationTrail()" );
       
    64     TInt ret( KErrNone );
       
    65     if ( iHandle )
       
    66         {
       
    67         Send( ELocManStopTrail );    
       
    68         }
       
    69     else
       
    70         {
       
    71         ret = KErrDisconnected;
       
    72         }
       
    73     
       
    74     return ret;
       
    75     }
       
    76 // --------------------------------------------------------------------------
       
    77 // RLocationTrail::GetLocationTrailState
       
    78 // --------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C TInt RLocationTrail::GetLocationTrailState( TTrailState& aState )
       
    81     {
       
    82     LOG( "RLocationTrail::GetLocationTrailState()" );
       
    83     TInt ret( KErrDisconnected );
       
    84     TPckg<TTrailState> state( aState );
       
    85     
       
    86     if ( iHandle )
       
    87         {
       
    88         ret = SendReceive( ELocManTrailState, TIpcArgs( &state ) );
       
    89         }
       
    90     return ret;
       
    91     }
       
    92 // --------------------------------------------------------------------------
       
    93 // RLocationTrail::NotifyLocationTrailStateChange
       
    94 // --------------------------------------------------------------------------
       
    95 //
       
    96 EXPORT_C void RLocationTrail::NotifyLocationTrailStateChange( TRequestStatus& aStatus )
       
    97     {
       
    98     LOG( "RLocationTrail::NotifyLocationTrailStateChange()" );
       
    99     if ( iHandle )
       
   100         {
       
   101         SendReceive( ELocManNotifyTrailStateChange, aStatus );
       
   102         }        
       
   103     else
       
   104         {
       
   105         CompleteRequest(aStatus, KErrDisconnected);
       
   106         }
       
   107     }
       
   108 
       
   109 // --------------------------------------------------------------------------
       
   110 // RLocationTrail::CancelNotificationRequest
       
   111 // --------------------------------------------------------------------------
       
   112 //
       
   113 EXPORT_C void RLocationTrail::CancelNotificationRequest()
       
   114     {
       
   115     LOG( "RLocationTrail::CancelNotificationRequest()" );
       
   116     if ( iHandle )
       
   117     	{
       
   118         SendReceive( ELocManCancelNotification );
       
   119     	}
       
   120     }    
       
   121 
       
   122 // --------------------------------------------------------------------------
       
   123 // RLocationTrail::RetrieveLocation
       
   124 // --------------------------------------------------------------------------
       
   125 //    
       
   126 EXPORT_C TInt RLocationTrail::RetrieveLocation( const TTime& aTimeStamp, 
       
   127 												TLocationData& aLocationData,
       
   128                                                 TTrailState& aState )
       
   129     {
       
   130     TInt ret( KErrDisconnected );
       
   131     TPckg<TTime> timeStamp( aTimeStamp );
       
   132     TPckg<TTrailState> state( aState );
       
   133     TPckg<TLocationData> locationData( aLocationData );
       
   134     if ( iHandle )
       
   135         {
       
   136         ret = SendReceive( ELocManRetrieveLoc, TIpcArgs( &timeStamp, &locationData, &state ) );    
       
   137         }
       
   138     return ret;
       
   139     }
       
   140 
       
   141 // --------------------------------------------------------------------------
       
   142 // RLocationTrail::CurrentLocation
       
   143 // --------------------------------------------------------------------------
       
   144 //
       
   145 EXPORT_C void RLocationTrail::CurrentLocation( TRequestStatus& aStatus, 
       
   146 											   TLocationData& aLocationData )
       
   147     {
       
   148     LOG( "RLocationTrail::CurrentLocation(), begin" );
       
   149     
       
   150     delete iCurrentLocData;
       
   151     iCurrentLocData = new TPckg<TLocationData>( aLocationData );
       
   152     
       
   153     if ( iHandle && iCurrentLocData )
       
   154         {
       
   155         SendReceive( ELocManCurrentLoc, TIpcArgs( iCurrentLocData ), aStatus );
       
   156         }
       
   157     else
       
   158         {
       
   159         if ( !iCurrentLocData )
       
   160         	{
       
   161         	CompleteRequest(aStatus, KErrNoMemory);
       
   162         	}
       
   163         else
       
   164         	{
       
   165         	CompleteRequest(aStatus, KErrDisconnected);
       
   166         	}
       
   167         }
       
   168     LOG( "RLocationTrail::CurrentLocation(), end" );
       
   169     }
       
   170 
       
   171 // --------------------------------------------------------------------------
       
   172 // RLocationTrail::CancelLocationRequest
       
   173 // --------------------------------------------------------------------------
       
   174 //
       
   175 EXPORT_C void RLocationTrail::CancelLocationRequest()
       
   176     {
       
   177     if ( iHandle )
       
   178         {
       
   179         SendReceive( ELocManCancelCurrentLoc );
       
   180         }
       
   181     }
       
   182 
       
   183 EXPORT_C TInt RLocationTrail::GetTrailCaptureSetting( TTrailCaptureSetting& aCaptureSetting )
       
   184 	{
       
   185 	TPckg<TTrailCaptureSetting> captureSetting( aCaptureSetting );
       
   186 	TInt err( KErrDisconnected );
       
   187 	
       
   188 	if ( iHandle )
       
   189 		{
       
   190 		err = SendReceive( ELocManGetCaptureSetting, TIpcArgs( &captureSetting ) );
       
   191 		}
       
   192 	
       
   193 	return err;
       
   194 	}
       
   195 
       
   196 //End of File