|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: The RDS receiver implementation for FM Radio |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "fmradiordsreceiver.h" |
|
20 |
|
21 // ======== MEMBER FUNCTIONS ======== |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // CFMRadioRdsReceiver::CFMRadioRdsReceiver |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 CFMRadioRdsReceiver::CFMRadioRdsReceiver( TRadioSettings& aSettings ) : CFMRadioRdsReceiverBase(aSettings) |
|
28 { |
|
29 } |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CFMRadioRdsReceiver::ConstructL |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 void CFMRadioRdsReceiver::ConstructL() |
|
36 { |
|
37 BaseConstructL(); |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CFMRadioRdsReceiver::NewL |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CFMRadioRdsReceiver* CFMRadioRdsReceiver::NewL( TRadioSettings& aSettings ) |
|
45 { |
|
46 CFMRadioRdsReceiver* self = new ( ELeave ) CFMRadioRdsReceiver( aSettings ); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CFMRadioRdsReceiver::~CFMRadioRdsReceiver |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CFMRadioRdsReceiver::~CFMRadioRdsReceiver() |
|
58 { |
|
59 if( iRdsUtility ) |
|
60 { |
|
61 iRdsUtility->Close(); |
|
62 } |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CFMRadioRdsReceiver::InitL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CFMRadioRdsReceiver::InitL( CRadioUtility& aRadioUtility, CFMRadioPubSub* aPubSub ) |
|
70 { |
|
71 iPubSub = aPubSub; |
|
72 |
|
73 iRdsUtility = &aRadioUtility.RadioRdsUtilityL( *this ); |
|
74 |
|
75 SetAutomaticSwitchingL( iSettings.IsRdsAfSearchEnabled() ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CFMRadioRdsReceiver::SetAutomaticSwitchingL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CFMRadioRdsReceiver::SetAutomaticSwitchingL( TBool aEnable ) |
|
83 { |
|
84 if( iRdsUtility ) |
|
85 { |
|
86 User::LeaveIfError( iRdsUtility->SetAutomaticSwitching( aEnable ) ); |
|
87 } |
|
88 |
|
89 CFMRadioRdsReceiverBase::SetAutomaticSwitchingL( aEnable ); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CFMRadioRdsReceiver::StartReceiver |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CFMRadioRdsReceiver::StartReceiver() |
|
97 { |
|
98 TRdsData rdsData; |
|
99 rdsData.iRdsFunctions = ERdsProgrammeService | ERdsAlternateFrequency | ERdsRadioText | ERdsRadioTextPlus; |
|
100 rdsData.iAdditionalFunctions1 = 0; |
|
101 rdsData.iAdditionalFunctions2 = 0; |
|
102 |
|
103 if( iRdsUtility && !iStarted) |
|
104 { |
|
105 if( iRdsUtility->NotifyRdsDataChange( rdsData ) == KErrNone ) |
|
106 { |
|
107 // Avoid further calls |
|
108 iStarted = ETrue; |
|
109 } |
|
110 } |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CFMRadioRdsReceiver::StopReceiver |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void CFMRadioRdsReceiver::StopReceiver() |
|
118 { |
|
119 if( iRdsUtility ) |
|
120 { |
|
121 iRdsUtility->CancelNotifyRdsDataChange(); |
|
122 } |
|
123 iStarted = EFalse; |
|
124 } |