Update contrib.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\debug\crashMonitor\src\scmprocessdata.cpp
15 // Core dump server - Process Data for System Crash
24 #include <scmdatatypes.h>
29 * TProcessData implementation
30 * @internal technology
34 * TProcessData constructor
36 TProcessData::TProcessData()
49 * Writes this classes data to the specified byte stream
50 * @param aWriter byte stream to use
51 * @return One of the OS wide codes
53 TInt TProcessData::Serialize(TByteStreamWriter& aWriter)
55 TInt startPos = aWriter.CurrentPosition();
58 aWriter.WriteInt(iId); // 4
60 if(iId != ESCMProcessData)
62 CLTRACE("TProcessData::Serialize Corrupt ID");
66 aWriter.WriteShort((TUint16) iVersion); // 2
68 if(iVersion == EProcData1)
70 // write data v1 format
71 aWriter.WriteInt(iPriority); // 4
72 aWriter.WriteInt64(iPid); // 8
75 aWriter.WriteInt(iName.Length()); // 4
76 for(TInt cnt = 0; cnt < iName.Length(); cnt++)
78 aWriter.WriteByte(iName[cnt]);
90 CLTRACE("TProcessData::Serialize Unsupported version");
94 TInt endPos = aWriter.CurrentPosition();
95 if( endPos - startPos != GetSize())
97 // error between actual size & real size in data
98 CLTRACE2("TProcessData::Serialize serialization size error. Wrote [%d] but expected [%d]", endPos - startPos, GetSize());
105 * Reads the classes data from the specified byte stream
106 * @param aReader Byte stream to use
107 * @return One of the OS wide codes
109 TInt TProcessData::Deserialize(TByteStreamReader& aReader)
111 TInt startPos = aReader.CurrentPosition();
113 iId = (SCMStructId)aReader.ReadInt(); // 4
114 if(iId != ESCMProcessData)
116 CLTRACE("TProcessData::Deserialize failed - Read corrupt ID");
120 iVersion = (TProcessDataVersion)aReader.ReadShort(); // 2
122 if(iVersion == EProcData1)
124 // read data v1 format
125 iPriority = aReader.ReadInt(); // 4
126 iPid = aReader.ReadInt64(); // 8
128 iNamesize = aReader.ReadInt(); // 4
130 if(iName.Ptr() && iName.MaxLength() >= (TInt)iNamesize)
134 for(TUint cnt = 0; cnt < iNamesize; cnt++)
136 iName.Append(aReader.ReadByte()); //iCategorySize bytes
144 iId = ESCMLast; //unrecognised header
145 CLTRACE("TProcessData::Deserialize Unsupported version");
149 TInt endPos = aReader.CurrentPosition();
150 if( endPos - startPos != GetSize())
152 iId = ESCMLast; //unrecognised header
154 // error between actual size & real size in data
155 CLTRACE("TProcessData::Deserialize serialization size error");
162 * Returns the externalised size of this class
165 TInt TProcessData::GetSize() const
167 if(iVersion == EProcData1)
169 return 22 + iName.Length();
173 CLTRACE("TProcessData::GetSize Unsupported version");
174 return KErrNotSupported;