105 { |
105 { |
106 return iFileName; |
106 return iFileName; |
107 } |
107 } |
108 |
108 |
109 // ----------------------------------------------------------------------------- |
109 // ----------------------------------------------------------------------------- |
110 // CMSRPMessage::SetFileSize |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C void CMSRPMessage::SetFileSize( const TInt aFileSize ) |
|
114 { |
|
115 iFileSize = aFileSize; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CMSRPMessage::GetFileSize |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C TInt CMSRPMessage::GetFileSize( ) |
|
123 { |
|
124 return iFileSize; |
|
125 } |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CMSRPMessage::InternalizeL |
110 // CMSRPMessage::InternalizeL |
128 // ----------------------------------------------------------------------------- |
111 // ----------------------------------------------------------------------------- |
129 // |
112 // |
130 EXPORT_C CMSRPMessage* CMSRPMessage::InternalizeL( RReadStream& aReadStream ) |
113 EXPORT_C CMSRPMessage* CMSRPMessage::InternalizeL( RReadStream& aReadStream ) |
131 { |
114 { |
203 { |
186 { |
204 TUint32 nameLength = aReadStream.ReadUint32L(); |
187 TUint32 nameLength = aReadStream.ReadUint32L(); |
205 aReadStream.ReadL( iFileName, nameLength ); |
188 aReadStream.ReadL( iFileName, nameLength ); |
206 break; |
189 break; |
207 } |
190 } |
208 case 12: //filesize |
191 |
209 { |
|
210 TUint32 val = aReadStream.ReadUint32L(); |
|
211 if( val > 0 ) |
|
212 { |
|
213 HBufC8* tempString = HBufC8::NewLC( val ); |
|
214 TPtr8 tempValue( tempString->Des() ); |
|
215 aReadStream.ReadL( tempValue, val ); |
|
216 iFileSize = TMSRPHeaderUtil::ConvertToNumber( tempString->Des() ); |
|
217 CleanupStack::PopAndDestroy( tempString ); |
|
218 } |
|
219 break; |
|
220 } |
|
221 case 13: //granularity |
|
222 { |
|
223 TUint32 val = aReadStream.ReadUint32L(); |
|
224 if( val > 0 ) |
|
225 { |
|
226 HBufC8* tempString = HBufC8::NewLC( val ); |
|
227 TPtr8 tempValue( tempString->Des() ); |
|
228 aReadStream.ReadL( tempValue, val ); |
|
229 iNotifyProgress = TMSRPHeaderUtil::ConvertToNumber( tempString->Des() ); |
|
230 CleanupStack::PopAndDestroy( tempString ); |
|
231 } |
|
232 break; |
|
233 } |
|
234 default: |
192 default: |
235 { |
193 { |
236 // nothing to do |
194 // nothing to do |
237 break; |
195 break; |
238 } |
196 } |
282 } |
240 } |
283 if( iSuccessReport ) |
241 if( iSuccessReport ) |
284 { |
242 { |
285 aWriteStream.WriteUint8L(7); // more headers in the stream flag |
243 aWriteStream.WriteUint8L(7); // more headers in the stream flag |
286 iSuccessReport->ExternalizeValueL( aWriteStream ); |
244 iSuccessReport->ExternalizeValueL( aWriteStream ); |
287 } |
|
288 if ( IsContent() ) |
|
289 { |
|
290 aWriteStream.WriteUint8L( 10 ); |
|
291 aWriteStream.WriteInt32L( iContentBuffer->Length() ); |
|
292 aWriteStream.WriteL( *iContentBuffer, iContentBuffer->Length() ); |
|
293 } |
245 } |
294 if ( IsFile() ) |
246 if ( IsFile() ) |
295 { |
247 { |
296 aWriteStream.WriteUint8L( 11 ); // 2 = file ID |
248 aWriteStream.WriteUint8L( 11 ); // 2 = file ID |
297 aWriteStream.WriteInt32L( iFileName.Length() ); |
249 aWriteStream.WriteInt32L( iFileName.Length() ); |
298 aWriteStream.WriteL( iFileName ); |
250 aWriteStream.WriteL( iFileName ); |
299 } |
251 } |
300 |
252 if ( IsContent() ) |
301 if( iFileSize > 0 ) |
253 { |
302 { |
254 // let's check if the buffer length is larger than KMaxLengthOfSmallMSRPMessage |
303 aWriteStream.WriteUint8L( 12 ); |
255 // if so, we must convert buffer to file |
304 TBuf8< 50 > val; |
256 if ( iContentBuffer->Length() > KMaxLengthOfSmallMSRPMessage ) |
305 val.AppendNum( iFileSize ); |
257 { |
306 aWriteStream.WriteInt32L( val.Length() ); |
258 ConvertBufferToFileL(); |
307 aWriteStream.WriteL( val ); |
259 aWriteStream.WriteUint8L( 11 ); |
308 } |
260 aWriteStream.WriteInt32L( iFileName.Length() ); |
309 if( iNotifyProgress > 0 ) |
261 aWriteStream.WriteL( iFileName ); |
310 { |
262 } |
311 aWriteStream.WriteUint8L( 13 ); |
263 else |
312 TBuf8< 50 > val; |
264 { |
313 val.AppendNum( iNotifyProgress ); |
265 aWriteStream.WriteUint8L( 10 ); |
314 aWriteStream.WriteInt32L( val.Length() ); |
266 aWriteStream.WriteInt32L( iContentBuffer->Length() ); |
315 aWriteStream.WriteL( val ); |
267 aWriteStream.WriteL( *iContentBuffer, iContentBuffer->Length() ); |
316 } |
268 } |
|
269 } |
|
270 |
317 aWriteStream.WriteUint8L(0); // no more headers in the stream flag |
271 aWriteStream.WriteUint8L(0); // no more headers in the stream flag |
318 } |
272 } |
319 |
273 |
320 // ----------------------------------------------------------------------------- |
274 // ----------------------------------------------------------------------------- |
321 // CMSRPMessage::IsMessage |
275 // CMSRPMessage::IsMessage |
342 } |
296 } |
343 return EFalse; |
297 return EFalse; |
344 |
298 |
345 } |
299 } |
346 |
300 |
347 |
301 // ----------------------------------------------------------------------------- |
348 EXPORT_C void CMSRPMessage::SetNotifyProgress(TBool aNotify) |
302 // CMSRPMessage::ConvertBufferToFileL |
349 { |
303 // ----------------------------------------------------------------------------- |
350 iNotifyProgress = aNotify; |
304 // |
351 } |
305 void CMSRPMessage::ConvertBufferToFileL( ) |
352 |
306 { |
353 EXPORT_C TBool CMSRPMessage::GetNotifyProgress() |
307 RFs fs; |
354 { |
308 User::LeaveIfError( fs.Connect() ); |
355 return iNotifyProgress; |
309 RFile tempFile; |
356 } |
310 TFileName tempFileName; |
|
311 |
|
312 // create temporary filename |
|
313 User::LeaveIfError( tempFile.Temp( |
|
314 fs, KDefaultTempFilePath, tempFileName, EFileShareExclusive | EFileWrite ) ); |
|
315 |
|
316 SetFileName( tempFileName ); |
|
317 |
|
318 tempFile.Write( 0, *iContentBuffer ); |
|
319 delete iContentBuffer; |
|
320 iContentBuffer = NULL; |
|
321 tempFile.Close(); |
|
322 fs.Close(); |
|
323 } |
|
324 |
357 // End of File |
325 // End of File |