|
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: CHWRMHapticsRespData class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32strm.h> // RReadStream,RWriteStream |
|
20 #include <hwrmhapticsrespdata.h> |
|
21 |
|
22 const TInt32 KHWRMHapticsRespProtocolVersion = 1; |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // NewLC() - Symbian constructor, leaves pointer to CleanupStack |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C CHWRMHapticsRespData* CHWRMHapticsRespData::NewLC( TInt aErrorCode, |
|
31 const TDesC8& aData ) |
|
32 { |
|
33 CHWRMHapticsRespData* self = new ( ELeave ) CHWRMHapticsRespData(); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL( aErrorCode, aData ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Destructor |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CHWRMHapticsRespData::~CHWRMHapticsRespData() |
|
44 { |
|
45 delete iData; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // ExternalizeL() |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C void CHWRMHapticsRespData::ExternalizeL( RWriteStream& aStream ) const |
|
53 { |
|
54 aStream.WriteInt32L( KHWRMHapticsRespProtocolVersion ); |
|
55 aStream.WriteInt32L( iErrorCode ); |
|
56 aStream.WriteInt32L( iData->Length() ); |
|
57 aStream << *iData; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // InternalizeL() |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C void CHWRMHapticsRespData::InternalizeL( RReadStream& aStream ) |
|
65 { |
|
66 TInt32 intToken; // 32 bit buffer |
|
67 |
|
68 aStream >> intToken; // read protocol version |
|
69 |
|
70 if( intToken != KHWRMHapticsRespProtocolVersion ) |
|
71 { |
|
72 User::Leave( KErrNotSupported ); |
|
73 } |
|
74 |
|
75 // Delete the current values |
|
76 delete iData; |
|
77 iData = NULL; |
|
78 |
|
79 aStream >> intToken; // read errorCode |
|
80 iErrorCode = intToken; |
|
81 |
|
82 aStream >> intToken; // read iData length |
|
83 |
|
84 iData = HBufC8::NewL( aStream, intToken ); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // ErrorCode() |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C TInt CHWRMHapticsRespData::ErrorCode() |
|
92 { |
|
93 return iErrorCode; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Data() |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C const TDesC8& CHWRMHapticsRespData::Data() |
|
101 { |
|
102 return *iData; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // C++ default constructor |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 CHWRMHapticsRespData::CHWRMHapticsRespData() |
|
110 { |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // ConstructL() |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void CHWRMHapticsRespData::ConstructL( TInt aErrorCode, const TDesC8& aData ) |
|
118 { |
|
119 iErrorCode = aErrorCode; |
|
120 |
|
121 iData = aData.AllocL(); |
|
122 } |
|
123 |
|
124 |