51
|
1 |
/*
|
|
2 |
* Copyright (c) 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 |
#ifndef MEMSPYENGINEOUTPUTSINKFILE_H
|
|
19 |
#define MEMSPYENGINEOUTPUTSINKFILE_H
|
|
20 |
|
|
21 |
// System includes
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <f32file.h>
|
|
24 |
|
|
25 |
// User includes
|
|
26 |
#include <memspy/engine/memspyengineoutputsink.h>
|
|
27 |
|
|
28 |
// Classes referenced
|
|
29 |
class CMemSpyEngine;
|
|
30 |
class CMemSpyEngineFileHolder;
|
|
31 |
|
|
32 |
NONSHARABLE_CLASS( CMemSpyEngineOutputSinkFile ) : public CMemSpyEngineOutputSink
|
|
33 |
{
|
|
34 |
public:
|
|
35 |
static CMemSpyEngineOutputSinkFile* NewL( CMemSpyEngine& aEngine, const TDesC& aRootFolder );
|
|
36 |
~CMemSpyEngineOutputSinkFile();
|
|
37 |
|
|
38 |
public:
|
|
39 |
CMemSpyEngineOutputSinkFile( CMemSpyEngine& aEngine );
|
|
40 |
void ConstructL( const TDesC& aRootFolder );
|
|
41 |
|
|
42 |
private: // From CMemSpyEngineOutputSink
|
|
43 |
void ProcessSuspendedL( TProcessId aId );
|
|
44 |
void ProcessResumed( TProcessId aId );
|
|
45 |
TMemSpySinkType Type() const;
|
|
46 |
void DataStreamBeginL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension );
|
|
47 |
void DataStreamBeginL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite );
|
|
48 |
void DataStreamBeginL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseTimeStamp );
|
|
49 |
void DataStreamEndL();
|
62
|
50 |
void FlushL();
|
|
51 |
|
51
|
52 |
void DoOutputLineL( const TDesC& aLine );
|
|
53 |
void DoOutputRawL( const TDesC8& aData );
|
|
54 |
TBool IsPrefixAllowed( const TDesC& aPrefix );
|
|
55 |
|
|
56 |
private: // Internal
|
|
57 |
void IdentifyFileServerProcessIdL();
|
|
58 |
void ConstructDefaultLogFileL();
|
|
59 |
void DisableAllBuffersAfterFileServerResumedL();
|
|
60 |
CMemSpyEngineFileHolder& HeadLog() const;
|
|
61 |
|
|
62 |
private:
|
|
63 |
RFs iFsSession;
|
|
64 |
RPointerArray< CMemSpyEngineFileHolder > iLogs;
|
|
65 |
RPointerArray< CMemSpyEngineFileHolder > iLogsPendingDestruction;
|
|
66 |
|
|
67 |
TUint iFileServerProcessId;
|
|
68 |
TBool iFileServerSuspended;
|
|
69 |
|
|
70 |
HBufC* iRoot;
|
|
71 |
|
|
72 |
private:
|
|
73 |
friend class CMemSpyEngineFileHolder;
|
|
74 |
};
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
NONSHARABLE_CLASS( CMemSpyEngineFileHolder ) : public CBase
|
|
80 |
{
|
|
81 |
public:
|
|
82 |
static CMemSpyEngineFileHolder* NewLC( CMemSpyEngineOutputSinkFile& aParent );
|
|
83 |
static CMemSpyEngineFileHolder* NewL( CMemSpyEngineOutputSinkFile& aParent, CMemSpyEngineSinkMetaData* aMetaData );
|
|
84 |
static CMemSpyEngineFileHolder* NewLogToRAML( CMemSpyEngineOutputSinkFile& aParent, CMemSpyEngineSinkMetaData* aMetaData );
|
|
85 |
~CMemSpyEngineFileHolder();
|
|
86 |
|
|
87 |
private:
|
|
88 |
CMemSpyEngineFileHolder( CMemSpyEngineOutputSinkFile& aParent, CMemSpyEngineSinkMetaData* aMetaData = NULL );
|
|
89 |
void ConstructL();
|
|
90 |
void CommonConstructL();
|
|
91 |
|
|
92 |
public: // API
|
|
93 |
void WriteLineL( const TDesC& aData );
|
|
94 |
void WriteRawL( const TDesC8& aData );
|
|
95 |
void EnableBufferL();
|
|
96 |
void DisableBufferL();
|
|
97 |
const TDesC& FileName() const;
|
62
|
98 |
void FlushL();
|
51
|
99 |
//
|
|
100 |
inline TBool UsingBuffer() const { return iEntireFileBuffer != NULL; }
|
|
101 |
inline TBool IsMainLog() const { return iIsMainLog; }
|
|
102 |
|
|
103 |
private: // Internal
|
|
104 |
void OpenFileL();
|
|
105 |
void AddToWorkingBufferL( const TDesC8& aText );
|
|
106 |
void FlushWorkingBufferL();
|
|
107 |
void PrepareFileL( const TDriveNumber* aForceDrive = NULL );
|
|
108 |
HBufC* CleanContextInfoLC( const TDesC& aContext );
|
|
109 |
HBufC* GenerateFileNameLC( const TDriveNumber* aForceDrive = NULL );
|
|
110 |
RFs& FsSession();
|
|
111 |
|
|
112 |
private: // Data members
|
|
113 |
CMemSpyEngineOutputSinkFile& iParent;
|
|
114 |
CMemSpyEngineSinkMetaData* iMetaData;
|
|
115 |
RFile iFile;
|
|
116 |
HBufC* iFileName;
|
|
117 |
HBufC8* iLineBuffer;
|
|
118 |
TBool iIsMainLog;
|
|
119 |
CBufFlat* iEntireFileBuffer;
|
|
120 |
CBufFlat* iWorkingBuffer;
|
|
121 |
};
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
#endif
|