51 /*! |
46 /*! |
52 * |
47 * |
53 */ |
48 */ |
54 RadioPresetStorage::~RadioPresetStorage() |
49 RadioPresetStorage::~RadioPresetStorage() |
55 { |
50 { |
56 delete d_ptr; |
|
57 } |
51 } |
58 |
52 |
59 /*! |
53 /*! |
60 * |
54 * |
61 */ |
55 */ |
62 int RadioPresetStorage::maxNumberOfPresets() const |
56 int RadioPresetStorage::maxNumberOfPresets() const |
63 { |
57 { |
64 Q_D( const RadioPresetStorage ); |
58 Q_D( const RadioPresetStorage ); |
65 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY |
|
66 return d->mPresetUtility->MaxNumberOfPresets(); |
59 return d->mPresetUtility->MaxNumberOfPresets(); |
67 #else |
|
68 TInt maxPresets = 0; |
|
69 d->mPresetUtility->GetMaxNumberOfPresets( maxPresets ); |
|
70 return maxPresets; |
|
71 #endif // COMPILE_WITH_NEW_PRESET_UTILITY |
|
72 } |
60 } |
73 |
61 |
74 /*! |
62 /*! |
75 * |
63 * |
76 */ |
64 */ |
77 int RadioPresetStorage::presetCount() const |
65 int RadioPresetStorage::presetCount() const |
78 { |
66 { |
79 Q_D( const RadioPresetStorage ); |
67 Q_D( const RadioPresetStorage ); |
80 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY |
|
81 return d->mPresetUtility->PresetCount(); |
68 return d->mPresetUtility->PresetCount(); |
82 #else |
|
83 TInt presetCount = 0; |
|
84 d->mPresetUtility->GetNumberOfPresets( presetCount ); |
|
85 return presetCount; |
|
86 #endif // COMPILE_WITH_NEW_PRESET_UTILITY |
|
87 } |
69 } |
88 |
70 |
89 /*! |
71 /*! |
90 * |
72 * |
91 */ |
73 */ |
92 int RadioPresetStorage::firstPreset() const |
74 int RadioPresetStorage::firstPreset() const |
93 { |
75 { |
94 Q_D( const RadioPresetStorage ); |
76 Q_D( const RadioPresetStorage ); |
95 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY |
|
96 return d->mPresetUtility->FirstPreset(); |
77 return d->mPresetUtility->FirstPreset(); |
97 #else |
|
98 TInt firstIndex = -1; |
|
99 TRAPD( err, d->mPresetUtility->GetFirstPresetL( firstIndex ) ); |
|
100 if ( err ) { |
|
101 firstIndex = -1; |
|
102 } |
|
103 return firstIndex; |
|
104 #endif // COMPILE_WITH_NEW_PRESET_UTILITY |
|
105 } |
78 } |
106 |
79 |
107 /*! |
80 /*! |
108 * |
81 * |
109 */ |
82 */ |
110 int RadioPresetStorage::nextPreset( int fromIndex ) const |
83 int RadioPresetStorage::nextPreset( int fromIndex ) const |
111 { |
84 { |
112 Q_D( const RadioPresetStorage ); |
85 Q_D( const RadioPresetStorage ); |
113 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY |
|
114 return d->mPresetUtility->NextPreset( fromIndex ); |
86 return d->mPresetUtility->NextPreset( fromIndex ); |
115 #else |
|
116 TInt nextIndex = -1; |
|
117 TRAPD( err, d->mPresetUtility->GetNextPresetL( fromIndex, nextIndex ) ); |
|
118 if ( err ) { |
|
119 nextIndex = -1; |
|
120 } |
|
121 return nextIndex; |
|
122 #endif // COMPILE_WITH_NEW_PRESET_UTILITY |
|
123 } |
87 } |
124 |
88 |
125 /*! |
89 /*! |
126 * |
90 * |
127 */ |
91 */ |
128 bool RadioPresetStorage::deletePreset( int presetIndex ) |
92 bool RadioPresetStorage::deletePreset( int presetIndex ) |
129 { |
93 { |
130 Q_D( RadioPresetStorage ); |
94 Q_D( RadioPresetStorage ); |
131 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY |
|
132 return d->mPresetUtility->DeletePreset( presetIndex ) == KErrNone; |
95 return d->mPresetUtility->DeletePreset( presetIndex ) == KErrNone; |
133 #else |
|
134 TRAPD( err, d->mPresetUtility->DeletePresetL( presetIndex ) ); |
|
135 return err; |
|
136 #endif // COMPILE_WITH_NEW_PRESET_UTILITY |
|
137 } |
96 } |
138 |
97 |
139 /*! |
98 /*! |
140 * |
99 * |
141 */ |
100 */ |
142 bool RadioPresetStorage::savePreset( const RadioStationIf& station ) |
101 bool RadioPresetStorage::savePreset( const RadioStationIf& station ) |
143 { |
102 { |
144 Q_D( RadioPresetStorage ); |
103 Q_D( RadioPresetStorage ); |
145 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY |
|
146 TPreset preset; |
104 TPreset preset; |
147 preset.SetFrequency( station.frequency() ); |
105 preset.SetFrequency( station.frequency() ); |
148 TPresetName name( station.name().utf16() ); |
106 TPresetName name( station.name().left( KPresetNameLength ).utf16() ); |
149 preset.SetName( name ); |
107 preset.SetName( name ); |
150 preset.SetRenamedByUser( station.isRenamedByUser() ); |
108 preset.SetRenamedByUser( station.isRenamedByUser() ); |
151 preset.SetGenre( station.genre() ); |
109 preset.SetGenre( station.genre() ); |
152 TRadioUrl url( station.url().utf16() ); |
110 TRadioUrl url( station.url().left( KUrlMaxLength ).utf16() ); |
153 preset.SetUrl( url ); |
111 preset.SetUrl( url ); |
154 preset.SetPiCode( station.piCode() ); |
112 preset.SetPiCode( station.piCode() ); |
155 preset.SetFavorite( station.isFavorite() ); |
113 preset.SetFavorite( station.isFavorite() ); |
156 preset.SetLocalStation( station.isLocalStation() ); |
114 preset.SetLocalStation( station.isLocalStation() ); |
157 |
115 |
158 TRAPD( err, d->mPresetUtility->SavePresetL( preset, station.presetIndex() ) ); |
116 TRAPD( err, d->mPresetUtility->SavePresetL( preset, station.presetIndex() ) ); |
159 return err == KErrNone; |
117 return err == KErrNone; |
160 #else |
|
161 TFmPresetName name( station.name().utf16() ); |
|
162 TRAPD( err, d->mPresetUtility->SetPresetL( station.presetIndex(), name, station.frequency() ) ); |
|
163 return err == KErrNone; |
|
164 #endif // COMPILE_WITH_NEW_PRESET_UTILITY |
|
165 } |
118 } |
166 |
119 |
167 /*! |
120 /*! |
168 * |
121 * |
169 */ |
122 */ |
170 bool RadioPresetStorage::readPreset( int index, RadioStationIf& station ) |
123 bool RadioPresetStorage::readPreset( int index, RadioStationIf& station ) |
171 { |
124 { |
172 Q_D( RadioPresetStorage ); |
125 Q_D( RadioPresetStorage ); |
173 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY |
|
174 TPreset preset; |
126 TPreset preset; |
175 TRAPD( err, d->mPresetUtility->ReadPresetL( index, preset ) ); |
127 TRAPD( err, d->mPresetUtility->ReadPresetL( index, preset ) ); |
176 if ( !err ) { |
128 if ( !err ) { |
177 |
129 |
178 station.setPresetIndex( index ); |
130 station.setPresetIndex( index ); |