|
1 /* |
|
2 * Copyright (c) 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: Definitions needed for common stream functionality |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CDUNSTREAM_H |
|
20 #define C_CDUNSTREAM_H |
|
21 |
|
22 #include "DunTransporter.h" |
|
23 |
|
24 /** |
|
25 * Class for common stream functionality |
|
26 * |
|
27 * @lib dunutils.lib |
|
28 * @since S60 v3.2 |
|
29 */ |
|
30 NONSHARABLE_CLASS( CDunStream ) : public CActive |
|
31 { |
|
32 |
|
33 public: |
|
34 |
|
35 /** |
|
36 * Resets data to initial values |
|
37 * |
|
38 * @since S60 3.2 |
|
39 * @return None |
|
40 */ |
|
41 void ResetData(); |
|
42 |
|
43 /** |
|
44 * Adds error code to consider as "no error" to either endpoint |
|
45 * |
|
46 * @since S60 3.2 |
|
47 * @param aError Error code to add |
|
48 * @param aOperationType Type of operation for which to add error |
|
49 * (read or write) |
|
50 * @return Symbian error code on error, KErrNone otherwise |
|
51 */ |
|
52 TInt AddSkippedError( TInt aError, TDunOperationType aOperationType ); |
|
53 |
|
54 /** |
|
55 * Adds callback for line status change controlling |
|
56 * The callback will be called when serious read error is detected |
|
57 * |
|
58 * @since S60 3.2 |
|
59 * @param aCallback Callback to call when read error occurs |
|
60 * @param aOperationType Type of operation for which to add error |
|
61 * (read or write) |
|
62 * @return Symbian error code on error, KErrNone otherwise |
|
63 */ |
|
64 TInt AddConnMonCallback( MDunConnMon* aCallback, |
|
65 TDunOperationType aOperationType ); |
|
66 |
|
67 /** |
|
68 * Sets buffering for this stream |
|
69 * |
|
70 * @since S60 3.2 |
|
71 * @param aBufferPtr Pointer to the buffer |
|
72 * @return KErrGeneral if buffer pointer null, KErrNone otherwise |
|
73 */ |
|
74 TInt SetBuffering( TPtr8* aBufferPtr ); |
|
75 |
|
76 /** |
|
77 * Sets media to be used for this endpoint |
|
78 * |
|
79 * @since S60 3.2 |
|
80 * @param aComm RComm pointer to use as the endpoint |
|
81 * @param aMediaContext Media context to use for this endpoint, either |
|
82 * local or network |
|
83 * @return Symbian error code on error, KErrNone otherwise |
|
84 */ |
|
85 TInt SetMedia( RComm* aComm, TDunMediaContext aMediaContext ); |
|
86 |
|
87 /** |
|
88 * Sets media to be used for this endpoint |
|
89 * |
|
90 * @since S60 3.2 |
|
91 * @param aSocket RSocket pointer to use as the endpoint |
|
92 * @param aMediaContext Media context to use for this endpoint, either |
|
93 * local or network |
|
94 * @return Symbian error code on error, KErrNone otherwise |
|
95 */ |
|
96 TInt SetMedia( RSocket* aSocket, TDunMediaContext aMediaContext ); |
|
97 |
|
98 /** |
|
99 * Gets media context |
|
100 * |
|
101 * @since S60 3.2 |
|
102 * @param aStreamType Stream type |
|
103 * @return Media context in use |
|
104 */ |
|
105 TDunMediaContext GetMediaContext( TDunStreamType aStreamType ); |
|
106 |
|
107 protected: |
|
108 |
|
109 CDunStream(); |
|
110 |
|
111 /** |
|
112 * Destructor. |
|
113 */ |
|
114 virtual ~CDunStream(); |
|
115 |
|
116 /** |
|
117 * Check whether an error code is severe error or not |
|
118 * |
|
119 * @since S60 3.2 |
|
120 * @param aError Error code to check for severity |
|
121 * @param aIsError ETrue if error code is error, EFalse if not error |
|
122 * @return ETrue if severe error detected, EFalse if not severe error |
|
123 */ |
|
124 TBool ProcessErrorCondition( TInt aError, TBool& aIsError ); |
|
125 |
|
126 // from base class CActive |
|
127 |
|
128 /** |
|
129 * From CActive. |
|
130 * Gets called when endpoint data read/write complete |
|
131 * |
|
132 * @since S60 3.2 |
|
133 * @return None |
|
134 */ |
|
135 virtual void RunL() {}; |
|
136 |
|
137 /** |
|
138 * From CActive. |
|
139 * Gets called on cancel |
|
140 * |
|
141 * @since S60 3.2 |
|
142 * @return None |
|
143 */ |
|
144 virtual void DoCancel() {}; |
|
145 |
|
146 private: |
|
147 |
|
148 /** |
|
149 * Initializes this class |
|
150 * |
|
151 * @since S60 3.2 |
|
152 * @return None |
|
153 */ |
|
154 void Initialize(); |
|
155 |
|
156 protected: // data |
|
157 |
|
158 /** |
|
159 * Pointer to stream's data buffer: upstream or downstream |
|
160 * Not own. |
|
161 */ |
|
162 TPtr8* iBufferPtr; |
|
163 |
|
164 /** |
|
165 * Callback(s) to call when notification(s) via MDunConnMon to be made |
|
166 * These callbacks are called on read failures |
|
167 */ |
|
168 RPointerArray<MDunConnMon> iCallbacksR; |
|
169 |
|
170 /** |
|
171 * Callback(s) to call when notification(s) via MDunConnMon to be made |
|
172 * These callbacks are called on write failures |
|
173 */ |
|
174 RPointerArray<MDunConnMon> iCallbacksW; |
|
175 |
|
176 /** |
|
177 * Read length set when RSocket::RecvOneOrMore() request completes |
|
178 */ |
|
179 TSockXfrLength iReadLengthSocket; |
|
180 |
|
181 /** |
|
182 * Type of current operation: read or write |
|
183 */ |
|
184 TDunOperationType iOperationType; |
|
185 |
|
186 /** |
|
187 * Current state of transfer: active or inactive |
|
188 */ |
|
189 TDunState iTransferState; |
|
190 |
|
191 /** |
|
192 * Direction of data transfer |
|
193 * This is set after iStreamType and iOperationType are known |
|
194 */ |
|
195 TDunDirection iDirection; |
|
196 |
|
197 /** |
|
198 * Array of error codes that will be skipped for read operations |
|
199 */ |
|
200 RArray<TInt> iOkErrorsR; |
|
201 |
|
202 /** |
|
203 * Array of error codes that will be skipped for write operations |
|
204 */ |
|
205 RArray<TInt> iOkErrorsW; |
|
206 |
|
207 /** |
|
208 * RComm object of network side |
|
209 * Not own. |
|
210 */ |
|
211 RComm* iNetwork; |
|
212 |
|
213 /** |
|
214 * RSocket object of local media side |
|
215 * If this is set then iComm is not used |
|
216 * Not own. |
|
217 */ |
|
218 RSocket* iSocket; |
|
219 |
|
220 /** |
|
221 * RComm object of local media side |
|
222 * If this is set then iSocket is not used |
|
223 * Not own. |
|
224 */ |
|
225 RComm* iComm; |
|
226 |
|
227 }; |
|
228 |
|
229 #endif // C_CDUNSTREAM_H |