sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <logwrap.h>
|
sl@0
|
17 |
#include <logwraplimits.h>
|
sl@0
|
18 |
#include "logcntdef.h"
|
sl@0
|
19 |
#include "s32strm.h"
|
sl@0
|
20 |
#include "LOGPANIC.H"
|
sl@0
|
21 |
|
sl@0
|
22 |
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
23 |
|
sl@0
|
24 |
/**
|
sl@0
|
25 |
This is the current version number of the event data, after the introduction of the "dual SIM support".
|
sl@0
|
26 |
New event properties in this version:
|
sl@0
|
27 |
- TInt iVersion;
|
sl@0
|
28 |
- TSimId iSimId;
|
sl@0
|
29 |
|
sl@0
|
30 |
The data versioning was introduced together with the "dual SIM support" changes where a new data member was
|
sl@0
|
31 |
added to the CLogEvent class.
|
sl@0
|
32 |
The idea is to keep InternalizeL()/ExternalizeL() functionality binary compatibly in case of the unlikely event
|
sl@0
|
33 |
CLogEvent data gets persisted to a file for example.
|
sl@0
|
34 |
|
sl@0
|
35 |
The old format of the externalized event data is:
|
sl@0
|
36 |
<id><type>.....<data length>[<optional: data>]
|
sl@0
|
37 |
|
sl@0
|
38 |
The new format of the externalized event data is:
|
sl@0
|
39 |
<id><type>.....<uint: data version><data length>[<optional: data>]<simId>
|
sl@0
|
40 |
|
sl@0
|
41 |
In case if CLogEvent::InternalizeL() reads from a stream with old event data, then:
|
sl@0
|
42 |
1) The data vesrion is read first as an integer.
|
sl@0
|
43 |
2) If the data version is negative then this is an event data with "dual SIM support",
|
sl@0
|
44 |
because the version number of that is positive integer above the KMaxTInt constant
|
sl@0
|
45 |
(interpreted as negative one if read as an integer from the stream)
|
sl@0
|
46 |
3) If the data version is positive then this is an event data without "dual SIM support".
|
sl@0
|
47 |
|
sl@0
|
48 |
@internalComponent
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
const TUint KLogEventDataVersion = 0x80000002U;
|
sl@0
|
51 |
|
sl@0
|
52 |
#endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
53 |
|
sl@0
|
54 |
EXPORT_C CLogEvent* CLogEvent::NewL()
|
sl@0
|
55 |
/** Creates a new log event detail object.
|
sl@0
|
56 |
|
sl@0
|
57 |
@return Pointer to the new log event detail object. */
|
sl@0
|
58 |
{
|
sl@0
|
59 |
CLogEvent* self = new(ELeave)CLogEvent;
|
sl@0
|
60 |
CleanupStack::PushL(self);
|
sl@0
|
61 |
self->ConstructL();
|
sl@0
|
62 |
CleanupStack::Pop(); // self
|
sl@0
|
63 |
return self;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
CLogEvent::CLogEvent() :
|
sl@0
|
67 |
iId(KLogNullId),
|
sl@0
|
68 |
iEventType(KNullUid),
|
sl@0
|
69 |
iDurationType(KLogNullDurationType),
|
sl@0
|
70 |
iDuration(KLogNullDuration),
|
sl@0
|
71 |
iContact(KLogNullContactId),
|
sl@0
|
72 |
iLink(KLogNullLink),
|
sl@0
|
73 |
iFlags(KLogNullFlags)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
void CLogEvent::ConstructL()
|
sl@0
|
78 |
{
|
sl@0
|
79 |
iDescription = HBufC::NewL(KLogMaxDescriptionLength);
|
sl@0
|
80 |
iRemoteParty = HBufC::NewL(KLogMaxRemotePartyLength);
|
sl@0
|
81 |
iDirection = HBufC::NewL(KLogMaxDirectionLength);
|
sl@0
|
82 |
iStatus = HBufC::NewL(KLogMaxStatusLength);
|
sl@0
|
83 |
iSubject = HBufC::NewL(KLogMaxSubjectLength);
|
sl@0
|
84 |
iNumber = HBufC::NewL(KLogMaxNumberLength);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
EXPORT_C CLogEvent::~CLogEvent()
|
sl@0
|
88 |
/** Frees all resources owned by the log event detail object. */
|
sl@0
|
89 |
{
|
sl@0
|
90 |
delete iDescription;
|
sl@0
|
91 |
delete iRemoteParty;
|
sl@0
|
92 |
delete iDirection;
|
sl@0
|
93 |
delete iStatus;
|
sl@0
|
94 |
delete iSubject;
|
sl@0
|
95 |
delete iNumber;
|
sl@0
|
96 |
delete iData;
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
EXPORT_C void CLogEvent::SetDataL(const TDesC8& aData)
|
sl@0
|
100 |
/** Sets event specific data.
|
sl@0
|
101 |
|
sl@0
|
102 |
The data can be used for any purpose. The data is copied into a heap descriptor
|
sl@0
|
103 |
allocated by this function; the amount of data is only limited by the available
|
sl@0
|
104 |
memory.
|
sl@0
|
105 |
|
sl@0
|
106 |
@param aData The event specific data. */
|
sl@0
|
107 |
{
|
sl@0
|
108 |
if (iData)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
if (iData->Des().MaxLength() < aData.Length())
|
sl@0
|
111 |
iData = iData->ReAllocL(aData.Length());
|
sl@0
|
112 |
}
|
sl@0
|
113 |
else
|
sl@0
|
114 |
{
|
sl@0
|
115 |
if (aData.Length() > 0)
|
sl@0
|
116 |
iData = HBufC8::NewL(aData.Length());
|
sl@0
|
117 |
else
|
sl@0
|
118 |
return;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
iData->Des().Copy(aData);
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
EXPORT_C void CLogEvent::SetDataL(RReadStream& aStream, TInt aLen)
|
sl@0
|
125 |
/** Sets event specific data from the specified stream.
|
sl@0
|
126 |
|
sl@0
|
127 |
The data can be used for any purpose. The data is copied into a heap descriptor
|
sl@0
|
128 |
allocated by this function; the amount of data is only limited by the available
|
sl@0
|
129 |
memory.
|
sl@0
|
130 |
|
sl@0
|
131 |
@param aStream The stream containing the event specific data.
|
sl@0
|
132 |
@param aLen The length of data to be read from the stream. */
|
sl@0
|
133 |
{
|
sl@0
|
134 |
HBufC8* buf = NULL;
|
sl@0
|
135 |
|
sl@0
|
136 |
if (aLen > 0)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
buf = HBufC8::NewLC(aLen);
|
sl@0
|
139 |
buf->Des().SetLength(aLen);
|
sl@0
|
140 |
|
sl@0
|
141 |
TPtr8 ptr(buf->Des());
|
sl@0
|
142 |
aStream.ReadL(ptr, aLen);
|
sl@0
|
143 |
|
sl@0
|
144 |
CleanupStack::Pop(); // buf
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
delete iData;
|
sl@0
|
148 |
iData = buf;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
|
sl@0
|
151 |
EXPORT_C void CLogEvent::CopyL(const CLogEvent& aEvent)
|
sl@0
|
152 |
/** Makes a copy of the specified log event.
|
sl@0
|
153 |
|
sl@0
|
154 |
@param aEvent The log event to be copied. */
|
sl@0
|
155 |
{
|
sl@0
|
156 |
// Set data first as this is the only function that can leave
|
sl@0
|
157 |
// If this function fails nothing will be changed
|
sl@0
|
158 |
SetDataL(aEvent.Data());
|
sl@0
|
159 |
|
sl@0
|
160 |
SetId(aEvent.Id());
|
sl@0
|
161 |
SetEventType(aEvent.EventType());
|
sl@0
|
162 |
SetTime(aEvent.Time());
|
sl@0
|
163 |
SetDurationType(aEvent.DurationType());
|
sl@0
|
164 |
SetDuration(aEvent.Duration());
|
sl@0
|
165 |
SetContact(aEvent.Contact());
|
sl@0
|
166 |
SetLink(aEvent.Link());
|
sl@0
|
167 |
SetDescription(aEvent.Description());
|
sl@0
|
168 |
SetRemoteParty(aEvent.RemoteParty());
|
sl@0
|
169 |
SetDirection(aEvent.Direction());
|
sl@0
|
170 |
SetStatus(aEvent.Status());
|
sl@0
|
171 |
SetSubject(aEvent.Subject());
|
sl@0
|
172 |
SetNumber(aEvent.Number());
|
sl@0
|
173 |
|
sl@0
|
174 |
ClearFlags(KLogFlagsMask);
|
sl@0
|
175 |
SetFlags(aEvent.Flags());
|
sl@0
|
176 |
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
177 |
SetSimId(aEvent.SimId());
|
sl@0
|
178 |
#endif
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
EXPORT_C void CLogEvent::InternalizeL(RReadStream& aStream)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
iId = (TLogId) aStream.ReadInt32L();
|
sl@0
|
184 |
iEventType.iUid = aStream.ReadInt32L();
|
sl@0
|
185 |
|
sl@0
|
186 |
TInt64 time;
|
sl@0
|
187 |
aStream >> time;
|
sl@0
|
188 |
iTime = time;
|
sl@0
|
189 |
|
sl@0
|
190 |
iDurationType = (TLogDurationType) aStream.ReadInt8L();
|
sl@0
|
191 |
iDuration = (TLogDuration) aStream.ReadUint32L();
|
sl@0
|
192 |
iContact = (TLogContactItemId ) aStream.ReadInt32L();
|
sl@0
|
193 |
iLink = (TLogLink) aStream.ReadUint32L();
|
sl@0
|
194 |
iFlags = (TLogFlags) aStream.ReadUint8L();
|
sl@0
|
195 |
|
sl@0
|
196 |
InternalizeBufL(aStream, iDescription);
|
sl@0
|
197 |
InternalizeBufL(aStream, iRemoteParty);
|
sl@0
|
198 |
InternalizeBufL(aStream, iDirection);
|
sl@0
|
199 |
InternalizeBufL(aStream, iStatus);
|
sl@0
|
200 |
InternalizeBufL(aStream, iSubject);
|
sl@0
|
201 |
InternalizeBufL(aStream, iNumber);
|
sl@0
|
202 |
|
sl@0
|
203 |
TInt dataLen = aStream.ReadInt32L();
|
sl@0
|
204 |
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
205 |
TUint dataVersion = 0;
|
sl@0
|
206 |
if(dataLen < 0)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
//This is CLogEvent data version with dual SIM support.
|
sl@0
|
209 |
//The next property is the data length.
|
sl@0
|
210 |
dataVersion = (TUint)dataLen;
|
sl@0
|
211 |
dataLen = aStream.ReadInt32L();
|
sl@0
|
212 |
}
|
sl@0
|
213 |
#endif
|
sl@0
|
214 |
HBufC8* temp = NULL;
|
sl@0
|
215 |
if(dataLen != 0)
|
sl@0
|
216 |
{
|
sl@0
|
217 |
temp = HBufC8::NewL(aStream, dataLen);
|
sl@0
|
218 |
}
|
sl@0
|
219 |
delete iData;
|
sl@0
|
220 |
iData = temp;
|
sl@0
|
221 |
|
sl@0
|
222 |
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
223 |
if(dataVersion >= KLogEventDataVersion)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
aStream >> iSimId;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
#endif
|
sl@0
|
228 |
}
|
sl@0
|
229 |
|
sl@0
|
230 |
void CLogEvent::InternalizeBufL(RReadStream& aStream, HBufC*& aDes)
|
sl@0
|
231 |
{
|
sl@0
|
232 |
TPtr ptr(aDes->Des());
|
sl@0
|
233 |
HBufC* temp = HBufC::NewL(aStream, ptr.MaxLength());
|
sl@0
|
234 |
ptr.Copy(*temp);
|
sl@0
|
235 |
delete temp;
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
EXPORT_C void CLogEvent::ExternalizeL(RWriteStream& aStream) const
|
sl@0
|
239 |
{
|
sl@0
|
240 |
aStream.WriteInt32L(iId);
|
sl@0
|
241 |
aStream.WriteInt32L(iEventType.iUid);
|
sl@0
|
242 |
aStream << iTime.Int64();
|
sl@0
|
243 |
aStream.WriteInt8L(iDurationType);
|
sl@0
|
244 |
aStream.WriteUint32L(iDuration);
|
sl@0
|
245 |
aStream.WriteInt32L(iContact);
|
sl@0
|
246 |
aStream.WriteUint32L(iLink);
|
sl@0
|
247 |
aStream.WriteInt8L(iFlags);
|
sl@0
|
248 |
aStream << *iDescription;
|
sl@0
|
249 |
aStream << *iRemoteParty;
|
sl@0
|
250 |
aStream << *iDirection;
|
sl@0
|
251 |
aStream << *iStatus;
|
sl@0
|
252 |
aStream << *iSubject;
|
sl@0
|
253 |
aStream << *iNumber;
|
sl@0
|
254 |
|
sl@0
|
255 |
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
256 |
aStream.WriteUint32L(KLogEventDataVersion);
|
sl@0
|
257 |
#endif
|
sl@0
|
258 |
|
sl@0
|
259 |
TInt dataLength = 0;
|
sl@0
|
260 |
if(iData)
|
sl@0
|
261 |
{
|
sl@0
|
262 |
dataLength = iData->Length();
|
sl@0
|
263 |
}
|
sl@0
|
264 |
aStream.WriteInt32L(dataLength);
|
sl@0
|
265 |
if (iData && dataLength)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
aStream << *iData;
|
sl@0
|
268 |
}
|
sl@0
|
269 |
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
270 |
aStream << iSimId;
|
sl@0
|
271 |
#endif
|
sl@0
|
272 |
}
|
sl@0
|
273 |
|
sl@0
|
274 |
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
275 |
|
sl@0
|
276 |
/**
|
sl@0
|
277 |
Sets the short Id of the SIM card being used.
|
sl@0
|
278 |
|
sl@0
|
279 |
@param aSimId SIM card short Id;
|
sl@0
|
280 |
*/
|
sl@0
|
281 |
EXPORT_C void CLogEvent::SetSimId(TSimId aSimId)
|
sl@0
|
282 |
{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
|
sl@0
|
283 |
iSimId = aSimId;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
/**
|
sl@0
|
287 |
Returns the short Id of the SIM card that was used.
|
sl@0
|
288 |
|
sl@0
|
289 |
@return SIM card short Id;
|
sl@0
|
290 |
*/
|
sl@0
|
291 |
EXPORT_C TSimId CLogEvent::SimId() const
|
sl@0
|
292 |
{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is defined
|
sl@0
|
293 |
return iSimId;
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
#else//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|
sl@0
|
297 |
|
sl@0
|
298 |
#pragma BullseyeCoverage off
|
sl@0
|
299 |
|
sl@0
|
300 |
/**
|
sl@0
|
301 |
Not supported.
|
sl@0
|
302 |
*/
|
sl@0
|
303 |
EXPORT_C void CLogEvent::SetSimId(TSimId)
|
sl@0
|
304 |
{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
|
sl@0
|
305 |
__ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
|
sl@0
|
306 |
}
|
sl@0
|
307 |
|
sl@0
|
308 |
/**
|
sl@0
|
309 |
Not supported.
|
sl@0
|
310 |
*/
|
sl@0
|
311 |
EXPORT_C TSimId CLogEvent::SimId() const
|
sl@0
|
312 |
{//Compiled when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM is not defined
|
sl@0
|
313 |
__ASSERT_ALWAYS(0, ::Panic(ELogDualSimNotSupported));
|
sl@0
|
314 |
return 0;
|
sl@0
|
315 |
}
|
sl@0
|
316 |
|
sl@0
|
317 |
#pragma BullseyeCoverage on
|
sl@0
|
318 |
|
sl@0
|
319 |
#endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
|