|
1 // Copyright (c) 2008-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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 @deprecated |
|
20 */ |
|
21 |
|
22 #ifndef SOCKETREADER_H_ |
|
23 #define SOCKETREADER_H_ |
|
24 #include <e32base.h> |
|
25 #include <es_sock.h> |
|
26 #include <in_sock.h> |
|
27 #include <securesocket.h> |
|
28 |
|
29 #include "observers.h" |
|
30 |
|
31 // Forwards |
|
32 class CSuplAsn1Decoder; |
|
33 |
|
34 /** Size of buffer used for reading SUPL messages from a socket |
|
35 */ |
|
36 const TInt KSuplMaxMessageLength = 8192; // Enough to keep all the assistance data |
|
37 |
|
38 class CSocketReader : public CActive |
|
39 { |
|
40 public: |
|
41 static CSocketReader* NewL(RSocket& aSocket, MSuplSocketObserver& aObserver, TUint aCallbackId); |
|
42 ~CSocketReader(); |
|
43 |
|
44 // CActive |
|
45 void RunL(); |
|
46 void DoCancel(); |
|
47 void RunError(); |
|
48 private: |
|
49 // Constructors |
|
50 CSocketReader(RSocket& aSocket, MSuplSocketObserver& aObserver, TUint aCallbackId); |
|
51 void ConstructL(); |
|
52 |
|
53 // Methods |
|
54 void SuplMessageLength(); |
|
55 void IssueRead(); |
|
56 void FireObservation(); |
|
57 private: |
|
58 // Socket to listen on |
|
59 RSocket& iSocket; |
|
60 |
|
61 // Observer for calling back when message received |
|
62 MSuplSocketObserver& iObserver; |
|
63 |
|
64 // Data buffer for message |
|
65 RBuf8 iBuffer; |
|
66 |
|
67 // Size of data read |
|
68 TSockXfrLength iBufferRead; |
|
69 |
|
70 // Is this the first fragment |
|
71 TBool iIsFirstFragment; |
|
72 |
|
73 // Total size of the message we are currently reading |
|
74 TUint iCurrentMessageSize; |
|
75 |
|
76 // Current read data |
|
77 TUint iReadSoFar; |
|
78 |
|
79 // Decoder |
|
80 CSuplAsn1Decoder* iDecoder; |
|
81 |
|
82 // Ptr into buffer |
|
83 TPtr8 iPtr; |
|
84 |
|
85 // Id for callbacks |
|
86 TUint iCallbackId; |
|
87 }; |
|
88 |
|
89 |
|
90 class CSecureSocketReader : public CActive |
|
91 { |
|
92 public: |
|
93 static CSecureSocketReader* NewL(CSecureSocket& aSocket, MSuplSocketObserver& aObserver, TUint aCallbackId); |
|
94 ~CSecureSocketReader(); |
|
95 |
|
96 // CActive |
|
97 void RunL(); |
|
98 void DoCancel(); |
|
99 void RunError(); |
|
100 private: |
|
101 // Constructors |
|
102 CSecureSocketReader(CSecureSocket& aSocket, MSuplSocketObserver& aObserver, TUint aCallbackId); |
|
103 void ConstructL(); |
|
104 |
|
105 // Methods |
|
106 void SuplMessageLength(); |
|
107 void IssueRead(); |
|
108 void FireObservation(); |
|
109 private: |
|
110 // Socket to listen on |
|
111 CSecureSocket& iSocket; |
|
112 |
|
113 // Observer for calling back when message received |
|
114 MSuplSocketObserver& iObserver; |
|
115 |
|
116 // Data buffer for message |
|
117 RBuf8 iBuffer; |
|
118 |
|
119 // Size of data read |
|
120 TSockXfrLength iBufferRead; |
|
121 |
|
122 // Is this the first fragment |
|
123 TBool iIsFirstFragment; |
|
124 |
|
125 // Total size of the message we are currently reading |
|
126 TUint iCurrentMessageSize; |
|
127 |
|
128 // Current read data |
|
129 TUint iReadSoFar; |
|
130 |
|
131 // Decoder |
|
132 CSuplAsn1Decoder* iDecoder; |
|
133 |
|
134 // Ptr into buffer |
|
135 TPtr8 iPtr; |
|
136 |
|
137 // Id for callbacks |
|
138 TUint iCallbackId; |
|
139 }; |
|
140 |
|
141 #endif /*SOCKETREADER_H_*/ |