|
1 /* |
|
2 * Copyright (c) 2005 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: Contains phone engine base central repository monitor class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cpeincallearvolumesettingmonitor.h" |
|
21 #include "mpephonemodelinternal.h" |
|
22 #include <centralrepository.h> |
|
23 #include <mpedatastore.h> |
|
24 #include <talogger.h> |
|
25 #include <telephonyvariant.hrh> |
|
26 #include <telincallvolcntrlcrkeys.h> |
|
27 |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CPEIncallEarVolumeSettingMonitor::NewL |
|
31 // Two-phased constructor. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CPEIncallEarVolumeSettingMonitor* CPEIncallEarVolumeSettingMonitor::NewL( |
|
35 MPEPhoneModelInternal& aModel ) |
|
36 { |
|
37 CPEIncallEarVolumeSettingMonitor* self = new ( ELeave ) CPEIncallEarVolumeSettingMonitor( |
|
38 aModel ); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop( self); |
|
42 return ( self ); |
|
43 } |
|
44 |
|
45 // Destructor |
|
46 CPEIncallEarVolumeSettingMonitor::~CPEIncallEarVolumeSettingMonitor() |
|
47 { |
|
48 // Cancel() is called by base class destructor, which also deletes iRepository |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CPEIncallEarVolumeSettingMonitor::CPEIncallEarVolumeSettingMonitor |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CPEIncallEarVolumeSettingMonitor::CPEIncallEarVolumeSettingMonitor( |
|
58 MPEPhoneModelInternal& aModel |
|
59 ) : CPECenRepMonitor( KTelIncallEarVolume ), |
|
60 iModel( aModel ), |
|
61 iUpdateInProgress( EFalse ) |
|
62 { |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CPEIncallEarVolumeSettingMonitor::ConstructL |
|
67 // Symbian 2nd phase constructor can leave. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CPEIncallEarVolumeSettingMonitor::ConstructL() |
|
71 { |
|
72 BaseConstructL( KCRUidInCallVolume ); |
|
73 |
|
74 TInt volume = KPEDefaultAudioVolume; // Default setting |
|
75 Get( volume ); |
|
76 TEFLOGSTRING2( |
|
77 KTAREQOUT, |
|
78 "PE CPEIncallEarVolumeSettingMonitor::ConstructL, Incall ear volume = %d ", |
|
79 volume ); |
|
80 // Write audio volume to EngineInfo. |
|
81 iModel.DataStore()->SetAudioVolume( volume ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CPEIncallEarVolumeSettingMonitor::Set |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 TInt CPEIncallEarVolumeSettingMonitor::Set( |
|
89 TInt aValue ) |
|
90 { |
|
91 TInt errorCode( KErrNone ); |
|
92 |
|
93 // Check whether this function call was initiated by a central repository |
|
94 // change notification. |
|
95 if( iUpdateInProgress == EFalse ) |
|
96 { |
|
97 errorCode = iRepository->Set( iMonitorSetting, aValue ); |
|
98 TEFLOGSTRING3( KTAREQOUT, "PE CPEIncallEarVolumeSettingMonitor::Set \ |
|
99 > CRepository::Set, Incall ear volume = %d, error code: %d", aValue, errorCode ); |
|
100 } |
|
101 |
|
102 return errorCode; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CPEIncallEarVolumeSettingMonitor::UpdateL |
|
107 // Symbian 2nd phase constructor can leave. |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CPEIncallEarVolumeSettingMonitor::UpdateL() |
|
111 { |
|
112 TInt volume; |
|
113 // The headset volume has changed in repository. |
|
114 // Retrieve the current volume from repository. |
|
115 User::LeaveIfError( Get( volume ) ); |
|
116 |
|
117 TEFLOGSTRING2( |
|
118 KTAREQOUT, |
|
119 "PE: CPEIncallEarVolumeSettingMonitor::UpdateL, Incall ear volume = %d ", |
|
120 volume ); |
|
121 |
|
122 // Update headset volume using an audiohandling routine |
|
123 // The routine will try to update the repository as well, |
|
124 // ensure this is blocked using an internal flag. |
|
125 iUpdateInProgress = ETrue; |
|
126 iModel.DataStore()->SetAudioVolumeCommand( volume ); |
|
127 iModel.HandleInternalMessage( MPEPhoneModel::EPEMessageSetAudioVolume ); |
|
128 |
|
129 // Reset the flag when synchronization is complete |
|
130 iUpdateInProgress = EFalse; |
|
131 |
|
132 } |
|
133 |
|
134 // End of file |