78 } |
83 } |
79 |
84 |
80 void CScriptIO::CreateChannel(TRequestStatus& aStatus) |
85 void CScriptIO::CreateChannel(TRequestStatus& aStatus) |
81 { |
86 { |
82 ASSERT(iCreateAndShutdownStatus == NULL); |
87 ASSERT(iCreateAndShutdownStatus == NULL); |
83 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),_L("Script:\tOpening Comm Port '%S'"), &iCommsChannel); |
88 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_CREATECHANNEL_1,"Script:\tOpening Comm Port '%S'", iCommsChannel); |
84 |
89 |
85 iCommClosed = EFalse; |
90 iCommClosed = EFalse; |
86 TInt err = CommOpen(iCommsChannel); |
91 TInt err = CommOpen(iCommsChannel); |
87 if (err != KErrNone) |
92 if (err != KErrNone) |
88 { |
93 { |
89 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),_L("Script: Error %d opening Comm Port"), err); |
94 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_CREATECHANNEL_2, "Script: Error %d opening Comm Port", err); |
90 TRequestStatus* stat = &aStatus; |
95 TRequestStatus* stat = &aStatus; |
91 User::RequestComplete(stat, err); |
96 User::RequestComplete(stat, err); |
92 } |
97 } |
93 iCreateAndShutdownStatus = &aStatus; |
98 iCreateAndShutdownStatus = &aStatus; |
94 } |
99 } |
95 |
100 |
96 void CScriptIO::CancelCreateChannel() |
101 void CScriptIO::CancelCreateChannel() |
97 { |
102 { |
98 __FLOG_STMT(_LIT8(logString,"Script:\tCancelCreateChannel()");) |
103 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_CANCELCREATECHANNEL_1, "Script:\tCancelCreateChannel()"); |
99 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
100 CommCancel(); |
104 CommCancel(); |
101 } |
105 } |
102 |
106 |
103 void CScriptIO::InitializeComplete() |
107 void CScriptIO::InitializeComplete() |
104 { |
108 { |
105 __FLOG_STMT(_LIT8(logString,"Script:\tInitializeComplete()");) |
109 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_INITIALIZECOMPLETE_1,"Script:\tInitializeComplete()"); |
106 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
107 ASSERT(iCreateAndShutdownStatus); |
110 ASSERT(iCreateAndShutdownStatus); |
108 User::RequestComplete(iCreateAndShutdownStatus, KErrNone); |
111 User::RequestComplete(iCreateAndShutdownStatus, KErrNone); |
109 iCreateAndShutdownStatus = NULL; |
112 iCreateAndShutdownStatus = NULL; |
110 } |
113 } |
111 |
114 |
112 void CScriptIO::ShutdownComplete(TInt aError) |
115 void CScriptIO::ShutdownComplete(TInt aError) |
113 { |
116 { |
114 __FLOG_STMT(_LIT8(logString,"Script:\tShutdownComplete(aError %d)");) |
117 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_SHUTDOWNCOMPLETE_1, _"Script:\tShutdownComplete(aError %d)", aError); |
115 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),logString(), aError); |
|
116 |
118 |
117 ASSERT(iCreateAndShutdownStatus); |
119 ASSERT(iCreateAndShutdownStatus); |
118 if (iCreateError != KErrNone) //The creation error is probably more interesting than a bad shutdown error |
120 if (iCreateError != KErrNone) //The creation error is probably more interesting than a bad shutdown error |
119 { |
121 { |
120 aError = iCreateError; |
122 aError = iCreateError; |
198 void CScriptIO::CommReadComplete(TInt aStatus) |
199 void CScriptIO::CommReadComplete(TInt aStatus) |
199 /** |
200 /** |
200 Reads completely - stops timer and if no error checks string against the desired string |
201 Reads completely - stops timer and if no error checks string against the desired string |
201 */ |
202 */ |
202 { |
203 { |
203 __FLOG_STMT(_LIT8(logString1,"Script:\tRead Complete");) |
204 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMREADCOMPLETE_1,"Script:\tRead Complete"); |
204 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString1()); |
|
205 if(aStatus==KErrCommsLineFail) |
205 if(aStatus==KErrCommsLineFail) |
206 { |
206 { |
207 __FLOG_STMT(_LIT8(logString2,"Script:\tComms Error %d");) |
207 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMREADCOMPLETE_2,"Script:\tComms Error %d",aStatus); |
208 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC8>(logString2()),aStatus); |
|
209 iChat->StopTimer(); |
208 iChat->StopTimer(); |
210 iReadPending=EFalse; |
209 iReadPending=EFalse; |
211 TRAPD(ret,iScriptExecutor->CompletedReadL(KErrCommsLineFail)); |
210 TRAPD(ret,iScriptExecutor->CompletedReadL(KErrCommsLineFail)); |
212 if (KErrNone != ret) |
211 if (KErrNone != ret) |
213 { |
212 { |
214 __FLOG_STMT(_LIT8(logString6,"Script:\tCompleteReadL Failure");) |
213 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMREADCOMPLETE_3,"Script:\tCompleteReadL Failure"); |
215 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString6()); |
|
216 } |
214 } |
217 return; |
215 return; |
218 } |
216 } |
219 |
217 |
220 __ASSERT_ALWAYS(iReadPending,NetDialPanic(EIllegalReadComplete)); |
218 __ASSERT_ALWAYS(iReadPending,NetDialPanic(EIllegalReadComplete)); |
221 iReadPending=EFalse; |
219 iReadPending=EFalse; |
222 |
220 |
223 |
221 |
224 if (aStatus==KErrCommsFrame) |
222 if (aStatus==KErrCommsFrame) |
225 { |
223 { |
226 __FLOG_STMT(_LIT(logString3,"Script:\tComms Error %d");) |
224 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMREADCOMPLETE_4, "Script:\tComms Error %d",aStatus); |
227 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString3()),aStatus); |
|
228 User::After(KClockTick); // wait for a clock tick and continue |
225 User::After(KClockTick); // wait for a clock tick and continue |
229 aStatus=KErrNone; |
226 aStatus=KErrNone; |
230 } |
227 } |
231 |
228 |
232 else if (aStatus!=KErrNone) |
229 else if (aStatus!=KErrNone) |
233 { |
230 { |
234 TRAPD(ret,iScriptExecutor->CompletedReadL(aStatus)); |
231 TRAPD(ret,iScriptExecutor->CompletedReadL(aStatus)); |
235 if (KErrNone != ret) |
232 if (KErrNone != ret) |
236 { |
233 { |
237 __FLOG_STMT(_LIT8(logString7,"Script:\tCompleteReadL Failure");) |
234 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMREADCOMPLETE_5,"Script:\tCompleteReadL Failure"); |
238 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString7()); |
|
239 } |
235 } |
240 return; |
236 return; |
241 } |
237 } |
242 |
238 |
243 #ifdef __FLOG_ACTIVE |
239 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMREADCOMPLETE_7, "Rx:\t%s",iRxBuffer); |
244 _LIT(logString4,"Rx:\t%S"); |
240 |
245 TBuf16<KLogBufferSize> temp; |
|
246 temp.Copy(iRxBuffer.Left(Min(iRxBuffer.Length(),KLogBufferSize))); |
|
247 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString4()),&temp); |
|
248 #endif |
|
249 |
241 |
250 if (iScriptExecutor->RequestUsePct()) |
242 if (iScriptExecutor->RequestUsePct()) |
251 { |
243 { |
252 TInt err=iScriptExecutor->WritePct(iRxBuffer); |
244 TInt err=iScriptExecutor->WritePct(iRxBuffer); |
253 if (err!=KErrNone) |
245 if (err!=KErrNone) |
254 { |
246 { |
255 TRAPD(ret,iScriptExecutor->CompletedReadL(err)); |
247 TRAPD(ret,iScriptExecutor->CompletedReadL(err)); |
256 if (KErrNone != ret) |
248 if (KErrNone != ret) |
257 { |
249 { |
258 __FLOG_STMT(_LIT8(logString8,"Script:\tCompleteReadL Failure");) |
250 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMREADCOMPLETE_8,"Script:\tCompleteReadL Failure"); |
259 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString8()); |
|
260 } |
251 } |
261 return; |
252 return; |
262 } |
253 } |
263 } |
254 } |
264 |
255 |
303 void CScriptIO::CommWriteComplete(TInt aStatus) |
288 void CScriptIO::CommWriteComplete(TInt aStatus) |
304 /** |
289 /** |
305 Writes completely - stops timer |
290 Writes completely - stops timer |
306 */ |
291 */ |
307 { |
292 { |
308 __FLOG_STMT(_LIT8(logString,"Script:\tWrite Complete");) |
293 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMWRITECOMPLETE_1,"Script:\tWrite Complete"); |
309 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
310 iChat->StopTimer(); |
294 iChat->StopTimer(); |
311 if(aStatus==KErrCommsLineFail) |
295 if(aStatus==KErrCommsLineFail) |
312 { |
296 { |
313 __FLOG_STMT(_LIT8(logString2,"Script:\tComms Error %d");) |
297 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_COMMWRITECOMPLETE_2, "Script:\tComms Error %d",aStatus); |
314 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),logString2(),aStatus); |
|
315 iWritePending=EFalse; |
298 iWritePending=EFalse; |
316 iScriptExecutor->CompletedWrite(KErrCommsLineFail); |
299 iScriptExecutor->CompletedWrite(KErrCommsLineFail); |
317 return; |
300 return; |
318 } |
301 } |
319 __ASSERT_ALWAYS(iWritePending,NetDialPanic(EIllegalWriteComplete)); |
302 __ASSERT_ALWAYS(iWritePending,NetDialPanic(EIllegalWriteComplete)); |
339 */ |
321 */ |
340 { |
322 { |
341 CommCancel(); |
323 CommCancel(); |
342 if(iWritePending) |
324 if(iWritePending) |
343 { |
325 { |
344 __FLOG_STMT(_LIT8(logString1,"Script:\tWrite Chat Time Out");) |
326 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_CHATTIMEOUT_1, "Script:\tWrite Chat Time Out"); |
345 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString1()); |
|
346 iWritePending=EFalse; |
327 iWritePending=EFalse; |
347 iScriptExecutor->CompletedWrite(KErrTimedOut); |
328 iScriptExecutor->CompletedWrite(KErrTimedOut); |
348 } |
329 } |
349 else if(iReadPending) |
330 else if(iReadPending) |
350 { |
331 { |
351 __FLOG_STMT(_LIT8(logString2,"Script:\tRead Chat Time Out");) |
332 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_CHATTIMEOUT_2,"Script:\tRead Chat Time Out"); |
352 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString2()); |
|
353 iReadPending=EFalse; |
333 iReadPending=EFalse; |
354 TRAPD(ret,iScriptExecutor->CompletedReadL(KErrTimedOut)); |
334 TRAPD(ret,iScriptExecutor->CompletedReadL(KErrTimedOut)); |
355 if (KErrNone != ret) |
335 if (KErrNone != ret) |
356 { |
336 { |
357 __FLOG_STMT(_LIT8(logString3,"Script:\tCompleteReadL Failure");) |
337 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_CHATTIMEOUT_3,"Script:\tCompleteReadL Failure"); |
358 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString3()); |
|
359 } |
338 } |
360 } |
339 } |
361 else |
340 else |
362 NetDialPanic(EIllegalTimeOutComplete); |
341 NetDialPanic(EIllegalTimeOutComplete); |
363 } |
342 } |
380 // |
359 // |
381 TReal realTimeInterval=aTimeOut*KTRealOneSecInMicroSecs; |
360 TReal realTimeInterval=aTimeOut*KTRealOneSecInMicroSecs; |
382 TInt timeInterval=TInt(realTimeInterval); |
361 TInt timeInterval=TInt(realTimeInterval); |
383 if (realTimeInterval>TReal(timeInterval)) |
362 if (realTimeInterval>TReal(timeInterval)) |
384 timeInterval++; |
363 timeInterval++; |
385 __FLOG_STMT(_LIT8(logString,"Script:\tRead Pending In %d Microseconds");) |
364 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_READ_1,"Script:\tRead Pending In %d Microseconds",timeInterval); |
386 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),logString(),timeInterval); |
365 |
387 // |
366 // |
388 iChat->StartTimer(timeInterval); |
367 iChat->StartTimer(timeInterval); |
389 CommReadOneOrMore(iRxBuffer); |
368 CommReadOneOrMore(iRxBuffer); |
390 iRxBufOffset=0; |
369 iRxBufOffset=0; |
391 } |
370 } |
422 void CScriptIO::PreSendPauseCompleted() |
400 void CScriptIO::PreSendPauseCompleted() |
423 /** |
401 /** |
424 PreSend pause is finished, can now do write. |
402 PreSend pause is finished, can now do write. |
425 */ |
403 */ |
426 { |
404 { |
427 #ifdef __FLOG_ACTIVE |
405 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSCRIPTIO_PRESENDPAUSECOMPLETED_1, "Tx:\t%s",iTxBuffer); |
428 _LIT(logString,"Tx:\t%S"); |
|
429 TBuf16<KLogBufferSize> temp; |
|
430 temp.Copy(iTxBuffer.Left(Min(iTxBuffer.Length(),KLogBufferSize))); |
|
431 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString()),&temp); |
|
432 #endif |
|
433 CommWrite(iTxBuffer); |
406 CommWrite(iTxBuffer); |
434 iChat->StartTimer(KWriteTimeOutSec*KOneSecInMicroSecs); |
407 iChat->StartTimer(KWriteTimeOutSec*KOneSecInMicroSecs); |
435 } |
408 } |
436 |
409 |
437 TBool CScriptIO::RWPending() |
410 TBool CScriptIO::RWPending() |