telephonyserver/etelserverandcore/SETEL/ET_PHONE.CPP
branchopencode
changeset 77 930a53cdc2d3
parent 32 58332560b319
child 81 7f379d8ed02d
equal deleted inserted replaced
35:6fbc08ed9c42 77:930a53cdc2d3
   992 			return;
   992 			return;
   993 			}
   993 			}
   994 
   994 
   995         // If a call is session based then it can only be used
   995         // If a call is session based then it can only be used
   996         // when the client is the session owner.
   996         // when the client is the session owner.
   997         if (reqMode&KReqModeSessionBased && IsSessionInProgress() 
   997         if ( (reqMode&KReqModeSessionBased && IsSessionInProgress()) 
   998                 /*&& aMessage.Int3() != iSessionOwner.iSubSessionId TODO*/)
   998         		&& (aMessage.Int3() != iDeliveryObject->iSessionOwner.iSubSessionId) )
   999             {
   999             {
  1000             // Each type of session only allowed to have one ongoing 'session/dialogue'.
  1000             // Each type of session only allowed to have one ongoing 'session/dialogue'.
  1001 			RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), res);
  1001 			RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), res);
  1002             aMessage.Complete(KErrServerBusy);
  1002             aMessage.Complete(KErrServerBusy);
  1003             return;
  1003             return;
  1352 			{
  1352 			{
  1353             WriteBackAndCompleteReq(aReqEntry,error);
  1353             WriteBackAndCompleteReq(aReqEntry,error);
  1354 			}
  1354 			}
  1355         }
  1355         }
  1356     
  1356     
  1357     CheckAndDestroyDummySubSession(); //TODO
  1357     CheckAndDestroyDummySubSession();
  1358     }
  1358     }
  1359 
  1359 
  1360 void CTelObject::RepostRequest(CReqEntry* aUpdatedReqEntry, const TInt aError)
  1360 void CTelObject::RepostRequest(CReqEntry* aUpdatedReqEntry, const TInt aError)
  1361     {
  1361     {
  1362 	TReqMode reqMode = aUpdatedReqEntry->iReqMode;
  1362 	TReqMode reqMode = aUpdatedReqEntry->iReqMode;
  1387     }
  1387     }
  1388 
  1388 
  1389 void CTelObject::SetSessionOwner(TInt aSessionHandle, TInt aSubSessionHandle)
  1389 void CTelObject::SetSessionOwner(TInt aSessionHandle, TInt aSubSessionHandle)
  1390     {
  1390     {
  1391 	iDeliveryObject->iSessionOwner = TPhoneClientId(aSessionHandle, aSubSessionHandle);
  1391 	iDeliveryObject->iSessionOwner = TPhoneClientId(aSessionHandle, aSubSessionHandle);
  1392     // TODO notify TSY that the session owner has changed 
       
  1393     }
  1392     }
  1394 
  1393 
  1395 // TODO can be used by the TSY to set the session owner to the current request.
  1394 // Can be used by the TSY to set the session owner to the current request.
  1396 // For each request the CTSY is given a TsyReqHandle so this is a sensible thing
  1395 // For each request the CTSY is given a TsyReqHandle so this is a sensible thing
  1397 // for it to be dealing with.
  1396 // for it to be dealing with.
  1398 // TODO note that once a session has an owner the reserved state is irrelevant.
  1397 // Note that once a session has an owner the reserved state is irrelevant.
  1399 
  1398 
  1400 EXPORT_C void CTelObject::SetSessionOwnerByTsyHandle(const TTsyReqHandle aTsyReqHandle)
  1399 EXPORT_C void CTelObject::SetSessionOwnerByTsyHandle(const TTsyReqHandle aTsyReqHandle)
  1401     {
  1400     {
  1402 //    const TInt owningsession = PhoneOwner()->FindSessionByTsyHandle( aTsyReqHandle );
  1401 	
  1403 //    const TInt owningsubsession = PhoneOwner()->FindSubSessionByTsyHandle( aTsyReqHandle );
  1402     const TInt owningsession = PhoneOwner()->FindSessionByTsyHandle( aTsyReqHandle );
  1404 	
  1403     const TInt owningsubsession = PhoneOwner()->FindSubSessionByTsyHandle( aTsyReqHandle );
  1405 //	iSessionOwner = TPhoneClientId(owningsession, owningsubsession);
  1404     
  1406     // TODO notify TSY that the session owner has changed 
  1405         
       
  1406     if(iDeliveryObject->GetReqMode() == (KReqModeSessionBased | KReqModeTransferToDefaultHandler)) // transfer to default handler
       
  1407     	{
       
  1408     	iDeliveryObject->iSessionOwner = TPhoneClientId(KUssdDefaultClientSid, owningsubsession);
       
  1409     	}
       
  1410     else //not default handler
       
  1411     	{
       
  1412     	iDeliveryObject->iSessionOwner = TPhoneClientId(owningsession, owningsubsession);
       
  1413     	}
  1407     }
  1414     }
  1408 
  1415 
  1409 
  1416 
  1410 TBool CTelObject::IsSessionOwner(CReqEntry* aReqEntry) const
  1417 TBool CTelObject::IsSessionOwner(CReqEntry* aReqEntry) const
  1411     {
  1418     {
  1412 	// TODO Neil's experimental update
       
  1413     TPhoneClientId clientId(reinterpret_cast<TInt>(aReqEntry->iSession),aReqEntry->iMessage.Int3());
  1419     TPhoneClientId clientId(reinterpret_cast<TInt>(aReqEntry->iSession),aReqEntry->iMessage.Int3());
  1414 	return (clientId == iDeliveryObject->iSessionOwner);
  1420 	return (clientId == iDeliveryObject->iSessionOwner);
  1415     }
  1421     }
  1416 
  1422 
  1417 TInterestCategory CTelObject::FindInterestCategory( const TSecureId aSid)
  1423 TInterestCategory CTelObject::FindInterestCategory( const TSecureId aSid)
  1428 	    return EInterestCategoryStandard;
  1434 	    return EInterestCategoryStandard;
  1429 	}	
  1435 	}	
  1430 
  1436 
  1431 EXPORT_C TBool CTelObject::IsSessionInProgress() const
  1437 EXPORT_C TBool CTelObject::IsSessionInProgress() const
  1432     {
  1438     {
  1433 	// TODO Neil's experimental update
  1439 	//Indicates if there is an ongoing USSD dialogue.
  1434 	if (iDeliveryObject)
  1440 	if (iDeliveryObject)
  1435 		{
  1441 		{
  1436 		return iDeliveryObject->iSessionOwner != TPhoneClientId();
  1442 		return iDeliveryObject->iSessionOwner != TPhoneClientId();
  1437 		}
  1443 		}
  1438 	return EFalse;
  1444 	return EFalse;
  1439     }
  1445     }
  1440 
  1446 
  1441 EXPORT_C TInt CTelObject::ReserveSession()
  1447 EXPORT_C TInt CTelObject::ReserveSession()
  1442     {
  1448     {
  1443 	// TODO Neil's experimental update
  1449     // There is no active session so we have to work out who to deliver it to. 
  1444 	ASSERT(iDeliveryObject);
  1450     if (NULL == iDeliveryObject)
       
  1451     	{
       
  1452     	iDeliveryObject = CMmDeliveryObject::NewL(*this); 
       
  1453     	}
       
  1454     //Reserve the session if it is not already reserved
  1445     if (iDeliveryObject->iSessionReserved)
  1455     if (iDeliveryObject->iSessionReserved)
  1446         {
  1456         {
  1447         return KErrInUse;
  1457         return KErrInUse;
  1448         }
  1458         }
  1449     iDeliveryObject->iSessionReserved = ETrue;
  1459     iDeliveryObject->iSessionReserved = ETrue;
  1450 	return KErrNone;
  1460 	return KErrNone;
  1451     }
  1461     }
  1452 
  1462 
  1453 EXPORT_C TBool CTelObject::IsSessionReserved() const
  1463 EXPORT_C TBool CTelObject::IsSessionReserved() const
  1454     {
  1464     {
  1455 	// TODO Neil's experimental update
  1465 	//Check if the USSD session has been reserved
  1456     return iDeliveryObject->iSessionReserved;
  1466 	if (NULL != iDeliveryObject)
       
  1467 		{
       
  1468 		return iDeliveryObject->iSessionReserved;
       
  1469 		}
       
  1470 	else
       
  1471 		{
       
  1472 		return EFalse;
       
  1473 		}
  1457     }
  1474     }
  1458 
  1475 
  1459 EXPORT_C void CTelObject::CancelReserveSession()
  1476 EXPORT_C void CTelObject::CancelReserveSession()
  1460     {
  1477     {
  1461 	// TODO Neil's experimental update
  1478 	if (iDeliveryObject)
  1462     iDeliveryObject->iSessionReserved = EFalse;
  1479 		{
       
  1480 		iDeliveryObject->iSessionReserved = EFalse;
       
  1481 		}
  1463     }
  1482     }
  1464 
  1483 
  1465 EXPORT_C void CTelObject::EndSession()
  1484 EXPORT_C void CTelObject::EndSession()
  1466     {
  1485     {
  1467 	// TODO Neil's experimental update
  1486 	if (iDeliveryObject)
  1468     iDeliveryObject->iSessionOwner = TPhoneClientId();
  1487 		{
  1469     iDeliveryObject->iSessionReserved = EFalse;
  1488 		iDeliveryObject->iSessionOwner = TPhoneClientId();
       
  1489 		iDeliveryObject->iSessionReserved = EFalse;
       
  1490 		}
  1470     }
  1491     }
  1471 
  1492 
  1472 TInt CTelObject::ResolveError(CTelSession* aSession, const TInt aError) const
  1493 TInt CTelObject::ResolveError(CTelSession* aSession, const TInt aError) const
  1473 /**
  1494 /**
  1474  * Converts a coded error into the correct error to return.  The coded error value
  1495  * Converts a coded error into the correct error to return.  The coded error value