2046 FlowControlSuspend(); // Defect fix for MPO-4ZECUN |
2049 FlowControlSuspend(); // Defect fix for MPO-4ZECUN |
2047 iQuickInit->StartQuickInit(); |
2050 iQuickInit->StartQuickInit(); |
2048 ReqCompleted(aTsyReqHandle,KErrNone); |
2051 ReqCompleted(aTsyReqHandle,KErrNone); |
2049 return KErrNone; |
2052 return KErrNone; |
2050 } |
2053 } |
|
2054 |
|
2055 // local function needed below |
|
2056 |
|
2057 LOCAL_C void SetFaxSessionSettings(RCall::TFaxSessionSettings& aTrg, const RCall::TFaxSessionSettings& aSrc) |
|
2058 { |
|
2059 aTrg.iMode=aSrc.iMode; |
|
2060 aTrg.iFaxRetrieveType=aSrc.iFaxRetrieveType; |
|
2061 aTrg.iFaxClass=aSrc.iFaxClass; |
|
2062 aTrg.iFaxId=aSrc.iFaxId; |
|
2063 aTrg.iMaxSpeed=aSrc.iMaxSpeed; |
|
2064 aTrg.iMinSpeed=aSrc.iMinSpeed; |
|
2065 aTrg.iPreferredECM=aSrc.iPreferredECM; |
|
2066 aTrg.iFaxOnDemandDelay=aSrc.iFaxOnDemandDelay; |
|
2067 aTrg.iTxResolution=aSrc.iTxResolution; |
|
2068 aTrg.iTxCompression=aSrc.iTxCompression; |
|
2069 aTrg.iTxPages=aSrc.iTxPages; |
|
2070 aTrg.iRxResolution=aSrc.iRxResolution; |
|
2071 aTrg.iRxResolution=aSrc.iRxResolution; |
|
2072 } |
|
2073 |
|
2074 // |
|
2075 // CCallMobileFax - fax call functionality |
|
2076 // At construction, phone init sequence may not have yet determined phone's capabilities so |
|
2077 // create object anyway and check in the function calls whether fax is supported by phone |
|
2078 // |
|
2079 |
|
2080 CCallMobileFax* CCallMobileFax::NewL(CATIO* aATIO,CATInit* aInit,CPhoneGlobals* aPhoneGlobals,const TName& aName) |
|
2081 { |
|
2082 CCallMobileFax* faxCall=new(ELeave) CCallMobileFax(aATIO,aInit,aPhoneGlobals); |
|
2083 TCleanupItem newCallFaxHayesClose(CloseCall,faxCall); |
|
2084 CleanupStack::PushL(newCallFaxHayesClose); |
|
2085 faxCall->ConstructL(aName); |
|
2086 CleanupStack::Pop(); |
|
2087 return faxCall; |
|
2088 } |
|
2089 |
|
2090 CCallMobileFax::CCallMobileFax(CATIO* aATIO,CATInit* aInit,CPhoneGlobals* aPhoneGlobals) |
|
2091 : CCallMobile(aATIO,aInit,aPhoneGlobals),iFaxSession(NULL),iFax(NULL) |
|
2092 {} |
|
2093 |
|
2094 void CCallMobileFax::ConstructL(const TName& aName) |
|
2095 { |
|
2096 CCallHayes::ConstructL(aName); |
|
2097 iCallInfo.iLineOwnerName = KFaxLineName; |
|
2098 iDialFax=CATDialFax::NewL(iIo,this,iInit,iPhoneGlobals); |
|
2099 iConnectFax=CATConnectFax::NewL(iIo,this,iInit,iPhoneGlobals); |
|
2100 iAnswerFax=CATAnswerFax::NewL(iIo,this,iInit,iPhoneGlobals); |
|
2101 iHangUpFax=CATHangUpFax::NewL(iIo,this,iInit,iPhoneGlobals); |
|
2102 iFaxSettings.iMode = RCall::ETransmit; |
|
2103 iFaxSettings.iFaxRetrieveType = RCall::EFaxOnDemand; |
|
2104 iFaxSettings.iFaxClass = EClassAuto; |
|
2105 iFaxSettings.iMaxSpeed = 9600; |
|
2106 iFaxSettings.iMinSpeed = 2400; |
|
2107 iFaxSettings.iPreferredECM = EFalse; |
|
2108 iFaxSettings.iFaxOnDemandDelay = 20; |
|
2109 iFaxSettings.iTxResolution = EFaxNormal; |
|
2110 iFaxSettings.iTxCompression = EModifiedHuffman; |
|
2111 iFaxSettings.iTxPages = 0; |
|
2112 iFaxSettings.iRxResolution = EFaxNormal; |
|
2113 iFaxSettings.iRxCompression = EModifiedHuffman; |
|
2114 iFaxCompletion = new (ELeave) CFaxCompletion(); |
|
2115 iFaxProgress=CreateFaxProgressChunk(); |
|
2116 if(iFaxProgress==NULL) |
|
2117 User::Leave(KErrEtelFaxChunkNotCreated); |
|
2118 } |
|
2119 |
|
2120 CCallMobileFax::~CCallMobileFax() |
|
2121 // |
|
2122 // Removes itself from array of calls in CLineMobileData |
|
2123 // |
|
2124 { |
|
2125 __ASSERT_DEBUG(iFaxSession==NULL,Panic(EFaxServerNotNull)); |
|
2126 DeleteFaxProgressChunk(); // This deallocates the memory pointed to by iFaxProgress |
|
2127 delete iDialFax; |
|
2128 delete iConnectFax; |
|
2129 delete iAnswerFax; |
|
2130 delete iHangUpFax; |
|
2131 delete iFaxCompletion; |
|
2132 delete iFileHandles; |
|
2133 } |
|
2134 |
|
2135 void CCallMobileFax::CollateCoreCaps(const TTsyReqHandle aTsyReqHandle, TUint32* aCallCaps) |
|
2136 { |
|
2137 *aCallCaps = RCall::KCapsFax; |
|
2138 if (ValidateFaxClass(iFaxSettings.iFaxClass)==KErrNone |
|
2139 && (!(REINTERPRET_CAST(CLineMobileFax*,Owner())->iFaxOpened==TRUE && iFax==NULL)) |
|
2140 && iPhoneGlobals->iPhoneStatus.iModemDetected==RPhone::EDetectedPresent) |
|
2141 // check that fax class is OK and that no other fax call has opened a fax object |
|
2142 { |
|
2143 TCallOwnership owner = CheckOwnership(aTsyReqHandle); |
|
2144 if (ValidateRequest(aTsyReqHandle,RCall::EStatusIdle)==KErrNone) |
|
2145 *aCallCaps |= (RCall::KCapsDial | RCall::KCapsConnect); |
|
2146 TInt ret=KErrNone; |
|
2147 if (owner==CCallBase::EOwnedFalse) // call owned by another client |
|
2148 ret=KErrEtelNotCallOwner; |
|
2149 else |
|
2150 { |
|
2151 if (!iIsForIncomingCall) |
|
2152 { |
|
2153 if (REINTERPRET_CAST(CPhoneHayes*,Owner()->Owner())->CheckForOutstandingAnswer()) |
|
2154 ret=KErrEtelAnswerAlreadyOutstanding; |
|
2155 } |
|
2156 else |
|
2157 ret=KErrEtelAnswerAlreadyOutstanding; |
|
2158 } |
|
2159 if (ret==KErrNone && (iCallInfo.iMobileStatus==RMobileCall::EStatusIdle || iCallInfo.iMobileStatus==RMobileCall::EStatusRinging)) |
|
2160 *aCallCaps |= RCall::KCapsAnswer; |
|
2161 if (owner==CCallBase::EOwnedTrue && iCallInfo.iMobileStatus==RMobileCall::EStatusConnected) |
|
2162 { |
|
2163 *aCallCaps |= RCall::KCapsHangUp; |
|
2164 } |
|
2165 } |
|
2166 } |
|
2167 |
|
2168 TInt CCallMobileFax::OpenFax(TDesC* aTelNumber,TFaxMode aFaxMode) |
|
2169 // |
|
2170 // Open CETelFaxHayes object with desired settings |
|
2171 // |
|
2172 { |
|
2173 TFaxServerSessionSettings faxSettings; |
|
2174 faxSettings.iPhoneNumber.Copy(*aTelNumber); |
|
2175 faxSettings.iLogging = ETrue; |
|
2176 TInt ret = iPhoneGlobals->iConfiguration->ConfigModemString(TPtrC(KCDTypeNameFaxInitString),faxSettings.iFaxInitString); |
|
2177 if (!ret) |
|
2178 { |
|
2179 ret = iPhoneGlobals->iConfiguration->ConfigModemString(TPtrC(KCDTypeNameCsyName),faxSettings.iPortDriverName); |
|
2180 } |
|
2181 if (!ret) |
|
2182 { |
|
2183 ret = iPhoneGlobals->iConfiguration->ConfigModemString(TPtrC(KCDTypeNamePortName),faxSettings.iCommPortName); |
|
2184 } |
|
2185 if (ret) |
|
2186 return ret; |
|
2187 if(faxSettings.iFaxInitString.Length()==0) |
|
2188 faxSettings.iFaxInitString=KAT2Command; |
|
2189 faxSettings.iMode = aFaxMode; |
|
2190 faxSettings.iFaxClass = iFaxSettings.iFaxClass; |
|
2191 faxSettings.iFaxId = iFaxSettings.iFaxId; |
|
2192 faxSettings.iMaxSpeed = iFaxSettings.iMaxSpeed; |
|
2193 faxSettings.iMinSpeed = iFaxSettings.iMinSpeed; |
|
2194 faxSettings.iPreferredECM = iFaxSettings.iPreferredECM; |
|
2195 faxSettings.iFaxOnDemandDelay = iFaxSettings.iFaxOnDemandDelay; |
|
2196 faxSettings.iTxResolution = iFaxSettings.iTxResolution; |
|
2197 faxSettings.iTxCompression = iFaxSettings.iTxCompression; |
|
2198 faxSettings.iTxPages = iFaxSettings.iTxPages; |
|
2199 faxSettings.iRxResolution = iFaxSettings.iRxResolution; |
|
2200 faxSettings.iRxCompression = iFaxSettings.iRxCompression; |
|
2201 return iFaxSession->FxOpen(faxSettings,iFaxProgress); |
|
2202 } |
|
2203 |
|
2204 TInt CCallMobileFax::ValidateFaxClass(TFaxClass& aFaxClass) |
|
2205 { |
|
2206 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & KFaxCaps) == 0) |
|
2207 { |
|
2208 return KErrNotSupported; |
|
2209 } |
|
2210 switch (aFaxClass) |
|
2211 { |
|
2212 case EClassAuto: // TSY decides what class "AUTO" refers to! |
|
2213 { |
|
2214 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassTwoPointZero)) |
|
2215 aFaxClass = EClass2point0; |
|
2216 else if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassTwo)) |
|
2217 aFaxClass = EClass2; |
|
2218 else if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassOne)) |
|
2219 aFaxClass = EClass1; |
|
2220 break; |
|
2221 } |
|
2222 case EClass1: |
|
2223 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassOne)==0) |
|
2224 return KErrEtelWrongModemType; |
|
2225 break; |
|
2226 case EClass1point0: |
|
2227 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassOnePointZero)==0) |
|
2228 return KErrEtelWrongModemType; |
|
2229 break; |
|
2230 case EClass2: |
|
2231 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassTwo)==0) |
|
2232 return KErrEtelWrongModemType; |
|
2233 break; |
|
2234 case EClass2point0: |
|
2235 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassTwoPointZero)==0) |
|
2236 return KErrEtelWrongModemType; |
|
2237 break; |
|
2238 case EClass2point1: |
|
2239 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & RPhone::KCapsFaxClassTwoPointOne)==0) |
|
2240 return KErrEtelWrongModemType; |
|
2241 break; |
|
2242 default: |
|
2243 return KErrEtelWrongModemType; |
|
2244 } |
|
2245 return KErrNone; |
|
2246 } |
|
2247 |
|
2248 typedef CFaxSession* (*TFaxServerEntry)(); |
|
2249 void CCallMobileFax::GetFaxBaseL() |
|
2250 { |
|
2251 __ASSERT_DEBUG(iFaxCompletion,Panic(EFaxCompletionPtrNull)); |
|
2252 RFs fs; |
|
2253 (void)User::LeaveIfError(fs.Connect()); |
|
2254 |
|
2255 TInt r=iFaxServerLib.Load(KFaxServerName); |
|
2256 if (r==KErrNone) |
|
2257 { |
|
2258 // Check the Uid2 |
|
2259 #if defined (_UNICODE) |
|
2260 if(iFaxServerLib.Type()[1]!=TUid::Uid(KUidUnicodeDynamicFaxServer)) |
|
2261 r = KErrBadLibraryEntryPoint; |
|
2262 #else |
|
2263 if(iFaxServerLib.Type()[1]!=TUid::Uid(KUidDynamicFaxServer)) |
|
2264 r = KErrBadLibraryEntryPoint; |
|
2265 #endif |
|
2266 if (r==KErrNone) |
|
2267 { |
|
2268 TFaxServerEntry libEntry=(TFaxServerEntry)iFaxServerLib.Lookup(1); |
|
2269 if (libEntry!=NULL) |
|
2270 { |
|
2271 TRAP(r,iFaxSession=(*libEntry)()); // libEntry may leave. |
|
2272 if (r==KErrNone) |
|
2273 { |
|
2274 LOGTEXT(_L8("Loaded Fax Server")); |
|
2275 iFaxSession->SetCallBack(iFaxCompletion); |
|
2276 } |
|
2277 else |
|
2278 iFaxServerLib.Close(); |
|
2279 } |
|
2280 else |
|
2281 { |
|
2282 r = KErrBadLibraryEntryPoint; |
|
2283 iFaxServerLib.Close(); |
|
2284 } |
|
2285 } |
|
2286 else |
|
2287 iFaxServerLib.Close(); |
|
2288 } |
|
2289 fs.Close(); |
|
2290 (void)User::LeaveIfError(r); |
|
2291 } |
|
2292 |
|
2293 TInt CCallMobileFax::FaxConnectHandler(const TTsyReqHandle aTsyReqHandle) |
|
2294 { |
|
2295 TInt ret = ValidateFaxClass(iFaxSettings.iFaxClass); |
|
2296 if (ret!=KErrNone) |
|
2297 { |
|
2298 (void)SetUnowned(); |
|
2299 ReqCompleted(aTsyReqHandle,ret); |
|
2300 return ret; |
|
2301 } |
|
2302 if (REINTERPRET_CAST(CLineMobileFax*,Owner())->iFaxOpened==TRUE && iFax==NULL) |
|
2303 { |
|
2304 (void)SetUnowned(); |
|
2305 ReqCompleted(aTsyReqHandle,KErrEtelNotFaxOwner); |
|
2306 return ret; |
|
2307 } |
|
2308 |
|
2309 TRAPD(res,GetFaxBaseL()); |
|
2310 if (res!=KErrNone) |
|
2311 { |
|
2312 (void)SetUnowned(); |
|
2313 ReqCompleted(aTsyReqHandle,res); |
|
2314 } |
|
2315 iPhoneGlobals->iEventSignalActive = EFalse; |
|
2316 return res; |
|
2317 } |
|
2318 |
|
2319 void CCallMobileFax::FaxDial(const TTsyReqHandle aTsyReqHandle,TDesC* aTelNumber) |
|
2320 // |
|
2321 // Called once any initialising has been done. Checks here that modem supports fax, |
|
2322 // and that no other CCallHayes has opened a fax object |
|
2323 // |
|
2324 { |
|
2325 if (FaxConnectHandler(aTsyReqHandle)!=KErrNone) // ReqCompleted is called inside FaxConnectHandler |
|
2326 // if there is an error |
|
2327 return; |
|
2328 TFaxMode faxMode; |
|
2329 if (iFaxSettings.iMode==RCall::ETransmit) |
|
2330 { |
|
2331 faxMode = EDialAndTransmit; |
|
2332 } |
|
2333 else // we're receiving |
|
2334 { |
|
2335 if (iFaxSettings.iFaxRetrieveType==RCall::EFaxPoll) |
|
2336 faxMode = EDialAndReceivePoll; |
|
2337 else |
|
2338 faxMode = EDialAndReceiveFaxBack; |
|
2339 } |
|
2340 TInt res = OpenFax(aTelNumber,faxMode); |
|
2341 if (res!=KErrNone) // make sure cleaned up. |
|
2342 { |
|
2343 ReqCompleted(aTsyReqHandle,res); |
|
2344 return; |
|
2345 } |
|
2346 ChangeLineStatus(RCall::EStatusDialling); |
|
2347 // EStatusDialling always results in KErrNone return |
|
2348 (void) ChangeCallStatus(RMobileCall::EStatusDialling); |
|
2349 iPhoneGlobals->iNotificationStore->CheckNotification(this,EBegunConnecting); |
|
2350 iFaxCompletion->Configure(aTsyReqHandle,this); |
|
2351 iIo->Cancel(); |
|
2352 iPhoneGlobals->iPhoneStatus.iPortAccess = EPortAccessDenied; // so CATIO won't queue a read |
|
2353 |
|
2354 if (faxMode == EDialAndTransmit) |
|
2355 { |
|
2356 LOGTEXT(_L8("About to call CETelFaxBase::TxConnect")); |
|
2357 //this transfers ownership of the file handles object to the fax session object. |
|
2358 iFaxSession->SetFaxHeaderFile(iFileHandles); |
|
2359 //we now aren't resonsible for its deletion. |
|
2360 iFileHandles = NULL; |
|
2361 iFaxSession->TxConnect(); |
|
2362 } |
|
2363 else |
|
2364 { |
|
2365 LOGTEXT(_L8("About to call CETelFaxBase::RxConnect")); |
|
2366 iFaxSession->RxConnect(); |
|
2367 } |
|
2368 } |
|
2369 |
|
2370 TInt CCallMobileFax::Dial(const TTsyReqHandle aTsyReqHandle,const TDesC8* aCallParams,TDesC* aTelNumber) |
|
2371 // |
|
2372 // Dial a fax call |
|
2373 // Check that call is not owned by another client, and line is idle |
|
2374 // |
|
2375 { |
|
2376 TInt ret = ValidateRequest(aTsyReqHandle,RCall::EStatusIdle); |
|
2377 if (ret==KErrNone) |
|
2378 { |
|
2379 (void)SetOwnership(aTsyReqHandle); |
|
2380 SetCallParams(aCallParams); |
|
2381 LOGTEXT(_L8("FaxCall:\tSubmitting Dial Command")); |
|
2382 iDialFax->ExecuteCommand(aTsyReqHandle,aTelNumber,&iCallInfo); |
|
2383 } |
|
2384 else |
|
2385 ReqCompleted(aTsyReqHandle,ret); |
|
2386 return KErrNone; |
|
2387 } |
|
2388 |
|
2389 void CCallMobileFax::FaxCancelCommand(const TTsyReqHandle aTsyReqHandle) |
|
2390 // |
|
2391 // Cancels the fax session (for ConnectCancel and AnswerCancel as well) |
|
2392 // |
|
2393 { |
|
2394 LOGTEXT(_L8("FaxCall:\tCancel Fax call and Unload module")); |
|
2395 if(!iFaxSession) // if iFaxSession is NULL |
|
2396 { // then CleanUpFaxServer has already been called |
|
2397 LOGTEXT(_L8("FaxCall:\tModule already unloaded, completing...")); |
|
2398 ReqCompleted(aTsyReqHandle,KErrCancel); // so return without further processing |
|
2399 return; |
|
2400 } |
|
2401 |
|
2402 LOGTEXT(_L8("FaxCall:\tClosing down fax server module")); |
|
2403 iFaxSession->Cancel(); |
|
2404 CleanUpFaxServer(); |
|
2405 iIo->Read(); |
|
2406 SetToIdle(); |
|
2407 ReqCompleted(aTsyReqHandle,KErrCancel); |
|
2408 } |
|
2409 |
|
2410 TInt CCallMobileFax::DialCancel(const TTsyReqHandle aTsyReqHandle) |
|
2411 { |
|
2412 LOGTEXT2(_L8("FaxCall:\tDialCancel(%d) called"),aTsyReqHandle); |
|
2413 iDialFax->CancelCommand(aTsyReqHandle); |
|
2414 return KErrNone; |
|
2415 } |
|
2416 |
|
2417 void CCallMobileFax::FaxConnect(const TTsyReqHandle aTsyReqHandle) |
|
2418 // |
|
2419 // Called once any initialising has been done. Checks here that modem supports fax. |
|
2420 // |
|
2421 { |
|
2422 if (FaxConnectHandler(aTsyReqHandle)!=KErrNone) |
|
2423 return; |
|
2424 TFaxMode faxMode; |
|
2425 if (iFaxSettings.iMode==RCall::ETransmit) |
|
2426 faxMode = EImmediateTransmit; |
|
2427 else |
|
2428 faxMode = EImmediateReceive; |
|
2429 TBuf<1> null; |
|
2430 null.Zero(); |
|
2431 TInt res = OpenFax(&null,faxMode); |
|
2432 if (res!=KErrNone) |
|
2433 { |
|
2434 ReqCompleted(aTsyReqHandle,res); |
|
2435 return; |
|
2436 } |
|
2437 ChangeLineStatus(RCall::EStatusConnecting); |
|
2438 // EStatusConnecting always returns KErrNone |
|
2439 (void)ChangeCallStatus(RMobileCall::EStatusConnecting); |
|
2440 iPhoneGlobals->iNotificationStore->CheckNotification(this,EBegunConnecting); |
|
2441 iFaxCompletion->Configure(aTsyReqHandle,this); |
|
2442 iIo->Cancel(); |
|
2443 iPhoneGlobals->iPhoneStatus.iPortAccess = EPortAccessDenied; // so CATIO won't queue a read |
|
2444 if (faxMode == EImmediateTransmit) |
|
2445 iFaxSession->TxConnect(); |
|
2446 else |
|
2447 iFaxSession->RxConnect(); |
|
2448 } |
|
2449 |
|
2450 TInt CCallMobileFax::Connect(const TTsyReqHandle aTsyReqHandle,const TDesC8* aCallParams) |
|
2451 // |
|
2452 // Immediate connect to a fax call |
|
2453 // Check that call is not owned by another client, and line is idle |
|
2454 // |
|
2455 { |
|
2456 TInt ret = ValidateRequest(aTsyReqHandle,RCall::EStatusIdle); |
|
2457 if (ret==KErrNone) |
|
2458 { |
|
2459 (void)SetOwnership(aTsyReqHandle); |
|
2460 SetCallParams(aCallParams); |
|
2461 LOGTEXT(_L8("FaxCall:\tSubmitting Connect Command")); |
|
2462 iConnectFax->ExecuteCommand(aTsyReqHandle,NULL,&iCallInfo); |
|
2463 } |
|
2464 else |
|
2465 ReqCompleted(aTsyReqHandle,ret); |
|
2466 return KErrNone; |
|
2467 } |
|
2468 |
|
2469 TInt CCallMobileFax::ConnectCancel(const TTsyReqHandle aTsyReqHandle) |
|
2470 { |
|
2471 LOGTEXT2(_L8("FaxCall:\tConnectCancel(%d) called"),aTsyReqHandle); |
|
2472 iConnectFax->CancelCommand(aTsyReqHandle); |
|
2473 return KErrNone; |
|
2474 } |
|
2475 |
|
2476 void CCallMobileFax::FaxAnswer(const TTsyReqHandle aTsyReqHandle) |
|
2477 { |
|
2478 if (FaxConnectHandler(aTsyReqHandle)!=KErrNone) |
|
2479 return; |
|
2480 TFaxMode faxMode; |
|
2481 if (iFaxSettings.iMode==RCall::ETransmit) |
|
2482 faxMode = EWaitForRingAndTransmit; |
|
2483 else |
|
2484 faxMode = EWaitForRingAndReceive; |
|
2485 TBuf<1> null; |
|
2486 null.Zero(); |
|
2487 TInt res = OpenFax(&null,faxMode); |
|
2488 if (res!=KErrNone) |
|
2489 { |
|
2490 ReqCompleted(aTsyReqHandle,res); |
|
2491 return; |
|
2492 } |
|
2493 LOGTEXT(_L8("FaxCall:\tAnswering Fax call")); |
|
2494 ChangeLineStatus(RCall::EStatusAnswering); |
|
2495 // EStatusAnswering always results in KerrNone return |
|
2496 (void)ChangeCallStatus(RMobileCall::EStatusAnswering); |
|
2497 CPhoneHayes* phone=STATIC_CAST(CPhoneHayes*,Owner()->Owner()); |
|
2498 phone->StopRingCounter(); // RING should no longer come in |
|
2499 iPhoneGlobals->iNotificationStore->CheckNotification(this,EBegunConnecting); |
|
2500 iFaxCompletion->Configure(aTsyReqHandle,this); |
|
2501 iIo->Cancel(); |
|
2502 iPhoneGlobals->iPhoneStatus.iPortAccess = EPortAccessDenied; // so CATIO won't queue a read |
|
2503 if (faxMode == EWaitForRingAndTransmit) |
|
2504 iFaxSession->TxConnect(); |
|
2505 else |
|
2506 iFaxSession->RxConnect(); |
|
2507 } |
|
2508 |
|
2509 TInt CCallMobileFax::AnswerIncomingCall(const TTsyReqHandle aTsyReqHandle,const TDesC8* aCallParams) |
|
2510 // |
|
2511 // Answer a fax call |
|
2512 // |
|
2513 { |
|
2514 TInt ret=KErrNone; |
|
2515 CCallBase::TCallOwnership owned = CheckOwnership(aTsyReqHandle); |
|
2516 if (owned==CCallBase::EOwnedFalse) // call owned by another client |
|
2517 { |
|
2518 ret=KErrEtelNotCallOwner; |
|
2519 } |
|
2520 else if (REINTERPRET_CAST(CPhoneHayes*,Owner()->Owner())->CheckForOutstandingAnswer()) |
|
2521 ret=KErrEtelAnswerAlreadyOutstanding; |
|
2522 |
|
2523 if (ret==KErrNone) |
|
2524 { |
|
2525 CLineHayes* line = STATIC_CAST(CLineHayes*,Owner()); |
|
2526 CPhoneHayes* phone=STATIC_CAST(CPhoneHayes*,line->Owner()); |
|
2527 phone->CancelOtherRingingCall(line); |
|
2528 line->FreePreAllocCallIfNecessary(); |
|
2529 SetCallParams(aCallParams); |
|
2530 if (iCallInfo.iMobileStatus==RMobileCall::EStatusRinging) |
|
2531 { |
|
2532 LOGTEXT(_L8("FaxCall:\tSubmitting Answer Command")); |
|
2533 iAnswerFax->ExecuteCommand(aTsyReqHandle,NULL,&iCallInfo); |
|
2534 } |
|
2535 else // This call is now a client-designated Incoming Call object. |
|
2536 { |
|
2537 iIsForIncomingCall=ETrue; |
|
2538 iAnswerTsyReqHandle = aTsyReqHandle; |
|
2539 } |
|
2540 return KErrNone; |
|
2541 } |
|
2542 ReqCompleted(aTsyReqHandle,ret); |
|
2543 return KErrNone; |
|
2544 } |
|
2545 |
|
2546 TInt CCallMobileFax::AnswerIncomingCallCancel(const TTsyReqHandle aTsyReqHandle) |
|
2547 // |
|
2548 // Cancel the answer command if possible |
|
2549 // |
|
2550 { |
|
2551 LOGTEXT2(_L8("FaxCall:\tAnswerCancel(%d) called"),aTsyReqHandle); |
|
2552 if (iIsForIncomingCall) |
|
2553 { |
|
2554 iIsForIncomingCall=EFalse; |
|
2555 ReqCompleted(aTsyReqHandle,KErrCancel); |
|
2556 } |
|
2557 else |
|
2558 iAnswerFax->CancelCommand(aTsyReqHandle); |
|
2559 return KErrNone; |
|
2560 } |
|
2561 |
|
2562 void CCallMobileFax::AnswerImmediately() |
|
2563 { |
|
2564 (void)SetOwnership(iAnswerTsyReqHandle); |
|
2565 // EStatusRinging always results in KErrNone return |
|
2566 (void)ChangeCallStatus(RMobileCall::EStatusRinging);// new 14/1/99 |
|
2567 iPhoneGlobals->iNotificationStore->CheckNotification(this,ERingOccurred); |
|
2568 iIsForIncomingCall=EFalse; |
|
2569 LOGTEXT(_L8("FaxCall:\tSubmitting Answer command")); |
|
2570 iAnswerFax->ExecuteCommand(iAnswerTsyReqHandle,NULL,&iCallInfo); |
|
2571 } |
|
2572 |
|
2573 void CCallMobileFax::FaxHangUp(const TTsyReqHandle aTsyReqHandle) |
|
2574 // |
|
2575 // Fax server reconfigures port so no need to here. |
|
2576 // |
|
2577 { |
|
2578 if (iFaxSession) |
|
2579 { |
|
2580 // EStatusDisconnecting always results in KErrNone return |
|
2581 (void)ChangeCallStatus(RMobileCall::EStatusDisconnecting); |
|
2582 ChangeLineStatus(RCall::EStatusHangingUp); |
|
2583 iPhoneGlobals->iNotificationStore->CheckNotification(this,EBegunHangingUp); |
|
2584 CleanUpFaxServer(); |
|
2585 iIo->Read(); |
|
2586 SetToIdle(); |
|
2587 } |
|
2588 ReqCompleted(aTsyReqHandle,KErrNone); |
|
2589 } |
|
2590 |
|
2591 TInt CCallMobileFax::HangUp(const TTsyReqHandle aTsyReqHandle) |
|
2592 // |
|
2593 // Terminate a fax call. Checks fax capability, call ownership and line status. |
|
2594 // |
|
2595 { |
|
2596 if ((iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags & KFaxCaps) == 0) |
|
2597 { |
|
2598 ReqCompleted(aTsyReqHandle,KErrNotSupported); |
|
2599 return KErrNone; |
|
2600 } |
|
2601 if (CheckOwnership(aTsyReqHandle)==CCallBase::EOwnedFalse) |
|
2602 { |
|
2603 ReqCompleted(aTsyReqHandle,KErrEtelNotCallOwner); |
|
2604 return KErrNone; |
|
2605 } |
|
2606 if (iPhoneGlobals->iPhoneStatus.iLineStatus != RCall::EStatusConnected) |
|
2607 { |
|
2608 ReqCompleted(aTsyReqHandle,KErrNone); |
|
2609 return KErrNone; |
|
2610 } |
|
2611 LOGTEXT(_L8("FaxCall:\tHanging up")); |
|
2612 iHangUpFax->ExecuteCommand(aTsyReqHandle,NULL,&iCallInfo); |
|
2613 return KErrNone; |
|
2614 } |
|
2615 |
|
2616 TInt CCallMobileFax::HangUpCancel(const TTsyReqHandle aTsyReqHandle) |
|
2617 { |
|
2618 iHangUpFax->CancelCommand(aTsyReqHandle); |
|
2619 return KErrNone; |
|
2620 } |
|
2621 |
|
2622 TInt CCallMobileFax::RelinquishOwnership() |
|
2623 // |
|
2624 // Called by server to tell TSY to either pass ownership on to another interested client |
|
2625 // or hang up immediately |
|
2626 // |
|
2627 { |
|
2628 LOGTEXT(_L8("FaxCall:\tRelinquish Ownership")); |
|
2629 if(iList->iAcquireList.IsEmpty()) |
|
2630 { |
|
2631 if (iDialFax->IsPreConnectInProgress() || |
|
2632 iConnectFax->IsPreConnectInProgress() || |
|
2633 iAnswerFax->IsPreConnectInProgress()) // fax server has not yet been started |
|
2634 { |
|
2635 iCallInfo.iClientPanicOccurred = EPanicOccurredWithoutDataPortLoan; |
|
2636 return KErrNone; |
|
2637 } |
|
2638 (void)SetUnowned(); |
|
2639 TInt ret = KErrNone; |
|
2640 if (iCallInfo.iMobileStatus==RMobileCall::EStatusDialling || |
|
2641 iCallInfo.iMobileStatus==RMobileCall::EStatusConnecting || |
|
2642 iCallInfo.iMobileStatus==RMobileCall::EStatusAnswering || |
|
2643 iCallInfo.iMobileStatus==RMobileCall::EStatusConnected || |
|
2644 iCallInfo.iMobileStatus==RMobileCall::EStatusDisconnecting |
|
2645 ) |
|
2646 { |
|
2647 LOGTEXT(_L8("FaxCall:\tHanging up")); |
|
2648 ChangeLineStatus(RCall::EStatusHangingUp); |
|
2649 // EStatusDisconnecting always results in KErrNone return |
|
2650 (void)ChangeCallStatus(RMobileCall::EStatusDisconnecting); |
|
2651 CleanUpFaxServer(); |
|
2652 ChangeLineStatus(RCall::EStatusIdle); |
|
2653 // EStatusIdle always results in KErrNone return |
|
2654 (void)ChangeCallStatus(RMobileCall::EStatusIdle); |
|
2655 iPhoneGlobals->iPhoneStatus.iMode = RPhone::EModeIdle; |
|
2656 iIo->Cancel(); |
|
2657 TCommConfig aConfigPckg; |
|
2658 TInt ret = iPhoneGlobals->iConfiguration->PortConfig(aConfigPckg,EConfigTypeInit); |
|
2659 if (ret==KErrNone) |
|
2660 ret = iIo->ConfigurePort(aConfigPckg); |
|
2661 if (ret) |
|
2662 iPhoneGlobals->iPhoneStatus.iInitStatus = EPhoneNotInitialised; |
|
2663 else |
|
2664 iIo->Read(); // should a read be queued in this case? |
|
2665 } |
|
2666 RelinquishOwnershipCompleted(ret); |
|
2667 return KErrNone; |
|
2668 } |
|
2669 CAcquireEntry* entry=iList->iAcquireList.First(); |
|
2670 if (entry) |
|
2671 { |
|
2672 (void)SetOwnership(entry->iTsyReqHandle); |
|
2673 ReqCompleted(entry->iTsyReqHandle,KErrNone); |
|
2674 iList->Remove(entry); |
|
2675 } |
|
2676 RelinquishOwnershipCompleted(KErrNone); |
|
2677 return KErrNone; |
|
2678 } |
|
2679 |
|
2680 TInt CCallMobileFax::GetFaxSettings(const TTsyReqHandle aTsyReqHandle,RCall::TFaxSessionSettings* aSettings) |
|
2681 // |
|
2682 // Which are stored privately in CCallMobileFax |
|
2683 // |
|
2684 { |
|
2685 LOGTEXT(_L8("FaxCall:\tGetting fax settings")); |
|
2686 SetFaxSessionSettings(*aSettings,iFaxSettings); |
|
2687 ReqCompleted(aTsyReqHandle,KErrNone); |
|
2688 return KErrNone; |
|
2689 } |
|
2690 |
|
2691 TInt CCallMobileFax::SetFaxSettings(const TTsyReqHandle aTsyReqHandle,const RCall::TFaxSessionSettings* aSettings) |
|
2692 { |
|
2693 LOGTEXT(_L8("FaxCall:\tSetting fax settings")); |
|
2694 TUint phoneCaps = iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags; |
|
2695 if (aSettings->iFaxClass==EClass1 && (phoneCaps&RPhone::KCapsFaxClassOne) || |
|
2696 aSettings->iFaxClass==EClass2 && (phoneCaps&RPhone::KCapsFaxClassTwo) || |
|
2697 aSettings->iFaxClass==EClass2point0 && (phoneCaps&RPhone::KCapsFaxClassTwoPointZero) || |
|
2698 aSettings->iFaxClass==EClass1point0 && (phoneCaps&RPhone::KCapsFaxClassOnePointZero) || |
|
2699 aSettings->iFaxClass==EClass2point1 && (phoneCaps&RPhone::KCapsFaxClassTwoPointOne) || |
|
2700 aSettings->iFaxClass==EClassAuto) |
|
2701 { |
|
2702 SetFaxSessionSettings(iFaxSettings,*aSettings); |
|
2703 ReqCompleted(aTsyReqHandle,KErrNone); |
|
2704 } |
|
2705 else if (iPhoneGlobals->iPhoneStatus.iInitStatus!=EPhoneInitialised) |
|
2706 ReqCompleted(aTsyReqHandle,KErrEtelUnknownModemCapability); |
|
2707 else |
|
2708 ReqCompleted(aTsyReqHandle,KErrNotSupported); |
|
2709 return KErrNone; |
|
2710 } |
|
2711 |
|
2712 TInt CCallMobileFax::SetFaxSharedHeaderFile(const TTsyReqHandle aTsyReqHandle, CFaxSharedFileHandles* aFaxSharedFileHandles) |
|
2713 { |
|
2714 //if we already own an object delete and re-point to new one. |
|
2715 if(iFileHandles) |
|
2716 { |
|
2717 delete iFileHandles; |
|
2718 iFileHandles = NULL; |
|
2719 } |
|
2720 iFileHandles = aFaxSharedFileHandles; |
|
2721 |
|
2722 ReqCompleted(aTsyReqHandle,KErrNone); |
|
2723 return KErrNone; |
|
2724 } |
|
2725 |
|
2726 CTelObject* CCallMobileFax::OpenNewObjectByNameL(const TDesC& /*aName*/) |
|
2727 // |
|
2728 // Only want one CFaxHayes object to be opened per phone. |
|
2729 // Previously only the connected call could open a CFaxHayes object, so it was easy to check |
|
2730 // whether one had already been opened. Now a fax call can open a fax object at any time |
|
2731 // making it less clear how to check that no other call has opened one. |
|
2732 // |
|
2733 { |
|
2734 if (iPhoneGlobals->iPhoneStatus.iLineStatus != GetCoreCallStatus()) |
|
2735 { // ie another fax call is in progress so this call cannot open a fax object |
|
2736 User::Leave(KErrEtelNotCallOwner); |
|
2737 } |
|
2738 TBool& faxOpened = REINTERPRET_CAST(CLineMobileFax*,Owner())->iFaxOpened; |
|
2739 if (faxOpened==TRUE) |
|
2740 { |
|
2741 User::Leave(KErrAlreadyExists); |
|
2742 } |
|
2743 faxOpened=ETrue; |
|
2744 iFax = CFaxHayes::NewL(this,iPhoneGlobals); |
|
2745 return iFax; |
|
2746 } |
|
2747 |
|
2748 void CCallMobileFax::RemoveFax(CFaxHayes* aFaxHayes) |
|
2749 { |
|
2750 if (iFax == aFaxHayes) |
|
2751 iFax=NULL; |
|
2752 REINTERPRET_CAST(CLineMobileFax*,Owner())->iFaxOpened=EFalse; |
|
2753 } |
|
2754 |
|
2755 void CCallMobileFax::CleanUpFaxServer() |
|
2756 { |
|
2757 LOGTEXT(_L8("Closing down Fax Server")); |
|
2758 (void)iFaxSession->FxClose(); |
|
2759 iFaxServerLib.Close(); |
|
2760 iFaxSession = NULL; |
|
2761 iPhoneGlobals->iPhoneStatus.iPortAccess = EPortAccessAllowed; |
|
2762 iPhoneGlobals->iEventSignalActive = EFalse; |
|
2763 } |