|
1 /* |
|
2 * Copyright (c) 2008 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: This is the implementation of application class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "hiddescriptor.h" |
|
20 |
|
21 CHidDescriptor* CHidDescriptor::NewL() |
|
22 { |
|
23 CHidDescriptor* self = NewLC(); |
|
24 CleanupStack::Pop(self); |
|
25 return self; |
|
26 } |
|
27 |
|
28 CHidDescriptor* CHidDescriptor::NewLC() |
|
29 { |
|
30 CHidDescriptor* self = new (ELeave) CHidDescriptor(); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CHidDescriptor* CHidDescriptor::NewL(RReadStream& aStream) |
|
37 { |
|
38 CHidDescriptor* self = NewLC(aStream); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CHidDescriptor* CHidDescriptor::NewLC(RReadStream& aStream) |
|
44 { |
|
45 CHidDescriptor* self = new (ELeave) CHidDescriptor(); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(aStream); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CHidDescriptor::CHidDescriptor() |
|
52 { |
|
53 } |
|
54 |
|
55 CHidDescriptor::~CHidDescriptor() |
|
56 { |
|
57 delete iRawData; |
|
58 } |
|
59 |
|
60 void CHidDescriptor::ConstructL() |
|
61 { |
|
62 } |
|
63 |
|
64 void CHidDescriptor::ConstructL(RReadStream& aStream) |
|
65 { |
|
66 // First read in the type |
|
67 iType = static_cast<CHidDescriptor::TDescType> (aStream.ReadInt32L()); |
|
68 |
|
69 // The TInt size was written out using WriteInt32L |
|
70 // Read in the buffer size |
|
71 TInt size = aStream.ReadInt32L(); |
|
72 |
|
73 if (size > 0) |
|
74 { |
|
75 // Read in any data |
|
76 iRawData = HBufC8::NewL(aStream, size); |
|
77 } |
|
78 } |
|
79 |
|
80 TInt CHidDescriptor::DiskSize() const |
|
81 { |
|
82 // Always using 10 bytes as an estimate for Series 60 Descriptor headers |
|
83 |
|
84 // We write out the type which is an int |
|
85 TInt size = 4; |
|
86 |
|
87 // If there is raw data we will write out the descriptor |
|
88 if (iRawData && iRawData->Length() > 0) |
|
89 { |
|
90 // An estimate of the header requirements. |
|
91 size += 10; |
|
92 size += iRawData->Length(); |
|
93 } |
|
94 |
|
95 return size; |
|
96 } |
|
97 |
|
98 void CHidDescriptor::ExternalizeL(RWriteStream& aStream) const |
|
99 { |
|
100 // NOTE!! When changing this function, also check DiskSize |
|
101 |
|
102 // First write out the type |
|
103 aStream.WriteInt32L(iType); |
|
104 |
|
105 if (iRawData && iRawData->Length() > 0) |
|
106 { |
|
107 // Write out the buffer length |
|
108 aStream.WriteInt32L(iRawData->Length()); |
|
109 // Write out the buffer |
|
110 aStream << *iRawData; |
|
111 } |
|
112 else |
|
113 { |
|
114 // No buffer so just put 0 |
|
115 aStream.WriteInt32L(0); |
|
116 } |
|
117 } |