1 /* |
|
2 * Copyright (c) 2002 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: Settings handler for the settings outside of Profiles. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "CProfilesGSTonesPluginSettingsHandler.h" |
|
22 |
|
23 // INTERNAL INCLUDES |
|
24 #include "CProfilesGSTonesPluginFileListSettingItem.h" |
|
25 #include "ProfilesGSTonesPlugin.hrh" |
|
26 #include "ProfilesDebug.h" |
|
27 |
|
28 // INCLUDES FROM PROFILES SETTINGS VIEW |
|
29 #include <ProfilePanics.h> |
|
30 #include <ProfileSettingsView.hrh> |
|
31 #include <MProfileExternalSettingsObserver.h> |
|
32 |
|
33 // SYSTEM INCLUDES |
|
34 #include <centralrepository.h> |
|
35 #include <CalendarInternalCRKeys.h> |
|
36 #include <ClockDomainCRKeys.h> |
|
37 #include <ProfileEngineDomainCRKeys.h> |
|
38 #include <CoeHelp.h> |
|
39 #include <csxhelp/mode.hlp.hrh> |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CProfilesGSTonesPluginSettingsHandler::CProfilesGSTonesPluginSettingsHandler |
|
45 // C++ constructor can NOT contain any code, that might leave. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CProfilesGSTonesPluginSettingsHandler::CProfilesGSTonesPluginSettingsHandler( |
|
49 CCoeEnv* aCoeEnv ) |
|
50 : iCoeEnv( aCoeEnv ) |
|
51 { |
|
52 } |
|
53 |
|
54 // Destructor |
|
55 CProfilesGSTonesPluginSettingsHandler::~CProfilesGSTonesPluginSettingsHandler() |
|
56 { |
|
57 DrmDelete(); |
|
58 if( iClockNotifyHandler ) |
|
59 { |
|
60 iClockNotifyHandler->StopListening(); |
|
61 } |
|
62 if( iCalendarNotifyHandler ) |
|
63 { |
|
64 iCalendarNotifyHandler->StopListening(); |
|
65 } |
|
66 |
|
67 delete iClockNotifyHandler; |
|
68 delete iCalendarNotifyHandler; |
|
69 |
|
70 delete iClockSession; |
|
71 delete iCalendarSession; |
|
72 delete iCalendarInterface; |
|
73 delete iClockInterface; |
|
74 |
|
75 delete iTonesViewSettings; |
|
76 delete iFeatures; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CProfilesGSTonesPluginSettingsHandler::ConstructL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CProfilesGSTonesPluginSettingsHandler::ConstructL() |
|
84 { |
|
85 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::ConstructL begin" ); |
|
86 iFeatures = CProfilesGSTonesViewFeatures::NewL(); |
|
87 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::ConstructL after features" ); |
|
88 iTonesViewSettings = CProfilesGSTonesViewSettings::NewL( *iFeatures ); |
|
89 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::ConstructL after settings" ); |
|
90 |
|
91 iClockSession = CRepository::NewL( KCRUidClockApp ); |
|
92 iCalendarSession = CRepository::NewL( KCRUidCalendar ); |
|
93 |
|
94 iClockNotifyHandler = CCenRepNotifyHandler::NewL( *this, |
|
95 *iClockSession, |
|
96 CCenRepNotifyHandler::EStringKey, |
|
97 KClockAppSoundFile ); |
|
98 |
|
99 iClockNotifyHandler->StartListeningL(); |
|
100 |
|
101 iCalendarNotifyHandler = CCenRepNotifyHandler::NewL( *this, |
|
102 *iCalendarSession, |
|
103 CCenRepNotifyHandler::EStringKey, |
|
104 KCalendarSoundFile ); |
|
105 |
|
106 iCalendarNotifyHandler->StartListeningL(); |
|
107 |
|
108 User::LeaveIfError( iClockSession->Get( KClockAppSoundFile, iClockTone ) ); |
|
109 User::LeaveIfError( iCalendarSession->Get( KCalendarSoundFile, |
|
110 iCalendarTone ) ); |
|
111 DrmConstructL(); |
|
112 |
|
113 iCalendarInterface = |
|
114 new ( ELeave ) CProfilesGSTonesPluginCalendarDataInterface( *this ); |
|
115 iClockInterface = |
|
116 new ( ELeave ) CProfilesGSTonesPluginClockDataInterface( *this ); |
|
117 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::ConstructL end" ); |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CProfilesGSTonesPluginSettingsHandler::NewL |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 CProfilesGSTonesPluginSettingsHandler* |
|
125 CProfilesGSTonesPluginSettingsHandler::NewL( CCoeEnv* aCoeEnv ) |
|
126 { |
|
127 CProfilesGSTonesPluginSettingsHandler* self = new ( ELeave ) |
|
128 CProfilesGSTonesPluginSettingsHandler( aCoeEnv ); |
|
129 CleanupStack::PushL( self ); |
|
130 self->ConstructL(); |
|
131 CleanupStack::Pop( self ); |
|
132 return self; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CProfilesGSTonesPluginSettingsHandler::CreateSettingItemL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CAknSettingItem* CProfilesGSTonesPluginSettingsHandler::CreateSettingItemL( |
|
140 TInt aIdentifier ) |
|
141 { |
|
142 PRODEBUG1( "CProfilesGSTonesPluginSettingHandler::CreateSettingItemL(%d) begin",aIdentifier ); |
|
143 TFileName defaultToneFile; |
|
144 CAknSettingItem* item = NULL; |
|
145 |
|
146 switch( aIdentifier ) |
|
147 { |
|
148 case EProfileGSTonesPluginSettingCalendarToneId: |
|
149 { |
|
150 User::LeaveIfError( iCalendarSession->Get( KCalendarDefaultSoundFile, |
|
151 defaultToneFile ) ); |
|
152 item = new ( ELeave ) CProfilesGSTonesPluginFileListSettingItem( |
|
153 aIdentifier, defaultToneFile, iCoeEnv, *iCalendarInterface ); |
|
154 break; |
|
155 } |
|
156 case EProfileGSTonesPluginSettingClockToneId: |
|
157 { |
|
158 User::LeaveIfError( iClockSession->Get( KClockAppDefaultSoundFile, |
|
159 defaultToneFile ) ); |
|
160 item = new ( ELeave ) CProfilesGSTonesPluginFileListSettingItem( |
|
161 aIdentifier, defaultToneFile, iCoeEnv, *iClockInterface ); |
|
162 |
|
163 break; |
|
164 } |
|
165 case EProfileGSTonesPluginSettingHacModeId: |
|
166 { |
|
167 item = new( ELeave ) CAknBinaryPopupSettingItem( |
|
168 aIdentifier, iTonesViewSettings->iHac ); |
|
169 break; |
|
170 } |
|
171 default: |
|
172 { |
|
173 User::Panic( KProfilePanicText, EProfilePanicInvalidSettingItemId ); |
|
174 break; |
|
175 } |
|
176 } |
|
177 |
|
178 PRODEBUG1( "CProfilesGSTonesPluginSettingHandler::CreateSettingItemL(%d) end",aIdentifier ); |
|
179 return item; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CProfilesGSTonesPluginSettingsHandler::SetObserver |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CProfilesGSTonesPluginSettingsHandler::SetObserver( |
|
187 MProfileExternalSettingsObserver& aObserver ) |
|
188 { |
|
189 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::SetObserver" ); |
|
190 iObserver = &aObserver; |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CProfilesGSTonesPluginSettingsHandler::AllowedToChange |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 TBool CProfilesGSTonesPluginSettingsHandler::AllowedToChange( |
|
198 TInt aSettingItemId ) const |
|
199 { |
|
200 switch( aSettingItemId ) |
|
201 { |
|
202 case EProfileGSTonesPluginSettingCalendarToneId: // Fall through |
|
203 case EProfileGSTonesPluginSettingClockToneId: |
|
204 { |
|
205 return ETrue; |
|
206 } |
|
207 case EProfileGSTonesPluginSettingHacModeId: |
|
208 { |
|
209 return ( iFeatures->IsLocalFeatureSupported( |
|
210 KTonesViewFeatureIdHac ) ); |
|
211 } |
|
212 default: |
|
213 { |
|
214 return EFalse; |
|
215 } |
|
216 } |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CProfilesGSTonesPluginSettingsHandler::GetHelpContext |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 TBool CProfilesGSTonesPluginSettingsHandler::GetHelpContext( |
|
224 TCoeHelpContext& aContext ) const |
|
225 { |
|
226 aContext.iContext = KSET_HLP_PERSONAL_TONES; |
|
227 return ETrue; |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CProfilesGSTonesPluginSettingsHandler::SetHiddenItems |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CProfilesGSTonesPluginSettingsHandler::SetHiddenItems( |
|
235 CAknSettingItemArray& aSettingItemArray ) const |
|
236 { |
|
237 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::SetHiddenItems" ); |
|
238 TInt count( aSettingItemArray.Count() ); |
|
239 for( TInt index( 0 ); index < count; index++ ) |
|
240 { |
|
241 CAknSettingItem* item = aSettingItemArray.At( index ); |
|
242 if( ( item->Identifier() == EProfileGSTonesPluginSettingHacModeId ) ) |
|
243 { |
|
244 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::SetHiddenItems hac" ); |
|
245 item->SetHidden( |
|
246 !iFeatures->IsLocalFeatureSupported( KTonesViewFeatureIdHac ) ); |
|
247 } |
|
248 } |
|
249 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::SetHiddenItems end" ); |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CProfilesGSTonesPluginSettingsHandler::StoreIfChangedL |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void CProfilesGSTonesPluginSettingsHandler::StoreIfChangedL( TInt aSettingId ) |
|
257 { |
|
258 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::StoreIfChanged" ); |
|
259 iTonesViewSettings->StoreIfChangedL( aSettingId ); |
|
260 PRODEBUG( "CProfilesGSTonesPluginSettingHandler::StoreIfChanged end" ); |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CProfilesGSTonesPluginSettingsHandler::HandleNotifyString |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 void CProfilesGSTonesPluginSettingsHandler::HandleNotifyString( TUint32 aId, |
|
268 const TDesC16& /* aNewValue */ ) |
|
269 { |
|
270 PRODEBUG1( "CProfilesGSTonesPluginSettingHandler::HandleNotifyString(%d) begin",aId ); |
|
271 if( aId == KCalendarSoundFile ) |
|
272 { // cannot leave - ignore return value: |
|
273 iCalendarSession->Get( KCalendarSoundFile, iCalendarTone ); |
|
274 } |
|
275 else // Clock sound file |
|
276 { // cannot leave - ignore return value: |
|
277 iClockSession->Get( KClockAppSoundFile, iClockTone ); |
|
278 } |
|
279 TRAP_IGNORE( iObserver->HandleExternalSettingsChangedL() ); |
|
280 PRODEBUG1( "CProfilesGSTonesPluginSettingHandler::HandleNotifyString(%d) end",aId ); |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CProfilesGSTonesPluginSettingsHandler::StoreCalendarToneL |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 void CProfilesGSTonesPluginSettingsHandler::StoreCalendarToneL( |
|
288 const TDesC& aTone ) |
|
289 { |
|
290 PRODEBUG1( "CProfilesGSTonesPluginSettingHandler::StoreCalendarTone(%S)",&aTone ); |
|
291 if( iCalendarTone.CompareF( aTone ) != 0 ) |
|
292 { |
|
293 User::LeaveIfError( |
|
294 iCalendarSession->Set( KCalendarSoundFile, aTone ) ); |
|
295 RemoveAutomatedContent( iCalendarTone ); |
|
296 iCalendarTone.Copy( aTone ); |
|
297 } |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CProfilesGSTonesPluginSettingsHandler::StoreClockToneL |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void CProfilesGSTonesPluginSettingsHandler::StoreClockToneL( |
|
305 const TDesC& aTone ) |
|
306 { |
|
307 PRODEBUG1( "CProfilesGSTonesPluginSettingHandler::StoreClockTone(%S)",&aTone ); |
|
308 if( iClockTone.CompareF( aTone ) != 0 ) |
|
309 { |
|
310 User::LeaveIfError( |
|
311 iClockSession->Set( KClockAppSoundFile, aTone ) ); |
|
312 RemoveAutomatedContent( iClockTone ); |
|
313 iClockTone.Copy( aTone ); |
|
314 } |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CProfilesGSTonesPluginCalendarDataInterface:: |
|
319 // CProfilesGSTonesPluginCalendarDataInterface |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 CProfilesGSTonesPluginCalendarDataInterface:: |
|
323 CProfilesGSTonesPluginCalendarDataInterface( |
|
324 CProfilesGSTonesPluginSettingsHandler& aSettingsHandler ) |
|
325 : iSettingsHandler( aSettingsHandler ) |
|
326 {} |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CProfilesGSTonesPluginCalendarDataInterface::ItemData |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 const TDesC& CProfilesGSTonesPluginCalendarDataInterface::ItemData() |
|
333 { |
|
334 return iSettingsHandler.iCalendarTone; |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CProfilesGSTonesPluginCalendarDataInterface::SetItemDataL |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 void CProfilesGSTonesPluginCalendarDataInterface::SetItemDataL( |
|
342 const TDesC& aDataBuf ) |
|
343 { |
|
344 PRODEBUG( "CProfilesGSTonesPluginCalendarDataInterface::SetItemDataL" ); |
|
345 iSettingsHandler.StoreCalendarToneL( aDataBuf ); |
|
346 PRODEBUG( "CProfilesGSTonesPluginCalendarDataInterface::SetItemDataL end" ); |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CProfilesGSTonesPluginClockDataInterface:: |
|
351 // CProfilesGSTonesPluginClockDataInterface |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 CProfilesGSTonesPluginClockDataInterface:: |
|
355 CProfilesGSTonesPluginClockDataInterface( |
|
356 CProfilesGSTonesPluginSettingsHandler& aSettingsHandler ) |
|
357 : iSettingsHandler( aSettingsHandler ) |
|
358 {} |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CProfilesGSTonesPluginClockDataInterface::ItemData |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 const TDesC& CProfilesGSTonesPluginClockDataInterface::ItemData() |
|
365 { |
|
366 return iSettingsHandler.iClockTone; |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CProfilesGSTonesPluginClockDataInterface::SetItemDataL |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 void CProfilesGSTonesPluginClockDataInterface::SetItemDataL( |
|
374 const TDesC& aDataBuf ) |
|
375 { |
|
376 PRODEBUG( "CProfilesGSTonesPluginClockDataInterface::SetItemDataL" ); |
|
377 iSettingsHandler.StoreClockToneL( aDataBuf ); |
|
378 PRODEBUG( "CProfilesGSTonesPluginClockDataInterface::SetItemDataL end" ); |
|
379 } |
|
380 |
|
381 // End Of File |
|
382 |
|