141 iCurrentRouting = TMS_AUDIO_OUTPUT_PRIVATE; |
141 iCurrentRouting = TMS_AUDIO_OUTPUT_PRIVATE; |
142 iDTMFDnlinkPlayer = NULL; |
142 iDTMFDnlinkPlayer = NULL; |
143 iDTMFUplinkPlayer = NULL; |
143 iDTMFUplinkPlayer = NULL; |
144 iDTMFUplinkPlayerEtel = NULL; |
144 iDTMFUplinkPlayerEtel = NULL; |
145 iActiveCallType = -1; |
145 iActiveCallType = -1; |
146 iSyncVol = TMSPubSubListener::NewL(KTMSPropertyCategory,ESyncVolume, this); |
146 iSyncVol = TMSPubSubListener::NewL(KTMSPropertyCategory, ESyncVolume, this); |
147 |
147 |
148 //TODO: EUnit fails to initialize ProfileEngine in RT in eshell mode |
148 //TODO: EUnit fails to initialize ProfileEngine in RT in eshell mode |
149 TRAP_IGNORE(InitRingTonePlayerL()); |
149 TRAP_IGNORE(InitRingTonePlayerL()); |
150 |
150 |
151 // We need it running for global volume change updates |
151 // We need it running for global volume change updates |
176 void TMSServer::DropSession() |
176 void TMSServer::DropSession() |
177 { |
177 { |
178 iSession--; |
178 iSession--; |
179 |
179 |
180 // If session count is zero, start server shutdown |
180 // If session count is zero, start server shutdown |
181 if (iSession == 0) |
181 if (iSession <= 0 && iShutdownTimer) |
182 { |
182 { |
183 iShutdownTimer->SetDelay(TTimeIntervalMicroSeconds32( |
183 iShutdownTimer->SetDelay(TTimeIntervalMicroSeconds32( |
184 KTMSShutDownDelayTime)); |
184 KTMSShutDownDelayTime)); |
185 } |
185 } |
186 |
186 |
254 status = callServerThread->StartTMSCallServer(aHandle); |
254 status = callServerThread->StartTMSCallServer(aHandle); |
255 TInt count = 0; |
255 TInt count = 0; |
256 count = iTMSCallServList.Count(); |
256 count = iTMSCallServList.Count(); |
257 |
257 |
258 iTMSCallServList[count - 1]->iTMSCallProxyLocal = aHandle; |
258 iTMSCallServList[count - 1]->iTMSCallProxyLocal = aHandle; |
259 |
259 FindActiveCallType(); |
260 //cache global vol and global gain to call server thread. |
260 |
261 TInt volume; |
261 if (iActiveCallType == TMS_CALL_CS) |
262 switch (iCurrentRouting) |
|
263 { |
262 { |
264 case TMS_AUDIO_OUTPUT_PUBLIC: |
263 //cache global vol and global gain to call server thread. |
265 case TMS_AUDIO_OUTPUT_LOUDSPEAKER: |
264 TInt volume; |
|
265 switch (iCurrentRouting) |
266 { |
266 { |
267 iEffectSettings->GetLoudSpkrVolume(volume); |
267 case TMS_AUDIO_OUTPUT_LOUDSPEAKER: |
268 TRACE_PRN_N1(_L("loudspk vol %d"),volume); |
268 { |
|
269 iEffectSettings->GetLoudSpkrVolume(volume); |
|
270 TRACE_PRN_N1(_L("loudspk vol %d"),volume); |
|
271 } |
|
272 break; |
|
273 default: |
|
274 { |
|
275 iEffectSettings->GetEarPieceVolume(volume); |
|
276 TRACE_PRN_N1(_L("ear vol %d"),volume); |
|
277 } |
|
278 break; |
269 } |
279 } |
270 break; |
280 aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_VOL_SET, volume); |
271 default: |
281 aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_GAIN_SET, |
272 { |
282 iEffectSettings->Gain()); |
273 iEffectSettings->GetEarPieceVolume(volume); |
|
274 TRACE_PRN_N1(_L("ear vol %d"),volume); |
|
275 } |
|
276 break; |
|
277 } |
283 } |
278 aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_VOL_SET, volume); |
|
279 aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_GAIN_SET, |
|
280 iEffectSettings->Gain()); |
|
281 } |
284 } |
282 else |
285 else |
283 { |
286 { |
284 delete callServerThread; |
287 delete callServerThread; |
285 } |
288 } |
751 TRACE_PRN_FN_EXT; |
754 TRACE_PRN_FN_EXT; |
752 return status; |
755 return status; |
753 } |
756 } |
754 |
757 |
755 // ----------------------------------------------------------------------------- |
758 // ----------------------------------------------------------------------------- |
756 // TMSServer::SendMessageToCallServ |
|
757 // |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 TInt TMSServer::SendMessageToCallServ(TInt func, TIpcArgs args) |
|
761 { |
|
762 TRACE_PRN_FN_ENT; |
|
763 |
|
764 TInt status(TMS_RESULT_SUCCESS); |
|
765 TInt i = 0; |
|
766 while (i < iTMSCallServList.Count()) |
|
767 { |
|
768 TMSStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i]; |
|
769 |
|
770 if (callThread) |
|
771 { |
|
772 if (!callThread->IsActive()) |
|
773 { |
|
774 iTMSCallServList.Remove(i); |
|
775 delete callThread; |
|
776 } |
|
777 else |
|
778 { |
|
779 status = callThread->iTMSCallProxyLocal.SendToCallServer( |
|
780 func, args); |
|
781 if (status != TMS_RESULT_SUCCESS) |
|
782 { |
|
783 break; |
|
784 } |
|
785 } |
|
786 } |
|
787 i++; |
|
788 } |
|
789 |
|
790 TRACE_PRN_FN_EXT; |
|
791 return status; |
|
792 } |
|
793 |
|
794 // ----------------------------------------------------------------------------- |
|
795 // TMSServer::NotifyTarClients |
759 // TMSServer::NotifyTarClients |
796 // |
760 // |
797 // ----------------------------------------------------------------------------- |
761 // ----------------------------------------------------------------------------- |
798 // |
762 // |
799 TInt TMSServer::NotifyTarClients(TRoutingMsgBufPckg routingpckg) |
763 TInt TMSServer::NotifyTarClients(TRoutingMsgBufPckg routingpckg) |
804 TInt status(TMS_RESULT_SUCCESS); |
768 TInt status(TMS_RESULT_SUCCESS); |
805 FindActiveCallType(); |
769 FindActiveCallType(); |
806 |
770 |
807 if (iActiveCallType == TMS_CALL_CS) |
771 if (iActiveCallType == TMS_CALL_CS) |
808 { |
772 { |
809 |
|
810 iCurrentRouting = routingpckg().iOutput; |
773 iCurrentRouting = routingpckg().iOutput; |
811 if (iCurrentRouting == TMS_AUDIO_OUTPUT_PUBLIC || |
774 if (iCurrentRouting == TMS_AUDIO_OUTPUT_PUBLIC || |
812 iCurrentRouting == TMS_AUDIO_OUTPUT_LOUDSPEAKER) |
775 iCurrentRouting == TMS_AUDIO_OUTPUT_LOUDSPEAKER) |
813 { |
776 { |
814 iEffectSettings->GetLoudSpkrVolume(vol); |
777 iEffectSettings->GetLoudSpkrVolume(vol); |
815 TRACE_PRN_N1(_L("TMSServer::NotifyTarClients loudspkr vol %d"),vol); |
778 TRACE_PRN_N1(_L("TMSServer::NotifyTarClients loudspkr vol %d"),vol); |
816 } |
779 } |
817 else |
780 else |
977 if (iActiveCallType == TMS_CALL_IP && iDTMFUplinkPlayer) |
940 if (iActiveCallType == TMS_CALL_IP && iDTMFUplinkPlayer) |
978 { |
941 { |
979 iDTMFUplinkPlayer->Cancel(); |
942 iDTMFUplinkPlayer->Cancel(); |
980 status = TMS_RESULT_SUCCESS; |
943 status = TMS_RESULT_SUCCESS; |
981 } |
944 } |
982 else if (iActiveCallType == TMS_CALL_CS && |
945 else if (iActiveCallType == TMS_CALL_CS && iDTMFUplinkPlayerEtel) |
983 iDTMFUplinkPlayerEtel) |
|
984 { |
946 { |
985 status = iDTMFUplinkPlayerEtel->StopDtmfTone(); |
947 status = iDTMFUplinkPlayerEtel->StopDtmfTone(); |
986 status = TMSUtility::EtelToTMSResult(status); |
948 status = TMSUtility::EtelToTMSResult(status); |
987 } |
949 } |
988 } |
950 } |
1428 // ----------------------------------------------------------------------------- |
1390 // ----------------------------------------------------------------------------- |
1429 // TMSServer::HandleNotifyPSL |
1391 // TMSServer::HandleNotifyPSL |
1430 // |
1392 // |
1431 // ----------------------------------------------------------------------------- |
1393 // ----------------------------------------------------------------------------- |
1432 // |
1394 // |
1433 void TMSServer::HandleNotifyPSL(const TUid aUid, const TInt& aKey, |
1395 void TMSServer::HandleNotifyPSL(const TUid /*aUid*/, const TInt& /*aKey*/, |
1434 const TRequestStatus& aStatus) |
1396 const TRequestStatus& /*aStatus*/) |
1435 { |
1397 { |
1436 TRACE_PRN_FN_ENT; |
1398 TRACE_PRN_FN_ENT; |
1437 if(iEffectSettings) |
1399 if (iEffectSettings) |
1438 { |
1400 { |
1439 iEffectSettings->ResetDefaultVolume(); |
1401 iEffectSettings->ResetDefaultVolume(); |
1440 } |
1402 } |
1441 TRACE_PRN_FN_EXT; |
1403 TRACE_PRN_FN_EXT; |
1442 } |
1404 } |
1471 // Cleanup scheduler and delete the server |
1433 // Cleanup scheduler and delete the server |
1472 CleanupStack::PopAndDestroy(server); |
1434 CleanupStack::PopAndDestroy(server); |
1473 CleanupStack::PopAndDestroy(scheduler); |
1435 CleanupStack::PopAndDestroy(scheduler); |
1474 |
1436 |
1475 TRACE_PRN_N(_L("TMS->RunServerL - TMS server closed")); |
1437 TRACE_PRN_N(_L("TMS->RunServerL - TMS server closed")); |
|
1438 } |
|
1439 |
|
1440 // ----------------------------------------------------------------------------- |
|
1441 // TMSServer::TerminateServer |
|
1442 // |
|
1443 // ----------------------------------------------------------------------------- |
|
1444 // |
|
1445 void TMSServer::TermSrv(const RMessage2& aMessage) |
|
1446 { |
|
1447 TRACE_PRN_FN_ENT; |
|
1448 |
|
1449 // First, make sure request comes from a legitimate source |
|
1450 |
|
1451 // Level 1 - check process capability |
|
1452 //TBool allow = aMessage.HasCapability(ECapabilityTCB); |
|
1453 TBool allow = aMessage.HasCapability(ECapabilityPowerMgmt); |
|
1454 |
|
1455 if (allow) |
|
1456 { |
|
1457 // Level 2 - check Vendor ID |
|
1458 _LIT_VENDOR_ID(AllowId, VID_DEFAULT); |
|
1459 allow = (aMessage.VendorId() == AllowId) ? ETrue : EFalse; |
|
1460 } |
|
1461 /*if (allow) |
|
1462 { |
|
1463 // Level 3 - check SecureID of the process |
|
1464 TUid uid = ALLOWED_UID; |
|
1465 allow = ((static_cast<TUid> (aMessage.SecureId()) == uid)) ? ETrue : EFalse; |
|
1466 }*/ |
|
1467 |
|
1468 aMessage.Complete(TMS_RESULT_SUCCESS); |
|
1469 |
|
1470 if (allow) |
|
1471 { |
|
1472 TRACE_PRN_N(_L("TMS->Server going down!")); |
|
1473 SendMessageToCallServ(TMS_TERM_CALL_SRV, 0); |
|
1474 |
|
1475 TMSServerSession *session; |
|
1476 iSessionIter.SetToFirst(); |
|
1477 |
|
1478 for (;;) |
|
1479 { |
|
1480 session = static_cast<TMSServerSession*> (iSessionIter++); |
|
1481 if (!session) |
|
1482 { |
|
1483 break; |
|
1484 } |
|
1485 delete session; |
|
1486 } |
|
1487 } |
|
1488 TRACE_PRN_FN_EXT; |
1476 } |
1489 } |
1477 |
1490 |
1478 // ----------------------------------------------------------------------------- |
1491 // ----------------------------------------------------------------------------- |
1479 // TMSStartAndMonitorTMSCallThread::TMSStartAndMonitorTMSCallThread |
1492 // TMSStartAndMonitorTMSCallThread::TMSStartAndMonitorTMSCallThread |
1480 // Perhaps we need to move this to a .cpp? |
1493 // Perhaps we need to move this to a .cpp? |
1546 TInt status(TMS_RESULT_SUCCESS); |
1559 TInt status(TMS_RESULT_SUCCESS); |
1547 TMSCallServerStartParam start(iTMSServer, iCallSrvrHndl); |
1560 TMSCallServerStartParam start(iTMSServer, iCallSrvrHndl); |
1548 const TUidType serverUid(KNullUid, KNullUid, KUidTMSCallServerUid3); |
1561 const TUidType serverUid(KNullUid, KNullUid, KUidTMSCallServerUid3); |
1549 TThreadFunction serverFunc = TMSCallServer::StartThread; |
1562 TThreadFunction serverFunc = TMSCallServer::StartThread; |
1550 |
1563 |
1551 status = iServerThread.Create(_L(""), |
1564 status = iServerThread.Create(_L(""), serverFunc, KTMSCallServerStackSize, |
1552 serverFunc, |
1565 KTMSCallServerInitHeapSize, KTMSCallServerMaxHeapSize, &start, |
1553 KTMSCallServerStackSize, |
1566 EOwnerProcess); |
1554 KTMSCallServerInitHeapSize, |
|
1555 KTMSCallServerMaxHeapSize, |
|
1556 &start, |
|
1557 EOwnerProcess); |
|
1558 |
1567 |
1559 if (status != TMS_RESULT_SUCCESS) |
1568 if (status != TMS_RESULT_SUCCESS) |
1560 { |
1569 { |
1561 return status; |
1570 return status; |
1562 } |
1571 } |
1640 TInt TMSCallProxyLocal::Open(RServer2& aTMSCallServerHandle) |
1649 TInt TMSCallProxyLocal::Open(RServer2& aTMSCallServerHandle) |
1641 { |
1650 { |
1642 TRACE_PRN_FN_ENT; |
1651 TRACE_PRN_FN_ENT; |
1643 |
1652 |
1644 TInt status(KErrNotSupported); |
1653 TInt status(KErrNotSupported); |
1645 status = CreateSession(aTMSCallServerHandle, |
1654 status = CreateSession(aTMSCallServerHandle, TVersion( |
1646 TVersion(KTMSCallServerMajorVersionNumber, |
1655 KTMSCallServerMajorVersionNumber, KTMSCallServerMinorVersionNumber, |
1647 KTMSCallServerMinorVersionNumber, |
1656 KTMSCallServerBuildVersionNumber), -1, EIpcSession_GlobalSharable); |
1648 KTMSCallServerBuildVersionNumber), |
|
1649 -1, |
|
1650 EIpcSession_GlobalSharable); |
|
1651 TRACE_PRN_FN_EXT; |
1657 TRACE_PRN_FN_EXT; |
1652 return status; |
1658 return status; |
1653 } |
1659 } |
1654 |
1660 |
1655 // ----------------------------------------------------------------------------- |
1661 // ----------------------------------------------------------------------------- |
1659 // |
1665 // |
1660 TInt TMSCallProxyLocal::SendToCallServer(TInt aFunc, TUint value) |
1666 TInt TMSCallProxyLocal::SendToCallServer(TInt aFunc, TUint value) |
1661 { |
1667 { |
1662 TInt status(TMS_RESULT_SUCCESS); |
1668 TInt status(TMS_RESULT_SUCCESS); |
1663 status = SendReceive(aFunc, TIpcArgs(value)); |
1669 status = SendReceive(aFunc, TIpcArgs(value)); |
1664 return status; |
|
1665 } |
|
1666 |
|
1667 // ----------------------------------------------------------------------------- |
|
1668 // TMSCallProxyLocal::SendToCallServer |
|
1669 // |
|
1670 // ----------------------------------------------------------------------------- |
|
1671 // |
|
1672 TInt TMSCallProxyLocal::SendToCallServer(TInt aFunc, TIpcArgs args) |
|
1673 { |
|
1674 TInt status(TMS_RESULT_SUCCESS); |
|
1675 status = SendReceive(aFunc, args); |
|
1676 return status; |
1670 return status; |
1677 } |
1671 } |
1678 |
1672 |
1679 // ----------------------------------------------------------------------------- |
1673 // ----------------------------------------------------------------------------- |
1680 // TMSCallProxyLocal::ReceiveFromCallServer |
1674 // TMSCallProxyLocal::ReceiveFromCallServer |