diff -r 000000000000 -r c53acadfccc6 locationmanager/locationtrail/inc/cgpxconverterao.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locationmanager/locationtrail/inc/cgpxconverterao.h Mon Jan 18 20:34:07 2010 +0200 @@ -0,0 +1,190 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Active object for converting internal fileformat to GPX +* +*/ + + +#ifndef CGPXCONVERTERAO_H_ +#define CGPXCONVERTERAO_H_ + +#include +#include +#include +#include +#include +#include "ctracklog.h" + +const TInt KWriteBufSize = 256; + +_LIT( KTagXml, "" ); +_LIT( KTagGpxStart, "" ); +_LIT( KTagGpxEnd, "" ); +_LIT( KTagMetaStart, "" ); +_LIT( KTagMetaEnd, "" ); +_LIT( KTagName, "%S" ); +_LIT( KTagBounds, "" ); +_LIT( KTagTrackStart, "" ); +_LIT( KTagTrackEnd, "" ); +_LIT( KTagSegmentStart, "" ); +_LIT( KTagSegmentEnd, "" ); +_LIT( KTagTrkPointStart, "" ); +_LIT( KTagTrkPointEnd, "" ); +_LIT( KTagElevation, "%f" ); +_LIT( KTagTimeStamp, "" ); +_LIT( KTagCourse, "%f" ); +_LIT( KTagFix3D, "3d" ); +_LIT( KTagFix2D, "2d" ); +_LIT( KTagSatellites, "%d" ); +_LIT( KTagHdop, "%f" ); +_LIT( KTagVdop, "%f" ); + +class CGpxConverterAO : public CActive + { + private: + enum TProcessingState + { + EIdle, + ENextFile, + ECrashRecovery, + EStartFile, + EProcessing, + ECloseFile + }; + + public: + /** + * Creates and constructs a new instance of CContextBackupSubscriberAO. + * + * @return A pointer to the new instance. + */ + static CGpxConverterAO* NewL(); + + /** + * Destructor. + */ + virtual ~CGpxConverterAO(); + + /** + * From CActive. + * This method will be called when Backup & Restore state changes. + */ + void RunL(); + + /** + * From CActive. + * Handles a leave occurring in the request completion event handler RunL(). + * + * @param aError An error code. + * @return An error code. + */ + TInt RunError( TInt aError ); + + /** + * From CActive. + * Cancels. + */ + void DoCancel(); + + /** + * Adds temp-file and possible pre-calculated boundaries + * into processing queue + */ + void AddToQueueL( const TDesC& aFileName, TBoundaries* aBoundaries = NULL ); + + /** + * Adds observer for GPX file creation notifications + */ + void AddObserver( MGpxConversionObserver* aObserver ); + + private: + + /** + * Default constructor, implicitly called by NewL(). + */ + CGpxConverterAO(); + + /** + * 2nd phase construction, called by NewL(). + */ + void ConstructL(); + + /** + * Set next state for RunL + */ + void SetState( TProcessingState aState ); + + /** + * Resolve where to save tracklog file + */ + void GetTrackLogPathL( TDes& aFileName ); + + /** + * Read Tag Id from temp-file + */ + void ReadTagIdL(); + + /** + * Calculate min and max coordinates for tracklog + */ + void CalculateBoundaries(); + + /** + * Writes header tags for GPX file + */ + void WriteStartingTags(); + + /** + * Writes single trackpoint to GPX file + */ + void WriteItemToFile(); + + /** + * Close GPX file + */ + void WriteClosingTags(); + + private: // data + + TInt iState; + + RPointerArray iFileQueue; + RPointerArray iBoundQueue; + + TFileName iTempFile; + TBoundaries* iBoundaries; + TCoordinate* iLastCoords; + TFileName iGpxFileName; + TFileName iGpxPath; + + RFs iFs; + RFileReadStream iReader; + RFile64 iGpxFile; + + TTrackLogItem iTempItem; + + HBufC8* iWriteBuf; + HBufC* iFormatBuf; + + TBool iFixLost; + TItemId iTagId; + + TTime iStartTime; + TTime iEndTime; + + RPointerArray iObservers; + + }; + +#endif /*CGPXCONVERTERAO_H_*/