locationmanager/locationtrail/src/cgpxconverterao.cpp
changeset 25 8e4539ab1889
parent 21 50bf9db68373
child 36 aa5a574040a4
equal deleted inserted replaced
23:33ae025ac1e8 25:8e4539ab1889
    23 
    23 
    24 // ---------------------------------------------------------------------------
    24 // ---------------------------------------------------------------------------
    25 // Default constructor.
    25 // Default constructor.
    26 // ---------------------------------------------------------------------------
    26 // ---------------------------------------------------------------------------
    27 //
    27 //
    28 CGpxConverterAO::CGpxConverterAO() : CActive( CActive::EPriorityStandard )
    28 CGpxConverterAO::CGpxConverterAO() : CActive( CActive::EPriorityStandard ),
       
    29         iTempFile(NULL),
       
    30         iBoundaries(NULL)
    29     {
    31     {
    30     }
    32     }
    31 
    33 
    32 // ---------------------------------------------------------------------------
    34 // ---------------------------------------------------------------------------
    33 // Standard NewL for first phase construction.
    35 // Standard NewL for first phase construction.
    73     iFileQueue.ResetAndDestroy();
    75     iFileQueue.ResetAndDestroy();
    74     iFileQueue.Close();
    76     iFileQueue.Close();
    75     
    77     
    76     iBoundQueue.ResetAndDestroy();
    78     iBoundQueue.ResetAndDestroy();
    77     iBoundQueue.Close();
    79     iBoundQueue.Close();
    78     
    80 
       
    81     delete iTempFile;
       
    82     delete iBoundaries;
       
    83         
    79     delete iWriteBuf;
    84     delete iWriteBuf;
    80     delete iFormatBuf;
    85     delete iFormatBuf;
    81     }
    86     }
    82 
    87 
    83 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
   156 			LOG("CGpxConverterAO::RunL - ENextFile");
   161 			LOG("CGpxConverterAO::RunL - ENextFile");
   157 			if( iFileQueue.Count() > 0 )
   162 			if( iFileQueue.Count() > 0 )
   158 				{
   163 				{
   159 				TInt err;
   164 				TInt err;
   160 				iFixLost = ETrue;
   165 				iFixLost = ETrue;
       
   166                 delete iTempFile;
       
   167                 delete iBoundaries;
   161 				// get next temp-file from queue
   168 				// get next temp-file from queue
   162 				iTempFile = *iFileQueue[0];
   169 				iTempFile = iFileQueue[0];
   163 				iBoundaries = iBoundQueue[0];
   170 				iBoundaries = iBoundQueue[0];
   164 				err = iReader.Open( iFs, iTempFile, EFileRead );				
   171 				err = iReader.Open( iFs, *iTempFile, EFileRead );				
   165 				// remove from queue				
   172 				// remove from queue				
   166 				iFileQueue.Remove( 0 );
   173 				iFileQueue.Remove( 0 );
   167 				iBoundQueue.Remove( 0 );
   174 				iBoundQueue.Remove( 0 );
   168 				if ( err != KErrNone )
   175 				if ( err != KErrNone )
   169 					{
   176 					{
   199 				}
   206 				}
   200 			else
   207 			else
   201 				{
   208 				{
   202 				TInt err;
   209 				TInt err;
   203 				iReader.Close();
   210 				iReader.Close();
   204 				err = iReader.Open( iFs, iTempFile, EFileRead );
   211 				err = iReader.Open( iFs, *iTempFile, EFileRead );
   205 				if( err != KErrNone )
   212 				if( err != KErrNone )
   206 					{
   213 					{
   207 					SetState( ENextFile );
   214 					SetState( ENextFile );
   208 					}
   215 					}
   209 				TRAP( err, ReadTagIdL() );
   216 				TRAP( err, ReadTagIdL() );
   214 			}
   221 			}
   215 		case( EStartFile ):
   222 		case( EStartFile ):
   216 			{
   223 			{
   217 			LOG("CGpxConverterAO::RunL - EStartFile");
   224 			LOG("CGpxConverterAO::RunL - EStartFile");
   218 			_LIT( KExtGPX, ".gpx" );
   225 			_LIT( KExtGPX, ".gpx" );
   219 			TParsePtrC parse( iTempFile );
   226 			TParsePtrC parse( *iTempFile );
   220 			
   227 			
   221 			TRAPD(err, GetTrackLogPathL( iGpxPath ));
   228 			TRAPD(err, GetTrackLogPathL( iGpxPath ));
   222 			
   229 			
   223 			iGpxFileName.Copy( parse.Name() );
   230 			iGpxFileName.Copy( parse.Name() );
   224 			iGpxFileName.Append( KExtGPX );
   231 			iGpxFileName.Append( KExtGPX );
   286 			for( TInt i = iObservers.Count() - 1; i >=0; i-- )
   293 			for( TInt i = iObservers.Count() - 1; i >=0; i-- )
   287 				{
   294 				{
   288 				iObservers[i]->GpxFileCreated( iGpxPath, iTagId, distance, iStartTime, iEndTime );
   295 				iObservers[i]->GpxFileCreated( iGpxPath, iTagId, distance, iStartTime, iEndTime );
   289 				}
   296 				}
   290 			
   297 			
       
   298 			
       
   299 			iFs.Delete( *iTempFile );
       
   300 			
       
   301 			delete iTempFile;
       
   302 			iTempFile = NULL;
       
   303 			
   291 			delete iBoundaries;
   304 			delete iBoundaries;
   292 			iFs.Delete( iTempFile );
   305 			iBoundaries = NULL;
       
   306 			
   293 			SetState( ENextFile );
   307 			SetState( ENextFile );
   294 			break;
   308 			break;
   295 			}
   309 			}
   296 		}
   310 		}
   297 	}
   311 	}