200 |
200 |
201 // --------------------------------------------------------------------------- |
201 // --------------------------------------------------------------------------- |
202 // Stops sending for write endpoint |
202 // Stops sending for write endpoint |
203 // --------------------------------------------------------------------------- |
203 // --------------------------------------------------------------------------- |
204 // |
204 // |
205 TInt CDunDataPusher::Stop() |
205 void CDunDataPusher::Stop() |
206 { |
206 { |
207 FTRACE(FPrint( _L("CDunDataPusher::Stop()" ))); |
207 FTRACE(FPrint( _L("CDunDataPusher::Stop()" ))); |
208 if ( iPushState != EDunStateDataPushing ) |
|
209 { |
|
210 FTRACE(FPrint( _L("CDunDataPusher::Stop() (not ready) complete" ))); |
|
211 return KErrNotReady; |
|
212 } |
|
213 // As the EDunStateDataPushing can be on even with multiple requests, |
|
214 // cancel the actual operation in DoCancel() |
|
215 Cancel(); |
208 Cancel(); |
216 iPushState = EDunStateIdle; |
|
217 FTRACE(FPrint( _L("CDunDataPusher::Stop() complete" ))); |
209 FTRACE(FPrint( _L("CDunDataPusher::Stop() complete" ))); |
218 return KErrNone; |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // Stops sending for write endpoint and clears event queue |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 TInt CDunDataPusher::StopAndClearQueue() |
|
226 { |
|
227 FTRACE(FPrint( _L("CDunDataPusher::StopAndClearQueue()" ))); |
|
228 TInt retVal = Stop(); |
|
229 iEventQueue.Reset(); |
|
230 iEventIndex = 0; |
|
231 FTRACE(FPrint( _L("CDunDataPusher::StopAndClearQueue() complete" ))); |
|
232 return retVal; |
|
233 } |
210 } |
234 |
211 |
235 // --------------------------------------------------------------------------- |
212 // --------------------------------------------------------------------------- |
236 // Signals completion status in round robin and clears event queue |
213 // Signals completion status in round robin and clears event queue |
237 // --------------------------------------------------------------------------- |
214 // --------------------------------------------------------------------------- |
334 return KErrGeneral; |
310 return KErrGeneral; |
335 } |
311 } |
336 const TDesC8* dataToPush = iEventQueue[iEventIndex].iDataToPush; |
312 const TDesC8* dataToPush = iEventQueue[iEventIndex].iDataToPush; |
337 if ( iComm ) |
313 if ( iComm ) |
338 { |
314 { |
339 iStatus = KRequestPending; |
|
340 iPushState = EDunStateDataPushing; |
|
341 iComm->Write( iStatus, *dataToPush ); |
315 iComm->Write( iStatus, *dataToPush ); |
342 SetActive(); |
316 SetActive(); |
343 FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() RComm Write() requested for %d bytes... (buffer=0x%08X)" ), dataToPush->Length(), dataToPush )); |
317 FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() RComm Write() requested for %d bytes... (buffer=0x%08X)" ), dataToPush->Length(), dataToPush )); |
344 } |
318 } |
345 else if ( iSocket ) |
319 else if ( iSocket ) |
346 { |
320 { |
347 iStatus = KRequestPending; |
|
348 iPushState = EDunStateDataPushing; |
|
349 iSocket->Send( *dataToPush, 0, iStatus ); |
321 iSocket->Send( *dataToPush, 0, iStatus ); |
350 SetActive(); |
322 SetActive(); |
351 FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() RSocket Send() requested for %d bytes... (buffer=0x%08X)" ), dataToPush->Length(), dataToPush )); |
323 FTRACE(FPrint( _L("CDunDataPusher::ManageOneEvent() RSocket Send() requested for %d bytes... (buffer=0x%08X)" ), dataToPush->Length(), dataToPush )); |
352 } |
324 } |
353 else |
325 else |
406 ManageOneEvent(); |
378 ManageOneEvent(); |
407 } |
379 } |
408 else |
380 else |
409 { |
381 { |
410 // Last was served so stop processing and notify |
382 // Last was served so stop processing and notify |
411 iPushState = EDunStateIdle; |
|
412 iStreamCallback->NotifyDataPushComplete( ETrue ); |
383 iStreamCallback->NotifyDataPushComplete( ETrue ); |
413 } |
384 } |
414 } // if ( !stop ) |
385 } // if ( !stop ) |
415 else // stop -> tear down connection |
386 else // stop -> tear down connection |
416 { |
387 { |
417 iPushState = EDunStateIdle; |
|
418 TDunConnectionReason connReason; |
388 TDunConnectionReason connReason; |
419 connReason.iReasonType = EDunReasonTypeRW; |
389 connReason.iReasonType = EDunReasonTypeRW; |
420 connReason.iContext = EDunMediaContextLocal; |
390 connReason.iContext = EDunMediaContextLocal; |
421 connReason.iSignalType = 0; |
391 connReason.iSignalType = 0; |
422 connReason.iSignalHigh = EFalse; |
392 connReason.iSignalHigh = EFalse; |