1 /* |
|
2 * Copyright (c) 2008 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: Profile Settings Handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 #include <e32base.h> |
|
21 #include <centralrepository.h> |
|
22 #include <ProfileEngineSDKCRKeys.h> |
|
23 #include <hwrmvibrasdkcrkeys.h> |
|
24 |
|
25 // User Includes |
|
26 #include "evtutilsconsts.h" |
|
27 #include "evtprofilehandler.h" |
|
28 #include "evtdebug.h" |
|
29 |
|
30 // Constants |
|
31 static const TInt KSilentRing = 4; |
|
32 |
|
33 // ================ Member funtions for CEvtProfileHandler class =============== |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CEvtProfileHandler::CEvtProfileHandler |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CEvtProfileHandler::CEvtProfileHandler( MEvtProfileObserver& aObserver ): |
|
40 iObserver(aObserver) |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CEvtProfileHandler::~CEvtProfileHandler |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CEvtProfileHandler::~CEvtProfileHandler() |
|
49 { |
|
50 |
|
51 if( iVibraNotifyHandler ) |
|
52 { |
|
53 iVibraNotifyHandler->StopListening(); |
|
54 } |
|
55 |
|
56 if( iTypeNotifyHandler ) |
|
57 { |
|
58 iTypeNotifyHandler->StopListening(); |
|
59 } |
|
60 |
|
61 if( iVolumeNotifyHandler ) |
|
62 { |
|
63 iVolumeNotifyHandler->StopListening(); |
|
64 } |
|
65 |
|
66 delete iVibraNotifyHandler; |
|
67 delete iTypeNotifyHandler; |
|
68 delete iVolumeNotifyHandler; |
|
69 |
|
70 delete iProfileSession; |
|
71 delete iVibraSession; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CEvtProfileHandler::NewL |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 CEvtProfileHandler* CEvtProfileHandler::NewL( MEvtProfileObserver& aObserver ) |
|
79 { |
|
80 CEvtProfileHandler* self = NewLC( aObserver ); |
|
81 CleanupStack::Pop( self ); |
|
82 return self; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CEvtProfileHandler::NewLC |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 CEvtProfileHandler* CEvtProfileHandler::NewLC( MEvtProfileObserver& aObserver ) |
|
90 { |
|
91 CEvtProfileHandler* self = new ( ELeave )CEvtProfileHandler( aObserver ); |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL( ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CEvtProfileHandler::ConstructL |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void CEvtProfileHandler::ConstructL() |
|
102 { |
|
103 EVTUIDEBUG( "+ CEvtProfileHandler::ConstructL()" ); |
|
104 |
|
105 // Create a cenrep session each for Profile and Vibra Cenrep Settings. |
|
106 iProfileSession = CRepository::NewL( KCRUidProfileEngine ); |
|
107 iVibraSession = CRepository::NewL( KCRUidVibraCtrl ); |
|
108 |
|
109 // Create the cenrep notification handlers to listen to the settings |
|
110 // value changes. |
|
111 iVolumeNotifyHandler = CCenRepNotifyHandler::NewL(*this, |
|
112 *iProfileSession, |
|
113 CCenRepNotifyHandler::EIntKey, |
|
114 KProEngActiveRingingVolume); |
|
115 |
|
116 iTypeNotifyHandler = CCenRepNotifyHandler::NewL(*this, |
|
117 *iProfileSession, |
|
118 CCenRepNotifyHandler::EIntKey, |
|
119 KProEngActiveRingingType); |
|
120 |
|
121 iVibraNotifyHandler = CCenRepNotifyHandler::NewL(*this, |
|
122 *iVibraSession, |
|
123 CCenRepNotifyHandler::EIntKey, |
|
124 KVibraCtrlProfileVibraEnabled); |
|
125 |
|
126 // Get the initial value of the Settings. |
|
127 User::LeaveIfError( iProfileSession->Get( KProEngActiveRingingVolume, iRingingVolume ) ); |
|
128 User::LeaveIfError( iProfileSession->Get( KProEngActiveRingingType, iRingingType ) ); |
|
129 User::LeaveIfError( iVibraSession->Get( KVibraCtrlProfileVibraEnabled, iVibra ) ); |
|
130 |
|
131 // Start listening to settings change. |
|
132 iVolumeNotifyHandler->StartListeningL(); |
|
133 iTypeNotifyHandler->StartListeningL(); |
|
134 iVibraNotifyHandler->StartListeningL(); |
|
135 |
|
136 EVTUIDEBUG( "- CEvtProfileHandler::ConstructL()" ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CEvtProfileHandler::Volume |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 TInt CEvtProfileHandler::Volume( ) |
|
144 { |
|
145 EVTUIDEBUG1( "= CEvtProfileHandler::Volume() - %d", iRingingVolume ); |
|
146 return iRingingVolume; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CEvtProfileHandler::IsSilentRingingType |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 TBool CEvtProfileHandler::IsSilentRingingType( ) |
|
154 { |
|
155 EVTUIDEBUG1( "= CEvtProfileHandler::IsSilentRingingType() - %d", iRingingType ); |
|
156 if( iRingingType == KSilentRing ) |
|
157 return ETrue; |
|
158 else |
|
159 return EFalse; |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CEvtProfileHandler::IsVibra |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 TBool CEvtProfileHandler::IsVibra( ) |
|
167 { |
|
168 EVTUIDEBUG1( "= CEvtProfileHandler::IsVibra() - %d", iVibra ); |
|
169 return iVibra; |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CEvtProfileHandler::HandleNotifyInt() |
|
174 // (other items were commented in a header). |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CEvtProfileHandler::HandleNotifyInt(TUint32 aId, TInt aNewValue) |
|
178 { |
|
179 |
|
180 if ( aId == KProEngActiveRingingVolume ) |
|
181 { |
|
182 iRingingVolume = aNewValue; |
|
183 } |
|
184 else if ( aId == KProEngActiveRingingType ) |
|
185 { |
|
186 iRingingType = aNewValue; |
|
187 } |
|
188 else if ( aId == KVibraCtrlProfileVibraEnabled ) |
|
189 { |
|
190 iVibra = aNewValue; |
|
191 } |
|
192 iObserver.HandleProfileSettingsChange(); |
|
193 } |
|