1 /* |
1 /* |
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
122 // --------------------------------------------------------------------------- |
122 // --------------------------------------------------------------------------- |
123 // |
123 // |
124 TInt CDunDataWaiter::IssueRequest() |
124 TInt CDunDataWaiter::IssueRequest() |
125 { |
125 { |
126 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest()" ))); |
126 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest()" ))); |
127 if ( iDataWaiterState != EDunStateIdle ) |
127 if ( IsActive() ) |
128 { |
128 { |
129 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() (not ready) complete" ))); |
129 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() (not ready) complete" ))); |
130 return KErrNotReady; |
130 return KErrNotReady; |
131 } |
131 } |
132 if ( !iComm ) |
132 if ( !iComm ) |
133 { |
133 { |
134 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() (iComm) not initialized!" ) )); |
134 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() (iComm) not initialized!" ) )); |
135 return KErrGeneral; |
135 return KErrGeneral; |
136 } |
136 } |
137 iComm->ResetBuffers(); |
137 iComm->ResetBuffers(); |
138 iStatus = KRequestPending; |
|
139 iDataWaiterState = EDunStateDataWaiting; |
|
140 iComm->NotifyDataAvailable( iStatus ); |
138 iComm->NotifyDataAvailable( iStatus ); |
141 SetActive(); |
139 SetActive(); |
142 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() complete" ))); |
140 FTRACE(FPrint( _L("CDunDataWaiter::IssueRequest() complete" ))); |
143 return KErrNone; |
141 return KErrNone; |
144 } |
142 } |
145 |
143 |
146 // --------------------------------------------------------------------------- |
144 // --------------------------------------------------------------------------- |
147 // Stops monitoring for new data |
145 // Stops monitoring for new data |
148 // --------------------------------------------------------------------------- |
146 // --------------------------------------------------------------------------- |
149 // |
147 // |
150 TInt CDunDataWaiter::Stop() |
148 void CDunDataWaiter::Stop() |
151 { |
149 { |
152 FTRACE(FPrint( _L("CDunDataWaiter::Stop()" ))); |
150 FTRACE(FPrint( _L("CDunDataWaiter::Stop()" ))); |
153 if ( iDataWaiterState != EDunStateDataWaiting ) |
|
154 { |
|
155 FTRACE(FPrint( _L("CDunDataWaiter::Stop() (not ready) complete" ))); |
|
156 return KErrNotReady; |
|
157 } |
|
158 if ( !iComm ) |
|
159 { |
|
160 FTRACE(FPrint( _L("CDunDataWaiter::Stop() (iComm) not initialized!" ))); |
|
161 return KErrGeneral; |
|
162 } |
|
163 iComm->NotifyDataAvailableCancel(); |
|
164 Cancel(); |
151 Cancel(); |
165 iDataWaiterState = EDunStateIdle; |
|
166 FTRACE(FPrint( _L("CDunDataWaiter::Stop() complete" ))); |
152 FTRACE(FPrint( _L("CDunDataWaiter::Stop() complete" ))); |
167 return KErrNone; |
|
168 } |
153 } |
169 |
154 |
170 // --------------------------------------------------------------------------- |
155 // --------------------------------------------------------------------------- |
171 // CDunDataWaiter::CDunDataWaiter |
156 // CDunDataWaiter::CDunDataWaiter |
172 // --------------------------------------------------------------------------- |
157 // --------------------------------------------------------------------------- |
199 // |
184 // |
200 void CDunDataWaiter::Initialize() |
185 void CDunDataWaiter::Initialize() |
201 { |
186 { |
202 FTRACE(FPrint( _L("CDunDataWaiter::Initialize()" ) )); |
187 FTRACE(FPrint( _L("CDunDataWaiter::Initialize()" ) )); |
203 // Don't initialize iChannelCallback here (it is set through NewL) |
188 // Don't initialize iChannelCallback here (it is set through NewL) |
204 iDataWaiterState = EDunStateIdle; |
|
205 iComm = NULL; |
189 iComm = NULL; |
206 FTRACE(FPrint( _L("CDunDataWaiter::Initialize() complete" ) )); |
190 FTRACE(FPrint( _L("CDunDataWaiter::Initialize() complete" ) )); |
207 } |
191 } |
208 |
192 |
209 // --------------------------------------------------------------------------- |
193 // --------------------------------------------------------------------------- |
212 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
213 // |
197 // |
214 void CDunDataWaiter::RunL() |
198 void CDunDataWaiter::RunL() |
215 { |
199 { |
216 FTRACE(FPrint( _L("CDunDataWaiter::RunL()" ) )); |
200 FTRACE(FPrint( _L("CDunDataWaiter::RunL()" ) )); |
217 iDataWaiterState = EDunStateIdle; |
|
218 TInt retTemp = iStatus.Int(); |
201 TInt retTemp = iStatus.Int(); |
219 if ( retTemp != KErrNone ) |
202 if ( retTemp != KErrNone ) |
220 { |
203 { |
221 FTRACE(FPrint( _L("CDunDataWaiter::RunL() (failed) complete (%d)"), retTemp)); |
204 FTRACE(FPrint( _L("CDunDataWaiter::RunL() (failed) complete (%d)"), retTemp)); |
222 TInt count = iCallbacks.Count(); |
205 TInt count = iCallbacks.Count(); |
248 // Gets called on cancel |
231 // Gets called on cancel |
249 // --------------------------------------------------------------------------- |
232 // --------------------------------------------------------------------------- |
250 // |
233 // |
251 void CDunDataWaiter::DoCancel() |
234 void CDunDataWaiter::DoCancel() |
252 { |
235 { |
253 } |
236 FTRACE(FPrint( _L("CDunDataWaiter::DoCancel()" ) )); |
|
237 iComm->NotifyDataAvailableCancel(); |
|
238 FTRACE(FPrint( _L("CDunDataWaiter::DoCancel() complete" ) )); |
|
239 } |