|
1 /* |
|
2 * Copyright (c) 2007 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: Handles the updating of number entry |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <featmgr.h> |
|
20 #include <bmbubblemanager.h> |
|
21 #include <AknPhoneNumberEditor.h> |
|
22 |
|
23 #include "cphonenumberentry.h" |
|
24 #include "mnumberentry.h" |
|
25 #include "phoneconstants.h" |
|
26 #include "tphonecmdparamnumberentryobserver.h" |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // Constructor |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CPhoneNumberEntry::CPhoneNumberEntry( CBubbleManager& aBubbleManager ): |
|
35 iBubbleManager ( aBubbleManager ) |
|
36 { |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Second phase constructor |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 void CPhoneNumberEntry::ConstructL() |
|
44 { |
|
45 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) ) |
|
46 { |
|
47 iUseDialer = ETrue; |
|
48 } |
|
49 |
|
50 iNumberEntryContents = HBufC::NewL( KPhoneNumberEntryBufferSize ); |
|
51 iPreviousNumberEntryContent = HBufC::NewL( KPhoneNumberEntryBufferSize ); |
|
52 |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Static constructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CPhoneNumberEntry* CPhoneNumberEntry::NewL( CBubbleManager& aBubbleManager ) |
|
60 { |
|
61 CPhoneNumberEntry* self = |
|
62 new (ELeave) CPhoneNumberEntry( aBubbleManager ); |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // Destructor |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CPhoneNumberEntry::~CPhoneNumberEntry() |
|
74 { |
|
75 delete iNumberEntryContents; |
|
76 delete iPreviousNumberEntryContent; |
|
77 |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // EnableTactileFeedback |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CPhoneNumberEntry::EnableTactileFeedback( const TBool aEnable ) |
|
85 { |
|
86 if ( iUseDialer ) |
|
87 { |
|
88 iDialerNumberEntry->EnableTactileFeedback( aEnable ); |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // IsNumberEntryUsed |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 TBool CPhoneNumberEntry::IsNumberEntryUsed() const |
|
97 { |
|
98 // Get the initial number from number entry window |
|
99 if ( iUseDialer ) |
|
100 { |
|
101 return iDialerNumberEntry->IsNumberEntryUsed(); |
|
102 } |
|
103 else |
|
104 { |
|
105 return iBubbleManager.IsNumberEntryUsed(); |
|
106 } |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 TBool CPhoneNumberEntry::CountNumberEntryCharacters( ) |
|
115 { |
|
116 TInt result = 0; |
|
117 |
|
118 if ( iUseDialer ) |
|
119 { |
|
120 if ( iDialerNumberEntry->IsNumberEntryUsed() ) |
|
121 { |
|
122 TPtr ptr( iNumberEntryContents->Des() ); |
|
123 iDialerNumberEntry->GetTextFromNumberEntry( ptr ); |
|
124 result = iNumberEntryContents->Des().Length(); |
|
125 } |
|
126 } |
|
127 else |
|
128 { |
|
129 if ( iBubbleManager.IsNumberEntryUsed() ) |
|
130 { |
|
131 TPtr ptr( iNumberEntryContents->Des() ); |
|
132 iBubbleManager.GetTextFromNumberEntry( ptr ); |
|
133 result = iNumberEntryContents->Des().Length(); |
|
134 } |
|
135 } |
|
136 |
|
137 return result; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // SetNumberEntry |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CPhoneNumberEntry::SetNumberEntry( MNumberEntry* aNumberEntry ) |
|
145 { |
|
146 if ( iUseDialer ) |
|
147 { |
|
148 iDialerNumberEntry = aNumberEntry; |
|
149 } |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // SetNumberEntryContent |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CPhoneNumberEntry::SetNumberEntryContent( const TDesC& aContent ) |
|
158 { |
|
159 if ( iUseDialer ) |
|
160 { |
|
161 iDialerNumberEntry->SetTextToNumberEntry( aContent ); |
|
162 } |
|
163 else |
|
164 { |
|
165 iBubbleManager.StartChanges(); |
|
166 iBubbleManager.SetTextToNumberEntry( aContent ); |
|
167 iBubbleManager.EndChanges(); |
|
168 } |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // SetNumberEntryPromptText |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void CPhoneNumberEntry::SetNumberEntryPromptText( const TDesC& aPromptText ) |
|
176 { |
|
177 if ( iUseDialer ) |
|
178 { |
|
179 iDialerNumberEntry->SetNumberEntryPromptText( aPromptText ); |
|
180 } |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CPhoneNumberEntry::HandleNumberEntryChanged |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CPhoneNumberEntry::HandleNumberEntryChanged( ) |
|
188 { |
|
189 |
|
190 TBool contentUpdated = CheckNumberEntryContent(); |
|
191 |
|
192 if( contentUpdated && iNEChangedCallBack.iFunction ) |
|
193 { |
|
194 iNEChangedCallBack.CallBack(); |
|
195 } |
|
196 |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CPhoneNumberEntry::SetNumberEntryCallBack |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 void CPhoneNumberEntry::SetNumberEntryChangedCallBack( |
|
204 TPhoneCommandParam* aCommandParam ) |
|
205 { |
|
206 TPhoneCmdParamNumberEntryObserver* neObserver = |
|
207 static_cast<TPhoneCmdParamNumberEntryObserver*>( aCommandParam ); |
|
208 |
|
209 iNEChangedCallBack = neObserver->Observer(); |
|
210 |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CPhoneNumberEntry::CheckNumberEntryContent |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 TBool CPhoneNumberEntry::CheckNumberEntryContent() |
|
218 { |
|
219 |
|
220 TBool update = UpdatePreviousNumberEntryContent( |
|
221 DialerNumberEntryEditor() ); |
|
222 |
|
223 if( !update ) |
|
224 { |
|
225 update = UpdatePreviousNumberEntryContent( BubbleNumberEntryEditor() ); |
|
226 } |
|
227 |
|
228 return update; |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CPhoneNumberEntry::CheckNumberEntryContent |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TBool CPhoneNumberEntry::UpdatePreviousNumberEntryContent( |
|
236 CCoeControl* aEditor ) |
|
237 { |
|
238 TBool ret( EFalse ); |
|
239 |
|
240 if( aEditor && iPreviousNumberEntryContent ) |
|
241 { |
|
242 CAknPhoneNumberEditor* control = |
|
243 static_cast<CAknPhoneNumberEditor*> ( aEditor ); |
|
244 TInt res = iPreviousNumberEntryContent->Compare( control->Text(0) ); |
|
245 |
|
246 if( res != 0 ) //string are different |
|
247 { |
|
248 iPreviousNumberEntryContent->Des().Zero(); |
|
249 TPtr ptr( iPreviousNumberEntryContent->Des() ); |
|
250 control->GetText( ptr ); |
|
251 ret = ETrue; |
|
252 } |
|
253 } |
|
254 |
|
255 return ret; |
|
256 } |
|
257 |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CPhoneNumberEntry::CheckNumberEntryContent |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 CCoeControl* CPhoneNumberEntry::DialerNumberEntryEditor() const |
|
264 { |
|
265 CCoeControl* control = NULL; |
|
266 |
|
267 if ( iUseDialer ) |
|
268 { |
|
269 if ( iDialerNumberEntry->IsNumberEntryUsed() ) |
|
270 { |
|
271 control = iDialerNumberEntry->GetNumberEntry(); |
|
272 } |
|
273 } |
|
274 |
|
275 return control; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CPhoneNumberEntry::CheckNumberEntryContent |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 CCoeControl* CPhoneNumberEntry::BubbleNumberEntryEditor() const |
|
283 { |
|
284 CCoeControl* control = NULL; |
|
285 |
|
286 if ( iBubbleManager.IsNumberEntryUsed() ) |
|
287 { |
|
288 control = iBubbleManager.GetNumberEntry(); |
|
289 } |
|
290 |
|
291 return control; |
|
292 } |
|
293 |
|
294 // END |