|
1 /* |
|
2 * Copyright (c) 2008-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: Logging to chunk wrapper for MC Photos |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef T_GLXLOGCHUNK_H |
|
21 #define T_GLXLOGCHUNK_H |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 /** |
|
28 * RGlxLogUtility. |
|
29 * Encapsulates the use of RChunk for log writing |
|
30 */ |
|
31 NONSHARABLE_CLASS( RGlxLogUtility ) |
|
32 { |
|
33 public: |
|
34 /** |
|
35 * Opens the log chunk with given name |
|
36 * @param aName, the full name of the chunk |
|
37 * @param aReadOnly, whether to open in readonly or read-write |
|
38 */ |
|
39 TInt Open( const TDesC& aName, TBool aReadOnly ); |
|
40 |
|
41 /** |
|
42 * Creates the log chunk with given name |
|
43 * @param aName, the full name of the chunk |
|
44 */ |
|
45 void CreateL( const TDesC& aName ); |
|
46 |
|
47 /** |
|
48 * Closes the opened chunk. This needs to be called |
|
49 * before an object of this class goes out of scope |
|
50 */ |
|
51 void Close(); |
|
52 |
|
53 /** |
|
54 * @return the size of the log chunk |
|
55 */ |
|
56 TInt ChunkSize(); |
|
57 |
|
58 /** |
|
59 * @return the chunk unique Id (set by client) |
|
60 */ |
|
61 TObjectId Id(); |
|
62 |
|
63 /** |
|
64 * Sets the unique id for the log chunk |
|
65 * @param aId the id to set for the chunk |
|
66 */ |
|
67 void SetId( TObjectId aId ); |
|
68 |
|
69 /** |
|
70 * @return Current chunk write address |
|
71 */ |
|
72 TUint8* CurrentAddress(); |
|
73 |
|
74 /** |
|
75 * Sets the current write address |
|
76 * @param New write address |
|
77 */ |
|
78 void SetCurrentAddress( TUint8* aValue ); |
|
79 |
|
80 /** |
|
81 * @return Last address written to file |
|
82 */ |
|
83 TUint8* LastLoggedAddress(); |
|
84 |
|
85 /** |
|
86 * Sets the last logged address |
|
87 * @param New last logged address |
|
88 */ |
|
89 void SetLastLoggedAddress( TUint8* aValue ); |
|
90 |
|
91 /** |
|
92 * @return The topmost writable address of the chunk |
|
93 */ |
|
94 TUint8* BaseAddress(); |
|
95 |
|
96 /** |
|
97 * @return The bottom most writable address of the chunk |
|
98 */ |
|
99 TUint8* LastAddress(); |
|
100 |
|
101 private: |
|
102 |
|
103 /// Own: chunk to write to |
|
104 RChunk iChunk; |
|
105 }; |
|
106 |
|
107 /** |
|
108 * RGlxLogClient. |
|
109 * Client API for log writing to chunk |
|
110 */ |
|
111 NONSHARABLE_CLASS( RGlxLogClient ) |
|
112 { |
|
113 public: |
|
114 |
|
115 /** |
|
116 * Opens the log chunk with the given unique id |
|
117 * @param aId unique id for the log writing thread |
|
118 */ |
|
119 IMPORT_C TInt Open( TObjectId aId ); |
|
120 |
|
121 /** |
|
122 * Closes the log handle, needs to be called before an |
|
123 * object of this class goes out of scope |
|
124 */ |
|
125 IMPORT_C void Close(); |
|
126 |
|
127 /** |
|
128 * Writes a descriptor to the log |
|
129 * @param aLogEntry the log entry to write |
|
130 */ |
|
131 IMPORT_C void Write( const TDesC8& aLogEntry ); |
|
132 |
|
133 private: |
|
134 |
|
135 /// Own: log utility |
|
136 RGlxLogUtility iLogUtility; |
|
137 |
|
138 }; |
|
139 |
|
140 /** |
|
141 * RGlxLogManager. |
|
142 * Management API for log creation and committing to file |
|
143 */ |
|
144 NONSHARABLE_CLASS( RGlxLogManager ) |
|
145 { |
|
146 public: |
|
147 |
|
148 /** |
|
149 * Creates the log chunks |
|
150 */ |
|
151 IMPORT_C void CreateL(); |
|
152 |
|
153 /** |
|
154 * Releases the log chunks |
|
155 */ |
|
156 IMPORT_C void Release(); |
|
157 |
|
158 /** |
|
159 * Writes the log to a file |
|
160 * One file is created per chunk. |
|
161 * @param aFolder the directory where to store the logs |
|
162 */ |
|
163 IMPORT_C void CommitToFileL( const TDesC& aFolder ); |
|
164 |
|
165 private: |
|
166 |
|
167 // helper method to write all descriptors of a chunk to a |
|
168 // file |
|
169 void CommitToFileL( RGlxLogUtility& aUtility, RFile& aFile ); |
|
170 |
|
171 private: |
|
172 |
|
173 /// Own: log utility |
|
174 RGlxLogUtility iLogUtility1; |
|
175 /// Own: log utility |
|
176 RGlxLogUtility iLogUtility2; |
|
177 /// Own: file server handle |
|
178 RFs iFs; |
|
179 |
|
180 }; |
|
181 |
|
182 #endif // T_GLXLOGCHUNK_H |
|
183 |
|
184 |