|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32base.h> |
|
17 #include <s32buf.h> |
|
18 #include "urilistreadstream.h" |
|
19 #include "ineturilistsession.h" |
|
20 #include "ineturilistserver.h" |
|
21 |
|
22 |
|
23 CUriListReadStream* CUriListReadStream::NewL ( RInetUriListSession& aSession, TInt aHandle ) |
|
24 { |
|
25 CUriListReadStream* self = new (ELeave)CUriListReadStream (aSession, aHandle); |
|
26 CleanupStack::PushL ( self ); |
|
27 self->ConstructL (); |
|
28 CleanupStack::Pop (); |
|
29 return self; |
|
30 } |
|
31 |
|
32 CUriListReadStream::CUriListReadStream ( RInetUriListSession& aSession, TInt aHandle ) |
|
33 : iListSession ( aSession ), |
|
34 iIpcBuffer ( NULL ), |
|
35 iHandle ( aHandle ) |
|
36 { |
|
37 |
|
38 } |
|
39 |
|
40 |
|
41 void CUriListReadStream::ConstructL () |
|
42 { |
|
43 iIpcBuffer = CBufFlat::NewL ( KIpcDataSize ); |
|
44 iIpcBuffer->ExpandL ( 0, KIpcDataSize ); |
|
45 iReadStream.Open ( *iIpcBuffer ); // Open the stream |
|
46 } |
|
47 |
|
48 /** |
|
49 Destructor. |
|
50 |
|
51 Closes the stream setup in the server |
|
52 */ |
|
53 CUriListReadStream::~CUriListReadStream () |
|
54 { |
|
55 // Delete the buffer |
|
56 iReadStream.Close (); |
|
57 delete iIpcBuffer; |
|
58 iIpcBuffer = NULL; |
|
59 iListSession.CloseSrvStream (iHandle); |
|
60 |
|
61 } |
|
62 |
|
63 /** |
|
64 Reads the URI list from the server. The server stream handle is already setup. |
|
65 */ |
|
66 TInt CUriListReadStream::ReadUriListL () |
|
67 { |
|
68 // Reset the stream |
|
69 ResetL (); |
|
70 TPtr8 ptr ( iIpcBuffer->Ptr(0) ); |
|
71 TInt result = iListSession.ReadQueryResults ( iHandle, ptr ); |
|
72 User::LeaveIfError ( result ); |
|
73 return result; |
|
74 } |
|
75 |
|
76 /** |
|
77 Resets the position to the beginning of the stream |
|
78 */ |
|
79 void CUriListReadStream::ResetL () |
|
80 { |
|
81 MStreamBuf* srcStream = iReadStream.Source (); |
|
82 srcStream->SeekL ( MStreamBuf::ERead, EStreamBeginning, 0 ); |
|
83 } |
|
84 |