|
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 ); |
|
36 ~CMemSpyEngineOutputSinkFile(); |
|
37 |
|
38 public: |
|
39 CMemSpyEngineOutputSinkFile( CMemSpyEngine& aEngine ); |
|
40 void ConstructL(); |
|
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(); |
|
50 void DoOutputLineL( const TDesC& aLine ); |
|
51 void DoOutputRawL( const TDesC8& aData ); |
|
52 TBool IsPrefixAllowed( const TDesC& aPrefix ); |
|
53 |
|
54 private: // Internal |
|
55 void IdentifyFileServerProcessIdL(); |
|
56 void ConstructDefaultLogFileL(); |
|
57 void DisableAllBuffersAfterFileServerResumedL(); |
|
58 CMemSpyEngineFileHolder& HeadLog() const; |
|
59 |
|
60 private: |
|
61 RFs iFsSession; |
|
62 RPointerArray< CMemSpyEngineFileHolder > iLogs; |
|
63 RPointerArray< CMemSpyEngineFileHolder > iLogsPendingDestruction; |
|
64 |
|
65 TUint iFileServerProcessId; |
|
66 TBool iFileServerSuspended; |
|
67 |
|
68 private: |
|
69 friend class CMemSpyEngineFileHolder; |
|
70 }; |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 NONSHARABLE_CLASS( CMemSpyEngineFileHolder ) : public CBase |
|
76 { |
|
77 public: |
|
78 static CMemSpyEngineFileHolder* NewLC( CMemSpyEngineOutputSinkFile& aParent ); |
|
79 static CMemSpyEngineFileHolder* NewL( CMemSpyEngineOutputSinkFile& aParent, CMemSpyEngineSinkMetaData* aMetaData ); |
|
80 static CMemSpyEngineFileHolder* NewLogToRAML( CMemSpyEngineOutputSinkFile& aParent, CMemSpyEngineSinkMetaData* aMetaData ); |
|
81 ~CMemSpyEngineFileHolder(); |
|
82 |
|
83 private: |
|
84 CMemSpyEngineFileHolder( CMemSpyEngineOutputSinkFile& aParent, CMemSpyEngineSinkMetaData* aMetaData = NULL ); |
|
85 void ConstructL(); |
|
86 void CommonConstructL(); |
|
87 |
|
88 public: // API |
|
89 void WriteLineL( const TDesC& aData ); |
|
90 void WriteRawL( const TDesC8& aData ); |
|
91 void EnableBufferL(); |
|
92 void DisableBufferL(); |
|
93 const TDesC& FileName() const; |
|
94 // |
|
95 inline TBool UsingBuffer() const { return iEntireFileBuffer != NULL; } |
|
96 inline TBool IsMainLog() const { return iIsMainLog; } |
|
97 |
|
98 private: // Internal |
|
99 void OpenFileL(); |
|
100 void AddToWorkingBufferL( const TDesC8& aText ); |
|
101 void FlushWorkingBufferL(); |
|
102 void PrepareFileL( const TDriveNumber* aForceDrive = NULL ); |
|
103 HBufC* CleanContextInfoLC( const TDesC& aContext ); |
|
104 HBufC* GenerateFileNameLC( const TDriveNumber* aForceDrive = NULL ); |
|
105 RFs& FsSession(); |
|
106 |
|
107 private: // Data members |
|
108 CMemSpyEngineOutputSinkFile& iParent; |
|
109 CMemSpyEngineSinkMetaData* iMetaData; |
|
110 RFile iFile; |
|
111 HBufC* iFileName; |
|
112 HBufC8* iLineBuffer; |
|
113 TBool iIsMainLog; |
|
114 CBufFlat* iEntireFileBuffer; |
|
115 CBufFlat* iWorkingBuffer; |
|
116 }; |
|
117 |
|
118 |
|
119 |
|
120 #endif |