|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_RADIOENGINESETTINGS_H |
|
19 #define C_RADIOENGINESETTINGS_H |
|
20 |
|
21 // User includes |
|
22 #include "mradioenginesettings.h" |
|
23 #include "mradiosettingssetter.h" |
|
24 #include "cradioregion.h" |
|
25 |
|
26 // Forward declarations |
|
27 class MRadioSettingsObserver; |
|
28 class CRepository; |
|
29 class CRadioSettingsImp; |
|
30 |
|
31 // Constants |
|
32 |
|
33 /** |
|
34 * Maximum size of the network country code. |
|
35 * From CTelephony::TNetworkInfoV1 in etel3rdparty.h |
|
36 */ |
|
37 enum { KNetworkCountryCodeSize = 4 }; |
|
38 |
|
39 /** |
|
40 * Maximum size of the network identity. |
|
41 * From CTelephony::TNetworkInfoV1 in etel3rdparty.h |
|
42 */ |
|
43 enum { KNetworkIdentitySize = 8 }; |
|
44 |
|
45 /** |
|
46 * Concrete implementation of radio settings. |
|
47 */ |
|
48 NONSHARABLE_CLASS( CRadioEngineSettings ) : public CBase |
|
49 , public MRadioSettingsSetter |
|
50 { |
|
51 |
|
52 public: |
|
53 |
|
54 static CRadioEngineSettings* NewL( CRadioSettingsImp& aRadioSettingsImp ); |
|
55 |
|
56 ~CRadioEngineSettings(); |
|
57 |
|
58 /** |
|
59 * Determines if region is allowed. |
|
60 */ |
|
61 TBool IsRegionAllowed( TRadioRegion aRegionId ) const; |
|
62 |
|
63 private: |
|
64 |
|
65 CRadioEngineSettings( CRadioSettingsImp& aRadioSettingsImp ); |
|
66 |
|
67 void ConstructL(); |
|
68 |
|
69 // from base class MRadioEngineSettings |
|
70 |
|
71 TInt HeadsetVolume() const; |
|
72 TInt SpeakerVolume() const; |
|
73 TInt Volume() const; |
|
74 TInt OutputMode() const; |
|
75 TInt AudioRoute() const; |
|
76 TBool IsHeadsetVolMuted() const; |
|
77 TBool IsSpeakerVolMuted() const; |
|
78 TBool IsVolMuted() const; |
|
79 TBool IsPowerOn() const; |
|
80 TUint32 TunedFrequency() const; |
|
81 TInt DefaultMinVolumeLevel() const; |
|
82 TInt CountRegions() const; |
|
83 CRadioRegion& Region( TInt aIndex ) const; |
|
84 TRadioRegion RegionId() const; |
|
85 TUint32 FrequencyStepSize() const; |
|
86 TUint32 MaxFrequency() const; |
|
87 TUint32 MinFrequency() const; |
|
88 TInt DecimalCount() const; |
|
89 TRadioRegion DefaultRegion() const; |
|
90 TPtrC NetworkId() const; |
|
91 TPtrC CountryCode() const; |
|
92 |
|
93 // from base class MRadioSettingsSetter |
|
94 |
|
95 void SetObserver( MRadioSettingsObserver* aObserver ); |
|
96 TInt SetHeadsetVolume( TInt aVolume ); |
|
97 TInt SetSpeakerVolume( TInt aVolume ); |
|
98 TInt SetVolume( TInt aVolume ); |
|
99 TInt SetOutputMode( TInt aOutputMode ); |
|
100 TInt SetAudioRoute( TInt aAudioRoute ); |
|
101 TInt SetHeadsetVolMuted( TBool aMuted ); |
|
102 TInt SetSpeakerVolMuted( TBool aMuted ); |
|
103 TInt SetVolMuted( TBool aMuted ); |
|
104 TInt SetPowerOn( TBool aPowerState ); |
|
105 TInt SetTunedFrequency( TUint32 aFrequency ); |
|
106 TInt SetRegionId( TInt aRegion ); |
|
107 TInt SetNetworkId( const TDesC& aNetworkId ); |
|
108 TInt SetCountryCode( const TDesC& aCountryCode ); |
|
109 |
|
110 // New functions |
|
111 |
|
112 /** |
|
113 * Initializes the data holders |
|
114 */ |
|
115 void InitializeDataHolders(); |
|
116 |
|
117 /** |
|
118 * Gets a repository value and sets the default value if the key is not found |
|
119 */ |
|
120 TBool GetRepositoryValue( int aKey, TInt& aValue, TInt aDefault ); |
|
121 |
|
122 /** |
|
123 * Sets a boolean value to cenrep and data holder |
|
124 */ |
|
125 TInt SetFlagValue( int aKey, int aFlagId, TInt aValue ); |
|
126 |
|
127 /** |
|
128 * Initializes the regions as defined in the resource file. |
|
129 */ |
|
130 void InitializeRegionsL(); |
|
131 |
|
132 /** |
|
133 * Converts Region ID to index |
|
134 * |
|
135 * @param aRegionId The region ID that is wanted to convert |
|
136 * @return The region index, KErrNotFound if no match found |
|
137 */ |
|
138 TInt RegionIndexForId( TInt aRegionId ) const; |
|
139 |
|
140 /** |
|
141 * Updates the current region index |
|
142 * |
|
143 * @param aRegionId The new region ID |
|
144 */ |
|
145 void UpdateCurrentRegionIdx( TInt aRegionId ); |
|
146 |
|
147 private: // data |
|
148 |
|
149 /** |
|
150 * The observer for the setting changes. |
|
151 * Not own. |
|
152 */ |
|
153 MRadioSettingsObserver* iObserver; |
|
154 |
|
155 /** |
|
156 * The available regions. |
|
157 */ |
|
158 RRadioRegionArray iRegions; |
|
159 |
|
160 /** |
|
161 * The current region. |
|
162 */ |
|
163 TInt iCurrentRegionIdx; |
|
164 |
|
165 CRadioSettingsImp& iRadioSettingsImp; |
|
166 |
|
167 RResourceFile iResFile; |
|
168 |
|
169 CRepository* iRepository; |
|
170 |
|
171 // Data holders for quick access |
|
172 TBitFlags iFlags; |
|
173 TBuf<KNetworkIdentitySize> iNetworkId; |
|
174 TBuf<KNetworkCountryCodeSize> iCountryCode; |
|
175 TInt iHeadsetVolume; |
|
176 TInt iSpeakerVolume; |
|
177 TUint32 iFrequency; |
|
178 TInt iDefaultMinVolume; |
|
179 TRadioRegion iDefaultRegion; |
|
180 TRadioRegion iRegionId; |
|
181 |
|
182 }; |
|
183 |
|
184 #endif // C_RADIOENGINESETTINGS_H |