|
1 // Copyright (c) 1997-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 #include "FAXSERV.H" |
|
17 #include "fax_reversebytes.h" |
|
18 #include "FAXMODEM.H" |
|
19 #include "FAXMDRV.H" |
|
20 |
|
21 #include "FAXLOG.H" |
|
22 |
|
23 |
|
24 const TInt KClass2HangupStatusTimer=20; // < Time used to wait for final +FHNG: report. |
|
25 |
|
26 // this module has three parts |
|
27 // first receive routines rx |
|
28 // second transmit routines tx |
|
29 // third utilities |
|
30 |
|
31 /********************************************************************/ |
|
32 |
|
33 CFaxModemDriver *CFaxClass2::NewLC (TFaxServerSessionSettings * aFaxServerSessionSettings, RFax::TProgress & aProgress) |
|
34 { |
|
35 CFaxModemDriver *self = new (ELeave) CFaxClass2; |
|
36 CleanupStack::PushL (self); |
|
37 self->ConstructL (aFaxServerSessionSettings, aProgress); |
|
38 return self; |
|
39 } |
|
40 |
|
41 CFaxModemDriver *CFaxClass2::NewL (TFaxServerSessionSettings * aFaxServerSessionSettings, RFax::TProgress & aProgress) |
|
42 { |
|
43 CFaxModemDriver *self = NewLC (aFaxServerSessionSettings, aProgress); |
|
44 CleanupStack::Pop (); |
|
45 return self; |
|
46 } |
|
47 /********************************************************************/ |
|
48 |
|
49 TInt CFaxClass2::RxConnectL () |
|
50 { |
|
51 __FLOG_FAXSRV( _L8("CFaxClass2::RxConnectL entering")); |
|
52 |
|
53 CheckCadenceExportL (_L8 ("AT+FDCC=?\r")); |
|
54 if (!(iModem->ImportL (iResults, 35))) |
|
55 return (KFaxErrModemNotWorking); |
|
56 |
|
57 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
58 iModem->ProgressUpdateL (); |
|
59 ParseResults (iResults); |
|
60 |
|
61 iModem->GetMatchL (_L8 ("OK"), 2); |
|
62 |
|
63 if (iFaxServerSessionSettings->iRxResolution == EFaxNormal) |
|
64 iModem->iProgress.iResolution = EFaxNormal; |
|
65 else |
|
66 iModem->iProgress.iResolution = EFaxFine; |
|
67 |
|
68 if (iFaxServerSessionSettings->iRxCompression == EModifiedRead) |
|
69 iModem->iProgress.iCompression = EModifiedRead; |
|
70 else |
|
71 iModem->iProgress.iCompression = EModifiedHuffman; |
|
72 iActualFaxSpeed = iModem->iProgress.iSpeed; |
|
73 if (iActualFaxSpeed > iFaxServerSessionSettings->iMaxSpeed) |
|
74 iActualFaxSpeed = iFaxServerSessionSettings->iMaxSpeed; |
|
75 |
|
76 iResults.Copy (_L8 ("AT+FDCC=0,0,0,2,0,0,0,0\r")); |
|
77 |
|
78 iResults[8] = (TUint8) (iResults[8] + iModem->iProgress.iResolution); |
|
79 iResults[10] = (TUint8) (((iActualFaxSpeed / 2400) - 1) + '0'); |
|
80 iResults[16] = (TUint8) (iResults[16] + iModem->iProgress.iCompression); |
|
81 CheckCadenceExportL (iResults); |
|
82 if ((iModem->GetMatchL (_L8 ("OK"), 3)) == 0) |
|
83 return (KFaxErrModemNotWorking); |
|
84 CheckCadenceExportL (_L8 ("AT+FAA=0\r")); |
|
85 if ((iModem->GetMatchL (_L8 ("OK"), 5)) == 0) |
|
86 return (KFaxErrNoReceiveMode); |
|
87 |
|
88 TBuf8<RCall::KFaxIdUserNameMaxSize> narrowBuf; |
|
89 narrowBuf.Copy(iFaxServerSessionSettings->iFaxId); |
|
90 |
|
91 //-- By Dmitry Lyokhin. concerns PIA-58ELQK defect. |
|
92 if( narrowBuf.Length() < 1 ) narrowBuf.Append(' '); |
|
93 |
|
94 |
|
95 if (iFaxServerSessionSettings->iMode & KFaxPoll) |
|
96 { |
|
97 iModem->ExportL (_L8 ("AT+FSPL=1\r")); |
|
98 if ((iModem->GetMatchL (_L8 ("OK"), 5)) == 0) |
|
99 return (KFaxPollingUnsupported); |
|
100 iModem->ExportL (_L8 ("AT+FCIG=\"")); |
|
101 iModem->ExportL (narrowBuf); |
|
102 iModem->ExportL (_L8 ("\"\r")); |
|
103 if ((iModem->GetMatchL (_L8 ("OK"), 3)) == 0) |
|
104 return (KFaxPollingUnsupported); |
|
105 } |
|
106 else |
|
107 { |
|
108 CheckCadenceExportL (_L8 ("AT+FCR=1\r")); |
|
109 if ((iModem->GetMatchL (_L8 ("OK"), 5)) == 0) |
|
110 return (KFaxErrNoReceiveMode); |
|
111 CheckCadenceExportL (_L8 ("AT+FLID=\"")); |
|
112 iModem->ExportL (narrowBuf); |
|
113 iModem->ExportL (_L8 ("\"\r")); |
|
114 if ((iModem->GetMatchL (_L8 ("OK"), 3)) == 0) |
|
115 return (KFaxErrModemNotWorking); |
|
116 } |
|
117 |
|
118 if (iFaxServerSessionSettings->iMode & KFaxWaitForRing) |
|
119 { |
|
120 // while ((iModem->GetMatchL (_L8 ("RING"), 3)) == 0); |
|
121 // iTimeOfLastRing.UniversalTime(); |
|
122 } |
|
123 else |
|
124 { |
|
125 if ((iFaxServerSessionSettings->iMode & KFaxOffHook) == 0) |
|
126 DialFaxOnDemandL (); |
|
127 } |
|
128 |
|
129 if ((iFaxServerSessionSettings->iMode & KFaxPoll) == 0) |
|
130 { |
|
131 iModem->Silence (CLK_TCK); |
|
132 CheckCadenceExportL (_L8 ("ATA\r")); |
|
133 } |
|
134 |
|
135 iModem->iProgress.iPhase = ECallEstablishment; |
|
136 |
|
137 TInt pollDocsAvailable = 0; |
|
138 |
|
139 for (;;) |
|
140 { |
|
141 if (!(iModem->ImportL (iResults, 35))) |
|
142 return (KFaxErrCannotAnswer); |
|
143 |
|
144 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
145 iModem->ProgressUpdateL (); |
|
146 |
|
147 if ((iResults.FindF (_L8 ("NO DIALTONE"))) >= 0 || |
|
148 iResults.FindF (_L8 ("NO DIAL TONE")) >= 0) |
|
149 return (KFaxErrNoDialTone); |
|
150 if ((iResults.FindF (_L8 ("BUSY"))) >= 0) |
|
151 return (KFaxErrBusy); |
|
152 if ((iResults.FindF (_L8 ("NO ANSWER"))) >= 0) |
|
153 return (KFaxErrNoAnswer); |
|
154 if ((iResults.FindF (_L8 ("NO CARRIER"))) >= 0) |
|
155 return (KFaxErrNoCarrier); |
|
156 if ((iResults.FindF (_L8 ("OK"))) >= 0) |
|
157 break; |
|
158 if ((iResults.FindF (_L8 ("FHNG"))) >= 0) |
|
159 return (KFaxErrPrematureHangup); |
|
160 if ((iResults.FindF (_L8 ("FCON"))) >= 0) |
|
161 iModem->iProgress.iPhase = ESessionNegotiation; |
|
162 else if ((iResults.FindF (_L8 ("FPOLL"))) >= 0) |
|
163 pollDocsAvailable = 1; |
|
164 else if ((iResults.FindF (_L8 ("FTSI"))) >= 0) |
|
165 ExtractAnswerback (iResults); |
|
166 else if ((iResults.FindF (_L8 ("FDCS"))) >= 0) |
|
167 ParseResults (iResults); |
|
168 } |
|
169 |
|
170 if ((iFaxServerSessionSettings->iMode & KFaxPoll) && (pollDocsAvailable == 0)) |
|
171 return (KFaxNothingToPoll); |
|
172 |
|
173 iModem->iOurMessage.Format (_L8 ("about to receive fax")); |
|
174 iModem->ProgressUpdateL (); |
|
175 return (RxPrePageL ()); |
|
176 } |
|
177 |
|
178 /********************************************************************/ |
|
179 TInt CFaxClass2::RxPrePageL () |
|
180 { |
|
181 __FLOG_FAXSRV( _L8("CFaxClass2::RxPrePageL entering")); |
|
182 |
|
183 iModem->ExportL (_L8 ("AT+FDR\r")); |
|
184 for (;;) |
|
185 { |
|
186 if (!(iModem->ImportL (iResults, 35))) |
|
187 return (KFaxErrCannotConnect); |
|
188 |
|
189 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
190 iModem->ProgressUpdateL (); |
|
191 |
|
192 if ((iResults.FindF (_L8 ("ERROR"))) >= 0) |
|
193 return (KFaxErrNoReceiveMode); |
|
194 if ((iResults.FindF (_L8 ("FHNG"))) >= 0) |
|
195 return (KFaxErrPrematureHangup); |
|
196 if ((iResults.FindF (_L8 ("CONNECT"))) >= 0) |
|
197 break; |
|
198 if ((iResults.FindF (_L8 ("FDCS"))) >= 0) |
|
199 ParseResults (iResults); |
|
200 } |
|
201 |
|
202 iModem->TxcharL (Kdc2); |
|
203 return (RxStartPageL ()); |
|
204 } |
|
205 /********************************************************************/ |
|
206 TInt CFaxClass2::RxPostPageL () |
|
207 { |
|
208 __FLOG_FAXSRV(_L8("CFaxClass2::RxPostPageL entering")); |
|
209 |
|
210 iModem->iProgress.iPhase = EPostPageStatus; |
|
211 iModem->ProgressUpdateL (); |
|
212 for (;;) |
|
213 { |
|
214 if (!(iModem->ImportL (iResults, 20))) |
|
215 return (KFaxErrModemResponse); |
|
216 |
|
217 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
218 iModem->ProgressUpdateL (); |
|
219 |
|
220 if ((iResults.FindF (_L8 ("OK"))) >= 0) |
|
221 return (KFaxErrPrematureOK); |
|
222 if ((iResults.FindF (_L8 ("FHNG"))) >= 0) |
|
223 return (KFaxErrPrematureHangup); |
|
224 if ((iResults.FindF (_L8 ("FET"))) >= 0) |
|
225 break; |
|
226 } |
|
227 if (iModem->GetMatchL (_L8 ("OK"), 5) == 0) |
|
228 return (KFaxErrNoFinalOK); |
|
229 |
|
230 if ((iResults.FindF (_L8 ("0"))) >= 0) |
|
231 { |
|
232 iModem->iOurMessage.Format (_L8 ("page %u successfully received"), iModem->iProgress.iPage); |
|
233 iModem->ProgressUpdateL (); |
|
234 return (RxPrePageL ()); |
|
235 } |
|
236 if ((iResults.FindF (_L8 ("1"))) >= 0) |
|
237 { |
|
238 iModem->iOurMessage.Format (_L8 ("page %u successfully received : end of document"), iModem->iProgress.iPage); |
|
239 iModem->ProgressUpdateL (); |
|
240 iModem->iOurMessage.Format (_L8 ("Next fax awaited")); |
|
241 iModem->ProgressUpdateL (); |
|
242 return (RxPrePageL ()); |
|
243 } |
|
244 if ((iResults.FindF (_L8 ("2"))) >= 0) |
|
245 { |
|
246 iModem->iOurMessage.Format (_L8 ("Final page %u successfully received"), iModem->iProgress.iPage); |
|
247 iModem->ProgressUpdateL (); |
|
248 iModem->iProgress.iPhase = EDisconnection; |
|
249 iModem->ExportL (_L8 ("AT+FDR\r")); |
|
250 if (iModem->GetMatchL (_L8 ("FHNG"), KClass2HangupStatusTimer) == 0) |
|
251 return (KFaxErrNoHangup); |
|
252 if (iModem->GetMatchL (_L8 ("OK"), 5) == 0) |
|
253 return (KFaxErrNoFinalOK); |
|
254 return (KErrNone); |
|
255 } |
|
256 return (KFaxErrUnknownPageCode); |
|
257 } |
|
258 /********************************************************************/ |
|
259 |
|
260 TInt CFaxClass2::TxConnectL () |
|
261 { |
|
262 // we always use direct bit order when sending |
|
263 // we always use reversed bit order when receiving |
|
264 // this is in accordance with the rockwell bug. |
|
265 // if a modem doesn't have the rockwell bug then |
|
266 // the fax init string AT+FBOR=1 will force the |
|
267 // use of reversed bit ordering on reception. |
|
268 // since we have here a hardwired default AT+FBOR=0 |
|
269 // on transmission this will override the init string |
|
270 // which will therefore only be used (as needed) for |
|
271 // reception, and everything will work again |
|
272 |
|
273 __FLOG_FAXSRV( _L8("CFaxClass2::TxConnectL entering")); |
|
274 |
|
275 iModem->ExportL (_L8 ("AT+FBOR=0\r")); |
|
276 iModem->GetMatchL (_L8 ("OK"), 3); |
|
277 |
|
278 TBuf8<RCall::KFaxIdUserNameMaxSize> narrowBuf; |
|
279 narrowBuf.Copy(iFaxServerSessionSettings->iFaxId); |
|
280 |
|
281 //-- if the fax local id string is empty, insert blank |
|
282 //-- PIA-58ELQK defect fix by Dmitry Lyokhin 26.03.2001 |
|
283 if( narrowBuf.Length() < 1 ) narrowBuf.Append(' '); |
|
284 |
|
285 |
|
286 iModem->ExportL (_L8 ("AT+FLID=\"")); |
|
287 iModem->ExportL (narrowBuf); |
|
288 iModem->ExportL (_L8 ("\"\r")); |
|
289 if ((iModem->GetMatchL (_L8 ("OK"), 3)) == 0) |
|
290 return (KFaxErrModemNotWorking); |
|
291 |
|
292 iModem->ExportL (_L8 ("AT+FDCC=?\r")); |
|
293 if (!(iModem->ImportL (iResults, 35))) |
|
294 return (KFaxErrModemNotWorking); |
|
295 |
|
296 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
297 iModem->ProgressUpdateL (); |
|
298 ParseResults (iResults); |
|
299 |
|
300 iModem->GetMatchL (_L8 ("OK"), 2); |
|
301 |
|
302 iActualFaxSpeed = iModem->iProgress.iSpeed; |
|
303 if (iActualFaxSpeed > iFaxServerSessionSettings->iMaxSpeed) |
|
304 iActualFaxSpeed = iFaxServerSessionSettings->iMaxSpeed; |
|
305 |
|
306 iResults.Copy (_L8 ("AT+FDCC=0,0,0,2,0,0,0,0\r")); |
|
307 |
|
308 iResults[8] = (TUint8) (iResults[8] + iFaxServerSessionSettings->iTxResolution); |
|
309 iResults[10] = (TUint8) (((iActualFaxSpeed / 2400) - 1) + '0'); |
|
310 |
|
311 |
|
312 // added to support 2Dfaxing using class 2 |
|
313 if (iModem->iProgress.iCompression==EModifiedRead) |
|
314 iResults[16] = (TUint8) (iResults[16] + iFaxServerSessionSettings->iTxCompression); |
|
315 else |
|
316 iResults[16] = (TUint8) (iResults[16] + EModifiedHuffman); |
|
317 |
|
318 iModem->ExportL (iResults); |
|
319 if ((iModem->GetMatchL (_L8 ("OK"), 3)) == 0) |
|
320 return (KFaxErrModemNotWorking); |
|
321 |
|
322 iModem->ExportL (_L8 ("ATD")); |
|
323 if ((iFaxServerSessionSettings->iMode & KFaxOffHook) == 0) |
|
324 iModem->ExportL (iFaxServerSessionSettings->iPhoneNumber); |
|
325 iModem->TxcharL (Kreturn); |
|
326 |
|
327 iModem->iProgress.iPhase = ECallEstablishment; |
|
328 for (;;) |
|
329 { |
|
330 if (!(iModem->ImportL (iResults, KDialTimeout))) |
|
331 return (KFaxErrNoDial); |
|
332 |
|
333 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
334 iModem->ProgressUpdateL (); |
|
335 |
|
336 if ((iResults.FindF (_L8 ("NO DIALTONE"))) >= 0 || |
|
337 iResults.FindF (_L8 ("NO DIAL TONE")) >= 0) |
|
338 return (KFaxErrNoDialTone); |
|
339 if ((iResults.FindF (_L8 ("BUSY"))) >= 0) |
|
340 return (KFaxErrBusy); |
|
341 if ((iResults.FindF (_L8 ("NO ANSWER"))) >= 0) |
|
342 return (KFaxErrNoAnswer); |
|
343 if ((iResults.FindF (_L8 ("NO CARRIER"))) >= 0) |
|
344 return (KFaxErrNoCarrier); |
|
345 if ((iResults.FindF (_L8 ("FHNG"))) >= 0) |
|
346 return (KFaxErrNoNegotiate); |
|
347 if ((iResults.FindF (_L8 ("OK"))) >= 0) |
|
348 break; |
|
349 if ((iResults.FindF (_L8 ("FCON"))) >= 0) |
|
350 iModem->iProgress.iPhase = ESessionNegotiation; |
|
351 else if ((iResults.FindF (_L8 ("FCSI"))) >= 0) |
|
352 ExtractAnswerback (iResults); |
|
353 } |
|
354 return (TxPrePageL ()); |
|
355 } |
|
356 /********************************************************************/ |
|
357 TInt CFaxClass2::TxPrePageL () |
|
358 { |
|
359 __FLOG_FAXSRV( _L8("CFaxClass2::TxPrePageL entering")); |
|
360 |
|
361 iModem->ExportL (_L8 ("AT+FDT\r")); |
|
362 for (;;) |
|
363 { |
|
364 if (!(iModem->ImportL (iResults, 30))) |
|
365 return (KFaxErrNoNegotiate); |
|
366 |
|
367 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
368 iModem->ProgressUpdateL (); |
|
369 |
|
370 if ((iResults.FindF (_L8 ("FHNG"))) >= 0) |
|
371 return (KFaxErrNoNegotiate); |
|
372 if ((iResults.FindF (_L8 ("CONNECT"))) >= 0) |
|
373 break; |
|
374 if ((iResults.FindF (_L8 ("FDCS"))) >= 0) |
|
375 ParseResults (iResults); |
|
376 } |
|
377 |
|
378 for (;;) |
|
379 { |
|
380 |
|
381 //TInt ticks = CLK_TCK * 10; |
|
382 //-- PIA-58ELQK defect fix by Dmitry Lyokhin 26.03.2001 |
|
383 TInt XonTimeoutSec = CLK_TCK * 3; |
|
384 |
|
385 if ((iModem->RxcharWaitL (XonTimeoutSec)) == 0) |
|
386 { |
|
387 //-- XON character sending timeout. Ignore. |
|
388 //-- PIA-58ELQK defect fix by Dmitry Lyokhin 26.03.2001 |
|
389 //return (KFaxNoClass2Xon); |
|
390 break; |
|
391 } |
|
392 |
|
393 if (iModem->iReadone[0] == Kxon) |
|
394 break; |
|
395 } |
|
396 return (TxStartPageL ()); |
|
397 } |
|
398 /********************************************************************/ |
|
399 |
|
400 // |
|
401 // TxPostPage should return either with |
|
402 // |
|
403 // a) an error code and iPhase set to RFax::EPostPageStatus, in which case the send returns with the error |
|
404 // b) KErrNone and iPhase set to RFax::EDataTransfer, in which case we send the next page |
|
405 // c) KErrNone and iPhase set to RFax::EDisconnection, in which case the send returns with KErrNone |
|
406 // |
|
407 |
|
408 TInt CFaxClass2::TxPostPageL () |
|
409 { |
|
410 |
|
411 iModem->iTransmitBuffer.Append (Kdle); |
|
412 iModem->iTransmitBuffer.Append (Ketx); |
|
413 iModem->CommitTransmitBufferL (); |
|
414 |
|
415 iModem->iOurMessage.Format (_L8 ("<dle><etx> transmitted after %d lines"), iModem->iProgress.iLines); |
|
416 |
|
417 __FLOG_FAXSRV(iModem->iOurMessage); |
|
418 |
|
419 iModem->iProgress.iPhase = EPostPageStatus; |
|
420 iModem->ProgressUpdateL (); |
|
421 while (iModem->Txstat () != 0) |
|
422 ; |
|
423 |
|
424 // we've just ended phase C data, so we need to wait for the modem to respond with OK |
|
425 |
|
426 |
|
427 |
|
428 if (iModem->GetMatchL (_L8 ("OK"), (32 * 1024) / (iModem->iProgress.iSpeed / 10)) == 0) |
|
429 return (KFaxErrCannotEndData); |
|
430 |
|
431 iModem->Xonoff (); |
|
432 |
|
433 if (iFaxServerSessionSettings->iTxPages == iModem->iProgress.iPage) |
|
434 { |
|
435 iModem->ExportL (_L8 ("AT+FET=2\r")); |
|
436 iModem->iOurMessage.Format (_L8 ("End of document transmitted EOP frame")); |
|
437 } |
|
438 else |
|
439 { |
|
440 iModem->ExportL (_L8 ("AT+FET=0\r")); |
|
441 iModem->iOurMessage.Format (_L8 ("End of page %u transmitted MPS frame"), iModem->iProgress.iPage); |
|
442 } |
|
443 iModem->ProgressUpdateL (); |
|
444 |
|
445 for (;;) |
|
446 { |
|
447 |
|
448 //#if defined (__WINS__) |
|
449 // RDebug::Print(_L("NOW")); |
|
450 //#endif |
|
451 |
|
452 |
|
453 if (!(iModem->ImportL (iResults, 30))) |
|
454 { |
|
455 return (KFaxErrModemResponse); |
|
456 } |
|
457 |
|
458 iModem->iOurMessage.Format (_L8 ("%S"), &iResults); |
|
459 iModem->ProgressUpdateL (); |
|
460 |
|
461 if ((iResults.FindF (_L8 ("FHNG"))) >= 0) |
|
462 { |
|
463 if (iResults[7] == '0') |
|
464 break; |
|
465 return (KFaxErrNoNegotiate); |
|
466 } |
|
467 |
|
468 if ((iResults.FindF (_L8 ("FPTS"))) >= 0) |
|
469 { |
|
470 |
|
471 if (iResults.FindF (_L8("1"))==6) // 6 is the position of the error code in descriptor |
|
472 { |
|
473 iModem->iOurMessage.Append (_L8("FPTS:1 MCF frame")); |
|
474 iModem->ProgressUpdateL (); |
|
475 break; |
|
476 } |
|
477 else if (iResults.FindF(_L8("2"))==6) |
|
478 { |
|
479 iModem->iOurMessage.Append (_L8("FPTS:2 RTN frame")); |
|
480 iModem->ProgressUpdateL (); |
|
481 break; |
|
482 } |
|
483 else if (iResults.FindF(_L8("3"))==6) |
|
484 { |
|
485 iModem->iOurMessage.Append (_L8("FPTS:3 RTP frame")); |
|
486 iModem->ProgressUpdateL (); |
|
487 break; |
|
488 } |
|
489 else if (iResults.FindF(_L8("4"))==6) |
|
490 { |
|
491 iModem->iOurMessage.Append (_L8("FPTS:4 PIN frame")); |
|
492 iModem->ProgressUpdateL (); |
|
493 break; |
|
494 } |
|
495 else if (iResults.FindF(_L8("5"))==6) |
|
496 { |
|
497 iModem->iOurMessage.Append (_L8("FPTS:5 PIP frame")); |
|
498 iModem->ProgressUpdateL (); |
|
499 break; |
|
500 } |
|
501 break; |
|
502 |
|
503 } |
|
504 } // for(;;) ends here |
|
505 |
|
506 if (iModem->GetMatchL (_L8 ("OK"), 5) == 0) |
|
507 return (KFaxErrNoFinalOK); |
|
508 |
|
509 if ((((iResults.FindF (_L8 ("2"))) >= 0) || (iResults.FindF (_L8 ("4")) >= 0)) && (iRepeatPage <= 3)) //RTN and |
|
510 { //PIN responses |
|
511 iModem->iProgress.iPhase = ESessionNegotiation; |
|
512 iRepeatPage++; |
|
513 iModem->iProgress.iPage--; |
|
514 return (TxPrePageL ()); |
|
515 } |
|
516 if (iFaxServerSessionSettings->iTxPages != iModem->iProgress.iPage) |
|
517 { |
|
518 iRepeatPage = 0; |
|
519 return (TxPrePageL ()); |
|
520 } |
|
521 iModem->iProgress.iPhase = EDisconnection; |
|
522 return (KErrNone); |
|
523 } |
|
524 /********************************************************************/ |
|
525 |
|
526 // this routine parses both class 2 and class 2.0 |
|
527 // T.30 session subparameter strings, from both interrogatories |
|
528 // and reports - for interrogatories, we assume that later capabilities |
|
529 // (inside the brackets) are preferable to earlier ones |
|
530 |
|
531 // amended July 1998 to support ECM for class 2.0 |
|
532 |
|
533 void CFaxClass2::ParseResults (TDesC8 & aResults) |
|
534 { |
|
535 TInt x, field, inbracket; |
|
536 static const TInt minscans[][2] = |
|
537 { |
|
538 {0, 0 |
|
539 }, |
|
540 {5, 5 |
|
541 }, |
|
542 {10, 5 |
|
543 }, |
|
544 {10, 10 |
|
545 }, |
|
546 {20, 10 |
|
547 }, |
|
548 {20, 20 |
|
549 }, |
|
550 {40, 20 |
|
551 }, |
|
552 {40, 40 |
|
553 } |
|
554 }; |
|
555 |
|
556 for ( x = 0, field = 0, inbracket = 0; x < aResults.Length (); x++) |
|
557 { |
|
558 if ((aResults[x] > '0' - 1) && (aResults[x] < '9' + 1)) |
|
559 { |
|
560 if (field == 0) |
|
561 iModem->iProgress.iResolution = TFaxResolution (aResults[x] & 1); |
|
562 else if (field == 1) |
|
563 iModem->iProgress.iSpeed = (aResults[x] - '0' + 1) * 2400; |
|
564 else if (field == 4) |
|
565 iModem->iProgress.iCompression = TFaxCompression (aResults[x] & 1); |
|
566 else if (field == 5) |
|
567 iModem->iProgress.iECM = (aResults[x] - '0'); |
|
568 else if (field == 7) |
|
569 { |
|
570 iMinscan = minscans[aResults[x] - '0'][iModem->iProgress.iResolution]; |
|
571 if (iMinscan == 0) |
|
572 iMinlinelength = 0; |
|
573 else |
|
574 iMinlinelength = ((iModem->iProgress.iSpeed / (1000 / iMinscan)) / 8) + 1; |
|
575 } |
|
576 } |
|
577 if (aResults[x] == 0) |
|
578 break; |
|
579 if (aResults[x] == 0x28) |
|
580 inbracket = 1; |
|
581 if (aResults[x] == 0x29) |
|
582 inbracket = 0; |
|
583 if ((aResults[x] == 0x2c) && (inbracket == 0)) |
|
584 field++; |
|
585 if (field == 8) |
|
586 break; |
|
587 } |
|
588 if (iFaxServerSessionSettings->iFaxClass == EClass2) |
|
589 iModem->iProgress.iECM = 0; // no ECM using class 2 |
|
590 if (iModem->iProgress.iECM) |
|
591 iModem->iProgress.iECM = 1; // and treat EC as a boolean |
|
592 } |
|
593 /********************************************************************/ |
|
594 |
|
595 // this routine extract an ID string from a result code |
|
596 |
|
597 void CFaxClass2::ExtractAnswerback (TDesC8 & aResults) |
|
598 { |
|
599 TInt startID = aResults.Locate (0x22); |
|
600 if (startID != KErrNotFound) |
|
601 { |
|
602 startID++; |
|
603 TInt maxIDlength = (aResults.Length () - startID); |
|
604 if (maxIDlength > 20) |
|
605 maxIDlength = 20; |
|
606 iModem->iProgress.iAnswerback.Copy (aResults.Mid (startID, maxIDlength)); |
|
607 } |
|
608 } |
|
609 /********************************************************************/ |