54 // ---------------------------------------------------- |
52 // ---------------------------------------------------- |
55 // |
53 // |
56 CRadioEngine::CRadioEngine( |
54 CRadioEngine::CRadioEngine( |
57 MRadioEngineStateChangeCallback& aCallback) |
55 MRadioEngineStateChangeCallback& aCallback) |
58 : |
56 : |
59 iAutoResume(EFalse), |
57 iCurrentRadioState( EStateRadioOff ), |
60 iCurrentRadioState(EStateRadioOff), |
58 iCallback( aCallback ), |
61 iCallback(aCallback), |
59 iTempFrequency( KDefaultRadioFrequency ), |
62 iTempFrequency(KDefaultRadioFrequency), |
60 iTunePresetRequested( EFalse ), |
63 iTunePresetRequested(EFalse), |
61 iInitializeRadioRequestExists( EFalse ), |
64 iInitializeRadioRequestExists(EFalse), |
62 iTunerControl( EStateRadioTunerControlUninitialized ) |
65 ilineConstructed( EFalse ), |
|
66 iHFOptionActivated ( EFalse ) |
|
67 { |
63 { |
68 } |
64 } |
69 |
65 |
70 // ---------------------------------------------------- |
66 // ---------------------------------------------------- |
71 // CRadioEngine::ConstructL |
67 // CRadioEngine::ConstructL |
171 iPubSub->PublishFrequencyDecimalCountL( |
159 iPubSub->PublishFrequencyDecimalCountL( |
172 TFMRadioPSFrequencyDecimalCount( iRadioSettings->DecimalCount() ) ); |
160 TFMRadioPSFrequencyDecimalCount( iRadioSettings->DecimalCount() ) ); |
173 |
161 |
174 FTRACE(FPrint(_L("CRadioEngine::ConstructL() End "))); |
162 FTRACE(FPrint(_L("CRadioEngine::ConstructL() End "))); |
175 } |
163 } |
176 |
|
177 // ---------------------------------------------------- |
|
178 // CRadioEngine::ConnectLineL |
|
179 // Connects etel server |
|
180 // ---------------------------------------------------- |
|
181 // |
|
182 void CRadioEngine::ConnectLineL() |
|
183 { |
|
184 User::LeaveIfError( iTelServer.Connect() ); |
|
185 |
|
186 iTelServer.GetTsyName( 0, iTsyName ); |
|
187 |
|
188 User::LeaveIfError( iTelServer.LoadPhoneModule( iTsyName ) ); |
|
189 TInt numberOfPhones( 0 ); |
|
190 User::LeaveIfError( iTelServer.EnumeratePhones( numberOfPhones ) ); |
|
191 |
|
192 RTelServer::TPhoneInfo phoneInfo; |
|
193 |
|
194 // Only possible thing to do is leave. We definately need phone. |
|
195 User::LeaveIfError( iTelServer.GetPhoneInfo( 0, phoneInfo ) ); |
|
196 |
|
197 // Only possible thing to do is leave. We definately need phone. |
|
198 User::LeaveIfError( iPhone.Open( iTelServer, phoneInfo.iName )); |
|
199 |
|
200 |
|
201 RPhone::TLineInfo lineInfo; |
|
202 |
|
203 User::LeaveIfError( iPhone.GetLineInfo( 0, lineInfo ) ); |
|
204 |
|
205 User::LeaveIfError( iLine.Open( iPhone, lineInfo.iName ) ); |
|
206 |
|
207 ilineConstructed = ETrue; |
|
208 } |
|
209 |
164 |
210 // ---------------------------------------------------- |
165 // ---------------------------------------------------- |
211 // CRadioEngine::NewL |
166 // CRadioEngine::NewL |
212 // Two-phased class constructor. |
167 // Two-phased class constructor. |
213 // ---------------------------------------------------- |
168 // ---------------------------------------------------- |
1021 |
968 |
1022 // ---------------------------------------------------- |
969 // ---------------------------------------------------- |
1023 // CRadioEngine::MrftoRequestTunerControlComplete |
970 // CRadioEngine::MrftoRequestTunerControlComplete |
1024 // ---------------------------------------------------- |
971 // ---------------------------------------------------- |
1025 // |
972 // |
1026 void CRadioEngine::MrftoRequestTunerControlComplete( |
973 void CRadioEngine::MrftoRequestTunerControlComplete( TInt aError ) |
1027 TInt aError ) |
|
1028 { |
974 { |
1029 FTRACE(FPrint(_L("CRadioEngine::MrftoRequestTunerControlComplete() - Error = %d"), aError)); |
975 FTRACE(FPrint(_L("CRadioEngine::MrftoRequestTunerControlComplete() - Error = %d"), aError)); |
1030 |
976 |
1031 if ( aError == KErrNone ) |
977 if ( aError == KErrNone ) |
1032 { |
978 { |
1033 iTunerControl = ETrue; |
979 iTunerControl = EStateRadioTunerControlOn; |
1034 // Headset must be connected |
980 // Headset must be connected |
1035 iRadioSettings->SetHeadsetConnected(); |
981 iRadioSettings->SetHeadsetConnected(); |
1036 iFmTunerUtility->GetCapabilities( iTunerCaps ); |
982 iFmTunerUtility->GetCapabilities( iTunerCaps ); |
1037 |
|
1038 if( iTunerCaps.iTunerFunctions & TFmTunerCapabilities::ETunerRdsSupport ) |
983 if( iTunerCaps.iTunerFunctions & TFmTunerCapabilities::ETunerRdsSupport ) |
1039 { |
984 { |
1040 TRAP_IGNORE( iRdsReceiver->InitL( *iRadioUtility, iPubSub ) ) |
985 TRAP_IGNORE( iRdsReceiver->InitL( *iRadioUtility, iPubSub ) ) |
1041 } |
986 } |
1042 |
987 |
1043 TFmRadioFrequencyRange japanFreqRange = EFmRangeJapan; |
988 TFmRadioFrequencyRange japanFreqRange = EFmRangeJapan; |
1044 |
989 if ( TunerFrequencyRangeForRegionId( RegionId() ) == japanFreqRange ) |
1045 if ( TunerFrequencyRangeForRegionId( RegionId() ) == japanFreqRange ) |
990 { |
1046 { |
991 // region is Japan so we need to change the freq range from the default |
1047 // region is Japan so we need to change the freq range from the default |
992 iFmTunerUtility->SetFrequencyRange( japanFreqRange ); |
1048 iFmTunerUtility->SetFrequencyRange( japanFreqRange ); |
993 } |
1049 } |
994 else |
1050 else |
995 { |
1051 { |
996 // allready on correct freq range |
1052 // allready on correct freq range |
997 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTunerReady, KErrNone ); |
1053 HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventTunerReady, KErrNone ); |
998 } |
1054 } |
999 |
1055 } |
1000 } |
1056 else if ( aError == KFmRadioErrAntennaNotConnected ) |
1001 else if ( aError == KFmRadioErrAntennaNotConnected ) |
1057 { |
1002 { |
1058 FTRACE(FPrint(_L("CRadioEngine::MrftoRequestTunerControlComplete() - KFmRadioErrAntennaNotConnected"))); |
1003 FTRACE(FPrint(_L("CRadioEngine::MrftoRequestTunerControlComplete() - KFmRadioErrAntennaNotConnected"))); |
|
1004 iTunerControl = EStateRadioTunerControlOff; |
1059 iRadioSettings->SetHeadsetDisconnected(); |
1005 iRadioSettings->SetHeadsetDisconnected(); |
1060 HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventHeadsetDisconnected, KErrNone ); |
1006 HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventHeadsetDisconnected, KErrNone ); |
1061 } |
1007 } |
1062 else if ( aError == KErrAlreadyExists ) |
1008 else if ( aError == KErrAlreadyExists ) |
1063 { |
1009 { |
1064 iTunerControl = ETrue; |
1010 iTunerControl = EStateRadioTunerControlOn; |
1065 // Headset must be connected |
1011 // Headset must be connected |
1066 iRadioSettings->SetHeadsetConnected(); |
1012 iRadioSettings->SetHeadsetConnected(); |
1067 iFmTunerUtility->GetCapabilities( iTunerCaps ); |
1013 iFmTunerUtility->GetCapabilities( iTunerCaps ); |
1068 TInt frequency; |
1014 TInt frequency; |
1069 iFmTunerUtility->GetFrequency( frequency ); |
1015 iFmTunerUtility->GetFrequency( frequency ); |
1070 StoreAndPublishFrequency( frequency ); |
1016 StoreAndPublishFrequency( frequency ); |
1071 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, KErrNone ); |
1017 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTune, KErrNone ); |
1072 } |
1018 } |
1073 else if ( aError == KFmRadioErrFmTransmitterActive ) |
1019 else if ( aError == KFmRadioErrFmTransmitterActive ) |
1074 { |
1020 { |
1075 iTunerControl = EFalse; |
1021 iTunerControl = EStateRadioTunerControlOff; |
1076 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFMTransmitterOn, KErrNone ); |
1022 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFMTransmitterOn, KErrNone ); |
1077 } |
1023 } |
1078 else if ( aError == KFmRadioErrOfflineMode ) |
1024 else if ( aError == KFmRadioErrOfflineMode ) |
1079 { |
1025 { |
1080 iTunerControl = EFalse; |
1026 iTunerControl = EStateRadioTunerControlOff; |
1081 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFlightModeEnabled, KErrNone ); |
1027 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventFlightModeEnabled, KErrNone ); |
1082 } |
1028 } |
1083 else |
1029 else |
1084 { |
1030 { |
1085 //pass |
1031 iTunerControl = EStateRadioTunerControlOff; |
1086 } |
1032 } |
1087 } |
1033 } |
1088 |
1034 |
1089 // ---------------------------------------------------- |
1035 // ---------------------------------------------------- |
1090 // CRadioEngine::MrftoSetFrequencyRangeComplete |
1036 // CRadioEngine::MrftoSetFrequencyRangeComplete |
1091 // |
1037 // |
1092 // ---------------------------------------------------- |
1038 // ---------------------------------------------------- |
1093 // |
1039 // |
1094 void CRadioEngine::MrftoSetFrequencyRangeComplete( |
1040 void CRadioEngine::MrftoSetFrequencyRangeComplete( TInt aError ) |
1095 TInt aError ) |
|
1096 { |
1041 { |
1097 if ( aError == KErrNone ) |
1042 if ( aError == KErrNone ) |
1098 { |
1043 { |
1099 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTunerReady, KErrNone ); |
1044 HandleCallback( MRadioEngineStateChangeCallback::EFMRadioEventTunerReady, KErrNone ); |
1100 } |
1045 } |
1101 |
1046 |
1102 FTRACE(FPrint(_L("CRadioEngine::MrftoSetFrequencyRangeComplete() - error = %d"), aError)); |
1047 FTRACE(FPrint(_L("CRadioEngine::MrftoSetFrequencyRangeComplete() - error = %d"), aError)); |
1103 } |
1048 } |
1104 |
1049 |
1105 // ---------------------------------------------------- |
1050 // ---------------------------------------------------- |
1106 // CRadioEngine::MrftoSetFrequencyComplete |
1051 // CRadioEngine::MrftoSetFrequencyComplete |
1107 // ---------------------------------------------------- |
1052 // ---------------------------------------------------- |
1108 // |
1053 // |
1109 void CRadioEngine::MrftoSetFrequencyComplete( |
1054 void CRadioEngine::MrftoSetFrequencyComplete( TInt aError ) |
1110 TInt aError ) |
|
1111 { |
1055 { |
1112 FTRACE(FPrint(_L("CRadioEngine::MrftoSetFrequencyComplete() - aError = %d"), aError)); |
1056 FTRACE(FPrint(_L("CRadioEngine::MrftoSetFrequencyComplete() - aError = %d"), aError)); |
1113 |
|
1114 |
1057 |
1115 if ( !aError ) |
1058 if ( !aError ) |
1116 { |
1059 { |
1117 iRdsReceiver->ClearRdsInformation(); |
1060 iRdsReceiver->ClearRdsInformation(); |
1118 StoreAndPublishFrequency( iTempFrequency ); |
1061 StoreAndPublishFrequency( iTempFrequency ); |
1359 if ( ( aError == KErrDied ) || |
1300 if ( ( aError == KErrDied ) || |
1360 ( aError == KErrAccessDenied ) || |
1301 ( aError == KErrAccessDenied ) || |
1361 ( aError == KErrNotReady ) || |
1302 ( aError == KErrNotReady ) || |
1362 ( aError == KErrInUse ) ) |
1303 ( aError == KErrInUse ) ) |
1363 { |
1304 { |
1364 TInt callState = KErrUnknown; |
1305 // check call status |
1365 |
1306 if ( iSystemEventDetector->IsCallActive() ) |
1366 RMobileCall::TMobileCallStatus linestatus; |
|
1367 |
|
1368 if ( ilineConstructed ) |
|
1369 { |
|
1370 iLine.GetMobileLineStatus( linestatus ); |
|
1371 } |
|
1372 FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() linestatus = %d"), linestatus)); |
|
1373 |
|
1374 TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState); |
|
1375 FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() callState = %d"), callState)); |
|
1376 |
|
1377 // check status from line |
|
1378 if ( linestatus != RMobileCall::EStatusIdle && |
|
1379 linestatus != RMobileCall::EStatusUnknown || |
|
1380 iSystemEventDetector->IsCallActive() ) |
|
1381 { |
1307 { |
1382 FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() EFMRadioEventCallStarted") ) ); |
1308 FTRACE(FPrint(_L("CRadioEngine::MrpoStateChange() EFMRadioEventCallStarted") ) ); |
1383 iInCall = ETrue; |
1309 iInCall = ETrue; |
1384 ret = MRadioEngineStateChangeCallback::EFMRadioEventCallStarted; |
1310 ret = MRadioEngineStateChangeCallback::EFMRadioEventCallStarted; |
1385 } |
1311 } |
1386 } |
1312 } |
1387 else if ( aError == KErrHardwareNotAvailable ) // Radio is interrupted by FM Transmitter activation. |
1313 else if ( aError == KErrHardwareNotAvailable ) // Radio is interrupted by FM Transmitter activation. |
1502 // CRadioEngine::AudioResourcesAvailableL |
1428 // CRadioEngine::AudioResourcesAvailableL |
1503 // This callback notifies when audio resources become available. |
1429 // This callback notifies when audio resources become available. |
1504 // ----------------------------------------------------------------------------- |
1430 // ----------------------------------------------------------------------------- |
1505 // |
1431 // |
1506 void CRadioEngine::AudioResourcesAvailableL() |
1432 void CRadioEngine::AudioResourcesAvailableL() |
1507 { |
1433 { |
1508 FTRACE( FPrint( _L("CRadioEngine::AudioResourcesAvailableL()" ) ) ); |
1434 FTRACE( FPrint( _L("CRadioEngine::AudioResourcesAvailableL()" ) ) ); |
1509 if ( iPubSub && !iInCall && iTunerControl ) // if iPubSub exists, then the ConstructL has been successfully completed |
1435 // if iPubSub exists, then the ConstructL has been successfully completed |
1510 { |
1436 if ( iPubSub && !iInCall && iTunerControl == EStateRadioTunerControlOn ) |
1511 HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventAudioResourceAvailable, KErrNone ); |
1437 { |
1512 } |
1438 HandleCallback(MRadioEngineStateChangeCallback::EFMRadioEventAudioResourceAvailable, KErrNone ); |
1513 } |
1439 } |
|
1440 } |
1514 |
1441 |
1515 // ----------------------------------------------------------------------------- |
1442 // ----------------------------------------------------------------------------- |
1516 // CRadioEngine::AudioAutoResumeForbiddenL |
1443 // CRadioEngine::AudioAutoResumeForbiddenL |
1517 // This callback notifies when audio auto resuming is forbidden. |
1444 // This callback notifies when audio auto resuming is forbidden. |
1518 // ----------------------------------------------------------------------------- |
1445 // ----------------------------------------------------------------------------- |
1825 // CRadioEngine::RequestTunerControl |
1752 // CRadioEngine::RequestTunerControl |
1826 // request tuner control from RadioFmTunerUtility |
1753 // request tuner control from RadioFmTunerUtility |
1827 // ---------------------------------------------------- |
1754 // ---------------------------------------------------- |
1828 // |
1755 // |
1829 EXPORT_C void CRadioEngine::RequestTunerControl() const |
1756 EXPORT_C void CRadioEngine::RequestTunerControl() const |
1830 { |
1757 { |
1831 // Before first RequestTunerControl() call it is ok to enable offline mode without checking capabilities |
1758 FTRACE( FPrint( _L("CRadioEngine::RequestTunerControl()")) ); |
1832 iFmTunerUtility->EnableTunerInOfflineMode( ETrue ); |
1759 if ( iTunerControl == EStateRadioTunerControlUninitialized ) |
1833 iFmTunerUtility->RequestTunerControl(); |
1760 { |
1834 } |
1761 // first request for tuner control. |
|
1762 iFmTunerUtility->RequestTunerControl(); |
|
1763 } |
|
1764 } |
1835 |
1765 |
1836 // ---------------------------------------------------- |
1766 // ---------------------------------------------------- |
1837 // CRadioEngine::DecimalCount |
1767 // CRadioEngine::DecimalCount |
1838 // return decimal count for current region MHz information |
1768 // return decimal count for current region MHz information |
1839 // ---------------------------------------------------- |
1769 // ---------------------------------------------------- |