|
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: Implementation of the CTelDMGripHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include <mphonedevicemodeobserver.h> |
|
23 #include <hwrmdomainpskeys.h> |
|
24 #include "CTelDMGripHandler.h" |
|
25 #include "MTelDMAccessory.h" |
|
26 #include "CTelDMCommandHandler.h" |
|
27 #include <settingsinternalcrkeys.h> |
|
28 #include <centralrepository.h> |
|
29 |
|
30 // MODULE DATA STRUCTURES |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CTelDMGripHandler::NewL |
|
36 // |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CTelDMGripHandler* CTelDMGripHandler::NewL( CTelDMCommandHandler& aCommandHandler ) |
|
40 { |
|
41 |
|
42 CTelDMGripHandler* self = |
|
43 new ( ELeave ) CTelDMGripHandler( aCommandHandler ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CTelDMGripHandler::CTelDMGripHandler |
|
53 // |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CTelDMGripHandler::CTelDMGripHandler( CTelDMCommandHandler& aCommandHandler ): |
|
57 CActive( CActive::EPriorityStandard ), |
|
58 iCommandHandler ( aCommandHandler ) |
|
59 { |
|
60 CActiveScheduler::Add( this ); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CTelDMGripHandler::~CTelDMGripHandler |
|
65 // |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CTelDMGripHandler::~CTelDMGripHandler() |
|
69 { |
|
70 Cancel(); |
|
71 iProperty.Close(); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CTelDMGripHandler::ConstructL |
|
76 // |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CTelDMGripHandler::ConstructL() |
|
80 { |
|
81 /// Attach to key. Start listening for changes. |
|
82 iProperty.Attach( KPSUidHWRM, KHWRMGripStatus ); |
|
83 IssueRequest(); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CTelDMGripHandler::HandleChange |
|
88 // |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CTelDMGripHandler::HandleChange() |
|
92 { |
|
93 TInt err( KErrNone ); |
|
94 TInt state( KErrNone ); |
|
95 err = RProperty::Get( |
|
96 KPSUidHWRM, |
|
97 KHWRMGripStatus, |
|
98 state ); |
|
99 |
|
100 if ( err == KErrNone && state == EPSHWRMGripOpen && IsSliderCallAnswer() ) |
|
101 { |
|
102 iCommandHandler.HandleCommand( CTelDMCommandHandler::EGripOpen ); |
|
103 } |
|
104 else if ( err == KErrNone && state == EPSHWRMGripClosed && IsSliderCallEnd()) |
|
105 { |
|
106 iCommandHandler.HandleCommand( CTelDMCommandHandler::EGripClose ); |
|
107 } |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CTelDMGripHandler::RunL |
|
113 // Cannot leave, no RunError implementation |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CTelDMGripHandler::RunL() |
|
117 { |
|
118 if ( iStatus.Int() == KErrNone ) |
|
119 { |
|
120 HandleChange(); |
|
121 } |
|
122 IssueRequest(); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CTelDMGripHandler::DoCancel |
|
127 // |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CTelDMGripHandler::DoCancel() |
|
131 { |
|
132 iProperty.Cancel(); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CTelDMGripHandler::IssueRequest |
|
137 // |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CTelDMGripHandler::IssueRequest() |
|
141 { |
|
142 if ( !IsActive() ) |
|
143 { |
|
144 iProperty.Subscribe( iStatus ); |
|
145 SetActive(); |
|
146 } |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------- |
|
150 // CPhoneState::IsSliderCallAnswer |
|
151 // --------------------------------------------------------- |
|
152 // |
|
153 TBool CTelDMGripHandler::IsSliderCallAnswer() const |
|
154 { |
|
155 TInt answerEnabled = 0; |
|
156 TBool retVal ( EFalse ); |
|
157 TInt err = GetInt( |
|
158 KCRUidTelephonySettings, |
|
159 KSettingsOpeningSlideAnswer, |
|
160 answerEnabled ); |
|
161 |
|
162 if ( err == KErrNone && answerEnabled ) |
|
163 { |
|
164 retVal = ETrue; |
|
165 } |
|
166 return retVal; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CPhoneState::IsSliderCallEnd |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 TBool CTelDMGripHandler::IsSliderCallEnd() const |
|
174 { |
|
175 TInt endEnabled = 0; |
|
176 TBool retVal ( EFalse ); |
|
177 TInt err = GetInt( |
|
178 KCRUidTelephonySettings, |
|
179 KSettingsClosingSlideEnd, |
|
180 endEnabled ); |
|
181 |
|
182 if ( err == KErrNone && endEnabled ) |
|
183 { |
|
184 retVal = ETrue; |
|
185 } |
|
186 return retVal; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CTelDMGripHandler::GetInt |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 TInt CTelDMGripHandler::GetInt( |
|
194 const TUid& aUid, |
|
195 const TUint aId, |
|
196 TInt& aValue ) const |
|
197 { |
|
198 CRepository* repository = NULL; |
|
199 TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
200 if ( err == KErrNone ) |
|
201 { |
|
202 err = repository->Get( aId, aValue ); |
|
203 delete repository; |
|
204 } |
|
205 return err; |
|
206 } |
|
207 |
|
208 // End of File |