|
1 /* |
|
2 * Copyright (c) 2004 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: Active object to handle global list query results. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "cauiactiveobject.h" |
|
23 #include "cauiqueryobserver.h" |
|
24 #include <coemain.h> |
|
25 |
|
26 #include <mcauireconnectqueryobserver.h> |
|
27 #include <cphonecntfactory.h> |
|
28 #include <cphcntmatcher.h> |
|
29 #include <mphcntmatch.h> |
|
30 #include "cauimessagesender.h" |
|
31 #include "cauilogger.h" |
|
32 // CONSTANTS |
|
33 |
|
34 |
|
35 |
|
36 // The message editor granularity. |
|
37 const TInt KCaUiMessageEditorArrayGranularity = 1; |
|
38 |
|
39 // The reconnect query options granularity. |
|
40 #ifdef RD_UNIFIED_EDITOR |
|
41 const TInt KCaUiReConQueryOptionsArrayGranularity = 3; |
|
42 #else // RD_UNIFIED_EDITOR |
|
43 const TInt KCaUiReConQueryOptionsArrayGranularity = 4; |
|
44 #endif // RD_UNIFIED_EDITOR |
|
45 // The editor values that this active object supports. |
|
46 enum |
|
47 { |
|
48 #ifdef RD_UNIFIED_EDITOR |
|
49 ECaUiEditorMSG = 0 // Unified editor. |
|
50 #else // RD_UNIFIED_EDITOR |
|
51 ECaUiEditorSMS = 0, // SMS editor. |
|
52 ECaUiEditorMMS = 1 // MMS editor. |
|
53 #endif // RD_UNIFIED_EDITOR |
|
54 }; |
|
55 |
|
56 |
|
57 // ============================ MEMBER FUNCTIONS =============================== |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CCaUiGlnActiveObject::CCaUiGlnActiveObject |
|
62 // |
|
63 // C++ default constructor can NOT contain any code, that might leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CCaUiGlnActiveObject::CCaUiGlnActiveObject( |
|
67 MCaUiReconnectQueryObserver& aObserver ) |
|
68 : CActive( EPriorityStandard ), |
|
69 iObserver( &aObserver ) |
|
70 { |
|
71 CActiveScheduler::Add( this ); |
|
72 } |
|
73 |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CCaUiGlnActiveObject::ConstructL |
|
77 // |
|
78 // Symbian 2nd phase constructor can leave. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CCaUiGlnActiveObject::ConstructL( |
|
82 CPhCntMatcher* aPhCntMatcher, |
|
83 const TPtrC aPhoneNumber, |
|
84 const TPtrC aAlias ) |
|
85 { |
|
86 CAUILOGSTRING("CALLUI: >>> CCaUiGlnActiveObject::ConstructL() begin"); |
|
87 iReConQueryOptions = new ( ELeave ) CCaUiTIntArray( |
|
88 KCaUiReConQueryOptionsArrayGranularity ); |
|
89 |
|
90 // Get recipient info - is always available here |
|
91 iRealAddress = |
|
92 new ( ELeave ) CDesCArrayFlat( KCaUiMessageEditorArrayGranularity ); |
|
93 iRealAddress->AppendL( aPhoneNumber ); |
|
94 |
|
95 iAliases = new ( ELeave ) CDesC16ArrayFlat( |
|
96 KCaUiMessageEditorArrayGranularity ); |
|
97 |
|
98 if ( aAlias.Length() != 0 ) |
|
99 { |
|
100 // Alias was given, so matcher is not needed. |
|
101 iAliases->AppendL( aAlias ); |
|
102 |
|
103 // Matcher does not exist. |
|
104 iOwnMatcher = EFalse; |
|
105 } |
|
106 else |
|
107 { |
|
108 // Create matcher objects if needed. |
|
109 if ( !aPhCntMatcher ) |
|
110 { |
|
111 iOwnMatcher = ETrue; |
|
112 iPhCntFactory = CreateCntFactoryL(); |
|
113 iPhCntMatcher = iPhCntFactory->CreateContactMatcherL(); |
|
114 } |
|
115 else |
|
116 { |
|
117 iOwnMatcher = EFalse; |
|
118 iPhCntMatcher = aPhCntMatcher; |
|
119 } |
|
120 } |
|
121 CAUILOGSTRING("CALLUI: >>> CCaUiGlnActiveObject::ConstructL() end"); |
|
122 } |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CCaUiGlnActiveObject::NewL |
|
127 // |
|
128 // Two-phased constructor. |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 CCaUiGlnActiveObject* CCaUiGlnActiveObject::NewL( |
|
132 MCaUiReconnectQueryObserver& aObserver, |
|
133 CPhCntMatcher* aPhCntMatcher, |
|
134 const TPtrC aPhoneNumber, |
|
135 const TPtrC aAlias ) |
|
136 { |
|
137 CCaUiGlnActiveObject* self = new( ELeave ) CCaUiGlnActiveObject ( |
|
138 aObserver ); |
|
139 |
|
140 CleanupStack::PushL( self ); |
|
141 self->ConstructL( |
|
142 aPhCntMatcher, |
|
143 aPhoneNumber, |
|
144 aAlias ); |
|
145 CleanupStack::Pop(); |
|
146 |
|
147 return self; |
|
148 } |
|
149 |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CCaUiGlnActiveObject::~CCaUiGlnActiveObject |
|
153 // |
|
154 // Destructor. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 CCaUiGlnActiveObject::~CCaUiGlnActiveObject() |
|
158 { |
|
159 Cancel(); |
|
160 |
|
161 delete iReConQueryOptions; |
|
162 |
|
163 // Delete arrays. |
|
164 delete iRealAddress; |
|
165 delete iAliases; |
|
166 |
|
167 // Delete Phone Contact Finder objects if owned. |
|
168 if ( iOwnMatcher ) |
|
169 { |
|
170 delete iPhCntMatcher; |
|
171 delete iPhCntFactory; |
|
172 } |
|
173 |
|
174 if( iMessageSender ) |
|
175 { |
|
176 delete iMessageSender; |
|
177 } |
|
178 |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CCaUiGlnActiveObject::ReconQueryOptionsArray |
|
184 // |
|
185 // |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 CCaUiTIntArray* CCaUiGlnActiveObject::ReconQueryOptionsArray() |
|
189 { |
|
190 return iReConQueryOptions; |
|
191 } |
|
192 |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CCaUiGlnActiveObject::DoCancel |
|
196 // |
|
197 // |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CCaUiGlnActiveObject::DoCancel() |
|
201 { |
|
202 iObserver = NULL; |
|
203 } |
|
204 |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CCaUiGlnActiveObject::RunL |
|
208 // |
|
209 // |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CCaUiGlnActiveObject::RunL() |
|
213 { |
|
214 CAUILOGSTRING("CALLUI: >>> CCaUiGlnActiveObject::RunL() Begin"); |
|
215 |
|
216 MCaUiReconnectQueryObserver::TCaUiReconType recontype = |
|
217 MCaUiReconnectQueryObserver::ECallUiReconTypeCancel; |
|
218 TInt result = iStatus.Int(); |
|
219 TInt count = ReconQueryOptionsArray()->Count(); |
|
220 |
|
221 // If some option was chosen, change the result to contain right value. |
|
222 if ( result >= 0 && result <= count ) |
|
223 { |
|
224 result = ( *ReconQueryOptionsArray() )[ result ]; |
|
225 } |
|
226 else |
|
227 { |
|
228 result = KErrCancel; |
|
229 } |
|
230 |
|
231 CAUILOGSTRING2("CALLUI: CCaUiGlnActiveObject::RunL(): result: %d", result); |
|
232 switch ( result ) |
|
233 { |
|
234 case ECaUiVoiceCall: |
|
235 recontype = MCaUiReconnectQueryObserver::ECallUiReconTypeVoice; |
|
236 break; |
|
237 |
|
238 case ECaUiVideoCall: |
|
239 recontype = MCaUiReconnectQueryObserver::ECallUiReconTypeVideo; |
|
240 break; |
|
241 #ifndef RD_UNIFIED_EDITOR |
|
242 case ECaUiMms: |
|
243 CAUILOGSTRING("CALLUI: <<< CCaUiGlnActiveObject::RunL() ECaUiMms"); |
|
244 recontype = MCaUiReconConfQueryObserver::ECallUiReconTypeMms; |
|
245 LaunchEditorL( ECaUiEditorMMS ); |
|
246 break; |
|
247 |
|
248 case ECaUiSms: |
|
249 CAUILOGSTRING("CALLUI: <<< CCaUiGlnActiveObject::RunL() ECaUiSms"); |
|
250 recontype = MCaUiReconConfQueryObserver::ECallUiReconTypeSms; |
|
251 LaunchEditorL( ECaUiEditorSMS ); |
|
252 break; |
|
253 #else // RD_UNIFIED_EDITOR |
|
254 case ECaUiMsg: |
|
255 CAUILOGSTRING("CALLUI: <<< CCaUiGlnActiveObject::RunL() ECaUiMsg"); |
|
256 recontype = MCaUiReconnectQueryObserver::ECallUiReconTypeMsg; |
|
257 LaunchEditorL( ECaUiEditorMSG ); |
|
258 break; |
|
259 #endif // RD_UNIFIED_EDITOR |
|
260 default: |
|
261 break; |
|
262 } |
|
263 |
|
264 iObserver->OptionSelected( recontype ); |
|
265 |
|
266 Cancel(); |
|
267 |
|
268 CAUILOGSTRING("CALLUI: <<< CCaUiGlnActiveObject::RunL() end"); |
|
269 } |
|
270 |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CCaUiGlnActiveObject::SetActive |
|
274 // |
|
275 // |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CCaUiGlnActiveObject::SetActive() |
|
279 { |
|
280 if( !IsActive() ) |
|
281 { |
|
282 CActive::SetActive(); |
|
283 } |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------- |
|
287 // CCaUiGlnActiveObject::CreateMessageSenderL |
|
288 // --------------------------------------------------------- |
|
289 // |
|
290 void CCaUiGlnActiveObject::CreateMessageSenderL() |
|
291 { |
|
292 // Create instance of send ui. |
|
293 if( !iMessageSender ) |
|
294 { |
|
295 iMessageSender = CCaUiMessageSender::NewL(); |
|
296 } |
|
297 } |
|
298 |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CCaUiGlnActiveObject::LaunchEditorL |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void CCaUiGlnActiveObject::LaunchEditorL( TCaUiEditorType aEditorType ) |
|
305 { |
|
306 CAUILOGSTRING("CALLUI: >>> CCaUiGlnActiveObject::LaunchEditorL()"); |
|
307 |
|
308 CreateMessageSenderL(); |
|
309 |
|
310 const CUidNameArray& msgTypes = iMessageSender->MessageTypesArrayL(); |
|
311 |
|
312 if ( !( iAliases->Count() ) ) |
|
313 { |
|
314 // Name not yet known, so try to solve it. |
|
315 MPhCntMatch* match = NULL; |
|
316 TInt ret = iPhCntMatcher->MatchNumber( |
|
317 match, |
|
318 ( *iRealAddress )[0] ); // First and only phonenumber. |
|
319 CleanupStack::PushL( match ); |
|
320 |
|
321 if ( ret == KErrNone && match ) |
|
322 { |
|
323 HBufC* cliText = NULL; |
|
324 |
|
325 MPhCntMatch::TCliType cliType = match->Cli( cliText ); |
|
326 CleanupStack::PushL( cliText ); |
|
327 |
|
328 if ( cliType == MPhCntMatch::ECliName ) |
|
329 { |
|
330 iAliases->AppendL( *cliText ); |
|
331 } |
|
332 CleanupStack::PopAndDestroy( cliText ); |
|
333 } |
|
334 |
|
335 // Pop and destroy match. |
|
336 CleanupStack::Pop( match ); |
|
337 if ( match ) |
|
338 { |
|
339 match->Release(); |
|
340 } |
|
341 } |
|
342 |
|
343 |
|
344 TInt messageType = 0; // Editor type, default value. |
|
345 TBool launchQuery = EFalse; |
|
346 |
|
347 switch ( aEditorType ) |
|
348 { |
|
349 #ifndef RD_UNIFIED_EDITOR |
|
350 case ECaUiEditorSMS: |
|
351 messageType = msgTypes[ ECaUiEditorSMS ].iUid.iUid; // SMS editor. |
|
352 launchQuery = ETrue; |
|
353 break; |
|
354 |
|
355 case ECaUiEditorMMS: |
|
356 messageType = msgTypes[ ECaUiEditorMMS ].iUid.iUid; // MMS editor. |
|
357 launchQuery = ETrue; |
|
358 break; |
|
359 #else // RD_UNIFIED_EDITOR |
|
360 case ECaUiEditorMSG: |
|
361 messageType = msgTypes[ ECaUiEditorMSG ].iUid.iUid; // Unified message editor. |
|
362 launchQuery = ETrue; |
|
363 break; |
|
364 #endif // RD_UNIFIED_EDITOR |
|
365 default: |
|
366 break; |
|
367 } |
|
368 |
|
369 CAUILOGSTRING2("CALLUI: CCaUiGlnActiveObject::LaunchEditorL(): Message type: %d", messageType); |
|
370 CAUILOGSTRING2("CALLUI: CCaUiGlnActiveObject::LaunchEditorL(): Launch query: %d", launchQuery); |
|
371 |
|
372 // If the editor type was valid, launch the editor. |
|
373 if ( launchQuery ) |
|
374 { |
|
375 //Launch SMS Editor. |
|
376 iMessageSender->CreateNewMessageL( |
|
377 messageType, |
|
378 iRealAddress, |
|
379 iAliases, |
|
380 NULL ); |
|
381 } |
|
382 |
|
383 CAUILOGSTRING("CALLUI: <<< CCaUiGlnActiveObject::LaunchEditorL()"); |
|
384 } |
|
385 |
|
386 // ============================ MEMBER FUNCTIONS =============================== |
|
387 |
|
388 |
|
389 // ----------------------------------------------------------------------------- |
|
390 // CCaUiNoteActiveObject::CCaUiNoteActiveObject |
|
391 // |
|
392 // C++ default constructor can NOT contain any code, that might leave. |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 CCaUiNoteActiveObject::CCaUiNoteActiveObject() |
|
396 : CActive( EPriorityStandard ) |
|
397 { |
|
398 CActiveScheduler::Add( this ); |
|
399 } |
|
400 |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CCaUiNoteActiveObject::NewL |
|
404 // |
|
405 // Two-phased constructor. |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 CCaUiNoteActiveObject* CCaUiNoteActiveObject::NewL() |
|
409 { |
|
410 CCaUiNoteActiveObject* self = new( ELeave ) CCaUiNoteActiveObject (); |
|
411 |
|
412 return self; |
|
413 } |
|
414 |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CCaUiNoteActiveObject::~CCaUiNoteActiveObject |
|
418 // |
|
419 // Destructor. |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 CCaUiNoteActiveObject::~CCaUiNoteActiveObject() |
|
423 { |
|
424 Cancel(); |
|
425 } |
|
426 |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CCaUiNoteActiveObject::DoCancel |
|
430 // |
|
431 // |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 void CCaUiNoteActiveObject::DoCancel() |
|
435 { |
|
436 } |
|
437 |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // CCaUiNoteActiveObject::RunL |
|
441 // |
|
442 // |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CCaUiNoteActiveObject::RunL() |
|
446 { |
|
447 Cancel(); |
|
448 } |
|
449 |
|
450 |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // CCaUiNoteActiveObject::SetActive |
|
454 // |
|
455 // |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 void CCaUiNoteActiveObject::SetActive() |
|
459 { |
|
460 if( !IsActive() ) |
|
461 { |
|
462 CActive::SetActive(); |
|
463 } |
|
464 } |
|
465 |
|
466 |
|
467 // End of File |