|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Capsulating Media servers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <s32mem.h> |
|
26 |
|
27 #include "cmsearchresponsehash.h" |
|
28 #include "msdebug.h" |
|
29 |
|
30 |
|
31 // ======== LOCAL FUNCTIONS ======== |
|
32 // --------------------------------------------------------------------------- |
|
33 // NewL |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C CCmSearchResponseHash* CCmSearchResponseHash::NewL( TInt aStartIndex, |
|
37 TInt aItemCount, |
|
38 const TDesC8& aHash ) |
|
39 { |
|
40 CCmSearchResponseHash* self = new ( ELeave ) CCmSearchResponseHash( ); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL( aStartIndex, aItemCount, aHash ); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // NewL |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CCmSearchResponseHash* CCmSearchResponseHash::NewL() |
|
53 { |
|
54 CCmSearchResponseHash* self = new ( ELeave ) CCmSearchResponseHash(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // Constructor |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CCmSearchResponseHash::CCmSearchResponseHash() |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CCmSearchResponseHash::~CCmSearchResponseHash() |
|
72 { |
|
73 delete iHash; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // ConstructL |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CCmSearchResponseHash::ConstructL( TInt aStartIndex, |
|
81 TInt aItemCount, |
|
82 const TDesC8& aHash ) |
|
83 { |
|
84 SetStartIndex( aStartIndex ); |
|
85 SetItemCount( aItemCount ); |
|
86 SetHashL( aHash ); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // SetHashL |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 EXPORT_C void CCmSearchResponseHash::SetHashL( const TDesC8& aHash ) |
|
94 { |
|
95 delete iHash; |
|
96 iHash = NULL; |
|
97 iHash = aHash.AllocL(); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // Hash |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 EXPORT_C const TDesC8& CCmSearchResponseHash::Hash() const |
|
105 { |
|
106 if ( iHash ) |
|
107 { |
|
108 return *iHash; |
|
109 } |
|
110 else |
|
111 { |
|
112 return KNullDesC8(); |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // SetStartIndex |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 EXPORT_C void CCmSearchResponseHash::SetStartIndex( TInt aStartIndex ) |
|
121 { |
|
122 iStartIndex = aStartIndex; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // StartIndex |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C TInt CCmSearchResponseHash::StartIndex() const |
|
130 { |
|
131 return iStartIndex; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // SetItemCount |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C void CCmSearchResponseHash::SetItemCount( TInt aItemCount ) |
|
139 { |
|
140 iItemCount = aItemCount; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // ItemCount |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C TInt CCmSearchResponseHash::ItemCount() const |
|
148 { |
|
149 return iItemCount; |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // ExternalizeL |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CCmSearchResponseHash::ExternalizeL( RWriteStream& aStream ) const |
|
158 { |
|
159 aStream.WriteInt32L( Hash().Length() ); |
|
160 aStream << Hash(); |
|
161 aStream.WriteInt32L( StartIndex() ); |
|
162 aStream.WriteInt32L( ItemCount() ); |
|
163 } |
|
164 |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // InternalizeL |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CCmSearchResponseHash::InternalizeL( RReadStream& aStream ) |
|
171 { |
|
172 delete iHash; iHash = NULL; |
|
173 TInt bufLength = aStream.ReadInt32L(); |
|
174 iHash = HBufC8::NewL( aStream, bufLength ); |
|
175 |
|
176 iStartIndex = aStream.ReadInt32L(); |
|
177 iItemCount = aStream.ReadInt32L(); |
|
178 } |
|
179 |
|
180 // End of file |