|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: UPnPBrowseCriteria implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "upnpbrowsecriteria.h" |
|
21 #include "upnpattribute.h" |
|
22 #include "upnpobject.h" |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CUpnpBrowseCriteria::ConstructL |
|
31 // Symbian 2nd phase constructor can leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 void CUpnpBrowseCriteria::ConstructL(const TDesC8& aFilter) |
|
35 { |
|
36 iFilter = aFilter.AllocL(); |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CUpnpBrowseCriteria::NewLC |
|
41 // Two-phased constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CUpnpBrowseCriteria* CUpnpBrowseCriteria::NewLC(const TDesC8& aFilter) |
|
45 { |
|
46 CUpnpBrowseCriteria* self = new( ELeave ) CUpnpBrowseCriteria; |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(aFilter); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CUpnpBrowseCriteria::NewLC |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CUpnpBrowseCriteria* CUpnpBrowseCriteria::NewL(const TDesC8& aFilter) |
|
58 { |
|
59 CUpnpBrowseCriteria* self = NewLC(aFilter); |
|
60 CleanupStack::Pop(self); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CUpnpBrowseCriteria::CUpnpBrowseCriteria |
|
66 // C++ default constructor can NOT contain any code, that |
|
67 // might leave. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CUpnpBrowseCriteria::CUpnpBrowseCriteria() |
|
71 { |
|
72 } |
|
73 |
|
74 // Destructor |
|
75 CUpnpBrowseCriteria::~CUpnpBrowseCriteria() |
|
76 { |
|
77 delete iFilter; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CUpnpBrowseCriteria::SetFilterL |
|
82 // Sets filter. |
|
83 // (other items were commented in a header). |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C void CUpnpBrowseCriteria::SetFilterL( const TDesC8& aFilter ) |
|
87 { |
|
88 HBufC8* tmp = aFilter.AllocL(); |
|
89 delete iFilter; |
|
90 iFilter = tmp; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CUpnpBrowseCriteria::GetFilter |
|
95 // Returns filter. |
|
96 // (other items were commented in a header). |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C const TDesC8& CUpnpBrowseCriteria::Filter() const |
|
100 { |
|
101 return *iFilter; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CUpnpBrowseCriteria::SetRequestCount |
|
106 // Sets request count. |
|
107 // (other items were commented in a header). |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C void CUpnpBrowseCriteria::SetRequestedCount( TInt aRequestedCount ) |
|
111 { |
|
112 iRequestedCount=aRequestedCount; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CUpnpBrowseCriteria::RequestedCount |
|
117 // Returns requested count |
|
118 // (other items were commented in a header). |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C TInt CUpnpBrowseCriteria::RequestedCount() const |
|
122 { |
|
123 return iRequestedCount; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CUpnpBrowseCriteria::SetStartingIndex |
|
128 // Sets starting index. |
|
129 // (other items were commented in a header). |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C void CUpnpBrowseCriteria::SetStartingIndex( TInt aStartingIndex) |
|
133 { |
|
134 iStartingIndex=aStartingIndex; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CUpnpBrowseCriteria::StartingIndex |
|
139 // Returns starting index |
|
140 // (other items were commented in a header). |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C TInt CUpnpBrowseCriteria::StartingIndex() const |
|
144 { |
|
145 return iStartingIndex; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CUpnpBrowseCriteria::CopyL |
|
150 // Copies the content from parameter CUpnpElement to this |
|
151 // (other items were commented in a header). |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 EXPORT_C void CUpnpBrowseCriteria::CopyL( const CUpnpBrowseCriteria& aBrowseCriteria ) |
|
155 { |
|
156 CBufFlat* buffer = CBufFlat::NewL( sizeof( aBrowseCriteria ) ); |
|
157 CleanupStack::PushL( buffer ); |
|
158 RBufWriteStream outStream; |
|
159 outStream.Open( *buffer ); |
|
160 CleanupClosePushL( outStream ); |
|
161 RBufReadStream inStream; |
|
162 inStream.Open( *buffer ); |
|
163 CleanupClosePushL( inStream ); |
|
164 aBrowseCriteria.ExternalizeL( outStream ); |
|
165 InternalizeL( inStream ); |
|
166 CleanupStack::PopAndDestroy( 3 ); // inStream && outStream && buffer |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CUpnpBrowseCriteria::ExternalizeL |
|
171 // C++ default constructor can NOT contain any code, that |
|
172 // might leave. |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 EXPORT_C void CUpnpBrowseCriteria::ExternalizeL( RWriteStream& aStream ) const |
|
176 { |
|
177 aStream << *iFilter; |
|
178 aStream.WriteInt32L(RequestedCount()); |
|
179 aStream.WriteInt32L(StartingIndex()); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CUpnpBrowseCriteria::InternalizeL |
|
184 // C++ default constructor can NOT contain any code, that |
|
185 // might leave. |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C void CUpnpBrowseCriteria::InternalizeL( RReadStream& aStream ) |
|
189 { |
|
190 |
|
191 delete iFilter; |
|
192 iFilter = NULL; |
|
193 iFilter = HBufC8::NewL( aStream,KMaxUpnpObjStringLen); |
|
194 |
|
195 iRequestedCount=aStream.ReadInt32L(); |
|
196 iStartingIndex=aStream.ReadInt32L(); |
|
197 } |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CUpnpBrowseCriteria::ToDes8L |
|
200 // (other items were commented in a header). |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 EXPORT_C HBufC8* CUpnpBrowseCriteria::ToDes8L() const |
|
204 { |
|
205 // serialize object |
|
206 CBufFlat* buf = CBufFlat::NewL(KDefBufferGranularity); |
|
207 CleanupStack::PushL(buf); |
|
208 RBufWriteStream stream(*buf); |
|
209 CleanupClosePushL(stream); |
|
210 |
|
211 stream << *this; |
|
212 |
|
213 // create heap descriptor |
|
214 HBufC8* hbuf = HBufC8::NewLC(buf->Size()); |
|
215 TPtr8 ptr(hbuf->Des()); |
|
216 buf->Read(0, ptr, buf->Size()); |
|
217 |
|
218 // clean up |
|
219 CleanupStack::Pop(hbuf); |
|
220 CleanupStack::PopAndDestroy(&stream); |
|
221 CleanupStack::PopAndDestroy(buf); |
|
222 |
|
223 return hbuf; |
|
224 } |
|
225 // End of File |