|
1 /* |
|
2 * Copyright (c) 2006 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: Container for recorded chat view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "MCARecordedChatsPC.h" |
|
22 #include "MCARecordedChatsArrayPC.h" |
|
23 #include "IMUtils.h" |
|
24 #include "MCAConversationMessage.h" |
|
25 #include "CCAGroupUtils.h" |
|
26 |
|
27 #include "CCARecordedChatsContainer.h" |
|
28 #include "CCAChatViewControl.h" |
|
29 #include "MCARecordedChatProvider.h" |
|
30 #include "CCAContactSelectionDialog.h" |
|
31 #include "CCAUISessionManager.h" |
|
32 #include "MCAProcessManager.h" |
|
33 #include "MCASettingsPC.h" |
|
34 #include "MCAServerContactsArrayPC.h" |
|
35 |
|
36 #include "CCAMessageExtensionsHandler.h" |
|
37 #include "CAExternalInterface.h" |
|
38 #include "CCAAppUi.h" |
|
39 #include "CCAApp.h" |
|
40 #include "CCAStatusPaneHandler.h" |
|
41 #include "MCASkinVariant.h" |
|
42 #include "CCAVariantFactory.h" |
|
43 #include "TCAChatListBoxLayout.h" |
|
44 #include "MCALayoutInfo.h" |
|
45 #include "ChatDebugPrint.h" |
|
46 #include "IMDialogUtils.h" |
|
47 #include "mcarecipientobserver.h" |
|
48 #include "chatngclient.hrh" |
|
49 #include "imnginternalcrkeys.h" |
|
50 #include "IMPrivateCRKeys.h" |
|
51 #include "IMVariant.hrh" |
|
52 |
|
53 |
|
54 #include <finditemengine.h> |
|
55 #include <eikenv.h> |
|
56 #include <chatNG.rsg> |
|
57 #include <chatNG.mbg> |
|
58 #include <csxhelp/imng.hlp.hrh> |
|
59 #include <eikmenub.h> |
|
60 #include <AknLayout.cdl.h> //cdl |
|
61 #include <AppLayout.cdl.h> //cdl |
|
62 #include <AknsDrawUtils.h> |
|
63 #include <gulicon.h> |
|
64 #include <AknLayoutScalable_Apps.cdl.h> |
|
65 |
|
66 #include "CATouchUtils.h" |
|
67 |
|
68 // The Settings have been moved to Cenrep (also retained in the Resource file), |
|
69 // so the enums for keys and central repository header is added here |
|
70 #include "VariantKeys.h" |
|
71 |
|
72 |
|
73 // ================= MEMBER FUNCTIONS ======================= |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CCARecordedChatsContainer::NewL |
|
76 // Two-phased constructor. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CCARecordedChatsContainer* CCARecordedChatsContainer::NewL( |
|
80 const TRect& aRect, |
|
81 MCAViewSwitcher& aViewSwitcher, |
|
82 MCARecordedChatProvider& aRecChatArrayProvider, |
|
83 MCARecipientObserver& aRecipientObserver, |
|
84 MObjectProvider& aObjectProvider, |
|
85 MCASettingsPC& aSettingsPC, |
|
86 CCAAppUi* aAppUi, |
|
87 MCARecordedChatsPC& aRecordedChatsPC ) |
|
88 { |
|
89 CCARecordedChatsContainer* self = |
|
90 new ( ELeave ) CCARecordedChatsContainer( aRecChatArrayProvider, |
|
91 aViewSwitcher, |
|
92 aRecipientObserver, |
|
93 aSettingsPC, |
|
94 aAppUi, |
|
95 aRecordedChatsPC ); |
|
96 CleanupStack::PushL( self ); |
|
97 self->ConstructL( aRect, aObjectProvider ); |
|
98 CleanupStack::Pop( self ); |
|
99 return self; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CCARecordedChatsContainer::CCARecordedChatsContainer |
|
104 // Symbian OS default constructor |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 CCARecordedChatsContainer::CCARecordedChatsContainer( |
|
108 MCARecordedChatProvider& aRecChatArrayProvider, |
|
109 MCAViewSwitcher& aViewSwitcher, |
|
110 MCARecipientObserver& aRecipientObserver, |
|
111 MCASettingsPC& aSettingsPC, |
|
112 CCAAppUi* aAppUi, |
|
113 MCARecordedChatsPC& aRecordedChatsPC |
|
114 ) |
|
115 : iRecordedChatArrayProvider( aRecChatArrayProvider ), |
|
116 iRecordedChatsPC( aRecordedChatsPC ), |
|
117 iViewSwitcher( aViewSwitcher ), |
|
118 iRecipientObserver( aRecipientObserver ), |
|
119 iSettingsPC( aSettingsPC ) |
|
120 { |
|
121 iAppUI = aAppUi ; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // CCARecordedChatsContainer::ConstructL(const TRect& aRect) |
|
126 // Symbian OS two phased constructor |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 void CCARecordedChatsContainer::ConstructL( const TRect& aRect, |
|
130 MObjectProvider& aObjectProvider ) |
|
131 { |
|
132 SetMopParent( &aObjectProvider ); |
|
133 |
|
134 CreateWindowL(); |
|
135 |
|
136 CCAApp* myApp = static_cast<CCAApp*>( iAppUI->Application() ); |
|
137 iSkinVar = myApp->VariantFactory()->SkinVariantL(); |
|
138 |
|
139 iAppUI->AddLayoutChangeObserver( this ); |
|
140 |
|
141 // Create chat view |
|
142 LoadBitmapsL(); |
|
143 |
|
144 iChatView = CCAChatViewControl::NewL( aRect , *this, |
|
145 iRecordedChatsPC, |
|
146 iSettingsPC, |
|
147 iAppUI->MessageHandler(), |
|
148 iFromMe, |
|
149 iToMe, |
|
150 iUnsupported, |
|
151 iCorrupted, EFalse, this ); |
|
152 |
|
153 iChatView->SetObserver( this ); |
|
154 |
|
155 iChatView->SetTapObserver( this, 0 ); |
|
156 |
|
157 iAppUI->LayoutInfo()->SetLayoutID( TChatListBoxLayout::EWithoutEditor ); |
|
158 iAppUI->LayoutInfo()->SetEditorVisibility( EFalse ); |
|
159 |
|
160 iSendkeyInMsgList = ( IMUtils::CRKeyL( KCRUidIMVariation, KIMVariationKey ) |
|
161 & EIMFeatSendkeyInMsgList ); |
|
162 |
|
163 SetRect( aRect ); |
|
164 UpdateCbaL(); |
|
165 ActivateL(); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CCARecordedChatsContainer::LayoutChangedL |
|
170 // |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CCARecordedChatsContainer::LayoutChangedL( TInt aType ) |
|
174 { |
|
175 LoadBitmapsL(); |
|
176 TRect mainPaneRect; |
|
177 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
178 SetRect( mainPaneRect ); |
|
179 CCoeControl::HandleResourceChange( aType ); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CCARecordedChatsContainer::~CCARecordedChatsListViewContainer |
|
184 // destructor |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 CCARecordedChatsContainer::~CCARecordedChatsContainer() |
|
188 { |
|
189 delete iFromMe; |
|
190 delete iToMe; |
|
191 delete iUnsupported; |
|
192 delete iCorrupted; |
|
193 if ( iAppUI && !iAppUI->IsUnderDestruction() ) |
|
194 { |
|
195 iAppUI->RemoveLayoutChangeObserver( this ); |
|
196 } |
|
197 delete iChatView; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------- |
|
201 // CCARecordedChatsContainer::SetDefaultTitleL() |
|
202 // (other items were commented in a header). |
|
203 // --------------------------------------------------------- |
|
204 // |
|
205 void CCARecordedChatsContainer::SetDefaultTitleL() |
|
206 { |
|
207 iViewSwitcher.CAStatusPane()->SetTitleL( iEikonEnv, |
|
208 R_CHATCLIENT_RECORDEDCHATLIST_VIEW_TITLE ); |
|
209 iViewSwitcher.CAStatusPane()->ShowTabGroupL( KUidRecordedChatListView ); |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------- |
|
213 // CCARecordedChatsContainer::SizeChanged() |
|
214 // Called by framework when the view size is changed |
|
215 // --------------------------------------------------------- |
|
216 // |
|
217 void CCARecordedChatsContainer::SizeChanged() |
|
218 { |
|
219 TAknLayoutRect rp; |
|
220 |
|
221 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( |
|
222 TChatListBoxLayout::EWithoutEditor ) ); |
|
223 |
|
224 // set rect for chat view |
|
225 if ( iChatView ) |
|
226 { |
|
227 iChatView->SetRect( rp.Rect() ); |
|
228 } |
|
229 DrawNow(); |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------- |
|
233 // CCAConversationsContainer::Draw(const TRect& aRect) const |
|
234 // --------------------------------------------------------- |
|
235 // |
|
236 void CCARecordedChatsContainer::Draw( const TRect& aRect ) const |
|
237 { |
|
238 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
239 |
|
240 CWindowGc& myGc = SystemGc(); |
|
241 |
|
242 if ( !AknsDrawUtils::Background( skin, |
|
243 iSkinVar->MainPaneBackgroundContext(), |
|
244 myGc, aRect ) ) |
|
245 { |
|
246 myGc.Clear( aRect ); |
|
247 } |
|
248 } |
|
249 |
|
250 |
|
251 // --------------------------------------------------------- |
|
252 // CCARecordedChatsContainer::CountComponentControls() const |
|
253 // Number of components |
|
254 // --------------------------------------------------------- |
|
255 // |
|
256 TInt CCARecordedChatsContainer::CountComponentControls() const |
|
257 { |
|
258 return iChatView ? 1 : 0; // return nbr of controls inside this container |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------- |
|
262 // CCARecordedChatsContainer::ComponentControl(TInt aIndex) const |
|
263 // return component by index |
|
264 // --------------------------------------------------------- |
|
265 // |
|
266 CCoeControl* CCARecordedChatsContainer::ComponentControl( TInt aIndex ) const |
|
267 { |
|
268 switch ( aIndex ) |
|
269 { |
|
270 case 0: |
|
271 { |
|
272 return iChatView; |
|
273 } |
|
274 default: |
|
275 { |
|
276 return NULL; |
|
277 } |
|
278 } |
|
279 } |
|
280 |
|
281 |
|
282 // --------------------------------------------------------- |
|
283 // CCARecordedChatsContainer::OfferKeyEventL() |
|
284 // Handles key events |
|
285 // (other items were commented in a header). |
|
286 // --------------------------------------------------------- |
|
287 // |
|
288 TKeyResponse CCARecordedChatsContainer::OfferKeyEventL( |
|
289 const TKeyEvent& aEvent, TEventCode aType ) |
|
290 { |
|
291 if ( aType != EEventKey ) |
|
292 { |
|
293 return EKeyWasNotConsumed; |
|
294 } |
|
295 |
|
296 switch ( aEvent.iCode ) |
|
297 { |
|
298 // flowthrough |
|
299 case EKeyLeftArrow: |
|
300 case EKeyRightArrow: |
|
301 { |
|
302 return EKeyWasConsumed; |
|
303 } |
|
304 case EKeyBackspace: |
|
305 { |
|
306 if ( iRecordedChatArrayProvider.DeleteChatL() ) |
|
307 { |
|
308 iViewSwitcher.SwitchViewL( KUidRecordedChatListView ); |
|
309 } |
|
310 return EKeyWasConsumed; |
|
311 } |
|
312 |
|
313 // flowthrough |
|
314 case EKeyEnter: |
|
315 case EKeyOK: |
|
316 { |
|
317 ShowContextMenuL( EKeyActivation ); |
|
318 return EKeyWasConsumed; |
|
319 } |
|
320 case EKeyPhoneSend: |
|
321 { |
|
322 if ( iSendkeyInMsgList ) |
|
323 { |
|
324 if ( aEvent.iCode == EKeyPhoneSend |
|
325 && iChatView->Highlighted() |
|
326 && iChatView->SelectedItemType() |
|
327 == CFindItemEngine::EFindItemSearchPhoneNumberBin ) |
|
328 { |
|
329 // Phone number highlighted, send key pressed -> call |
|
330 iAppUI->ProcessCommandL( EChatClientCall ); |
|
331 } |
|
332 } |
|
333 return EKeyWasConsumed; |
|
334 } |
|
335 default: |
|
336 { |
|
337 TKeyResponse res = EKeyWasNotConsumed; |
|
338 if ( iChatView ) |
|
339 { |
|
340 res = static_cast<CCoeControl*>( iChatView )->OfferKeyEventL( aEvent, aType ); |
|
341 } |
|
342 |
|
343 if ( aEvent.iCode == EKeyDownArrow || aEvent.iCode == EKeyUpArrow ) |
|
344 { |
|
345 UpdateCbaL(); |
|
346 } |
|
347 |
|
348 return res; |
|
349 } |
|
350 } |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------- |
|
354 // CCARecordedChatsContainer::GetHelpContext |
|
355 // This function is called when Help application is launched |
|
356 // (other items were commented in a header). |
|
357 // --------------------------------------------------------- |
|
358 // |
|
359 void CCARecordedChatsContainer::GetHelpContext( |
|
360 TCoeHelpContext& aContext ) const |
|
361 { |
|
362 aContext.iMajor = KUidChatClient; |
|
363 aContext.iContext = KIMNG_HLP_SAVED_VIEW ; |
|
364 } |
|
365 |
|
366 // --------------------------------------------------------- |
|
367 // CCARecordedChatsContainer::HandleTapEventL |
|
368 // --------------------------------------------------------- |
|
369 // |
|
370 void CCARecordedChatsContainer::HandleTapEventL( TTapEvent aEvent, |
|
371 TUint /*aControlId*/ ) |
|
372 { |
|
373 // Forward taps to ShowContextMenuL() |
|
374 if ( aEvent == MCATapEventObserver::EDoubleTap ) |
|
375 { |
|
376 ShowContextMenuL( EDoubleClick ); |
|
377 } |
|
378 else if ( aEvent == MCATapEventObserver::ESingleTap ) |
|
379 { |
|
380 ShowContextMenuL( ESingleClick ); |
|
381 } |
|
382 } |
|
383 |
|
384 |
|
385 // --------------------------------------------------------- |
|
386 // CCARecordedChatsContainer::LoadBitmapsL |
|
387 // --------------------------------------------------------- |
|
388 // |
|
389 void CCARecordedChatsContainer::LoadBitmapsL() |
|
390 { |
|
391 //load "from me" icon |
|
392 TBool overrideBrand( AknLayoutUtils::LayoutMirrored() ); |
|
393 |
|
394 CGulIcon* iconTemp; |
|
395 |
|
396 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_from, |
|
397 EMbmChatngQgn_prop_im_from_mask, |
|
398 iAppUI->MbmFullPath(), |
|
399 overrideBrand ); |
|
400 CleanupStack::PushL( iconTemp ); |
|
401 IMUtils::UpdateIcon( iFromMe, iconTemp ); |
|
402 //iconTemp is removed from CleanupStack and does not have valid value |
|
403 |
|
404 //it can be safely reused |
|
405 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_tome, |
|
406 EMbmChatngQgn_prop_im_tome_mask, |
|
407 iAppUI->MbmFullPath(), |
|
408 overrideBrand ); |
|
409 CleanupStack::PushL( iconTemp ); |
|
410 IMUtils::UpdateIcon( iToMe, iconTemp ); |
|
411 //iconTemp is removed from CleanupStack and does not have valid value |
|
412 |
|
413 |
|
414 //it can be safely reused |
|
415 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_image_corrupted, |
|
416 EMbmChatngQgn_prop_image_corrupted_mask, |
|
417 iAppUI->MbmFullPath() ); |
|
418 CleanupStack::PushL( iconTemp ); |
|
419 IMUtils::UpdateIcon( iCorrupted, iconTemp ); |
|
420 //iconTemp is removed from CleanupStack and does not have valid value |
|
421 |
|
422 //it can be safely reused |
|
423 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_unknown, |
|
424 EMbmChatngQgn_prop_unknown_mask, |
|
425 iAppUI->MbmFullPath() ); |
|
426 CleanupStack::PushL( iconTemp ); |
|
427 IMUtils::UpdateIcon( iUnsupported, iconTemp ); |
|
428 //iconTemp is removed from CleanupStack and does not have valid value |
|
429 |
|
430 TAknLayoutRect rp; |
|
431 |
|
432 /*The argument 2: TChatListBoxLayout::EWithoutEditor*/ |
|
433 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( 2 ) ); |
|
434 |
|
435 TAknLayoutText text; |
|
436 text.LayoutText( rp.Rect(), |
|
437 AknLayoutScalable_Apps::im_reading_pane_t1( 1 ).LayoutLine() ); |
|
438 |
|
439 TSize size( text.TextRect().Height(), text.TextRect().Height() ); |
|
440 AknIconUtils::SetSize( iFromMe->Bitmap(), size ); |
|
441 AknIconUtils::SetSize( iToMe->Bitmap(), size ); |
|
442 iAppUI->MessageHandler().SizeChanged( size ); |
|
443 } |
|
444 |
|
445 // --------------------------------------------------------- |
|
446 // CCARecordedChatsContainer::IsStopped() |
|
447 // This method checks if scroll mode is on or off |
|
448 // --------------------------------------------------------- |
|
449 // |
|
450 TBool CCARecordedChatsContainer::IsStopped() const |
|
451 { |
|
452 return iChatView ? iChatView->Highlighted() : EFalse; |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------- |
|
456 // CCARecordedChatsContainer::SelectedItem() |
|
457 // --------------------------------------------------------- |
|
458 // |
|
459 HBufC* CCARecordedChatsContainer::SelectedItemL() |
|
460 { |
|
461 return iChatView ? iChatView->SelectedItemL() : KNullDesC().AllocL(); |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // CCARecordedChatsContainer::SelectedItemType |
|
466 // (other items were commented in a header). |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 TInt CCARecordedChatsContainer::SelectedItemType() |
|
470 { |
|
471 return iChatView ? iChatView->SelectedItemType() : KErrNotFound; |
|
472 } |
|
473 |
|
474 // logic: |
|
475 // 1. no groups/groups not supported --> hide "to group" |
|
476 // 2. no contacts --> hide "to contact" |
|
477 // 3. 1 and 2 --> hide forward menu completely |
|
478 // 4. contacts, but no online contacts, show All contacts are Offline |
|
479 // 5. skip always the current contact we're conversing with |
|
480 |
|
481 // --------------------------------------------------------- |
|
482 // CCARecordedChatsContainer::FwdContactVisible |
|
483 // --------------------------------------------------------- |
|
484 // |
|
485 TBool CCARecordedChatsContainer::FwdContactVisible() |
|
486 { |
|
487 TInt numContacts( iRecordedChatsPC.StoredContactsCount() ); |
|
488 |
|
489 TBool showFwdToContact = numContacts > 0; |
|
490 |
|
491 CHAT_DP( D_CHAT_LIT( "CCARecordedChatsContainer::FwdContactVisible\ |
|
492 - contacts %d, show %d" ), |
|
493 numContacts, showFwdToContact ); |
|
494 |
|
495 return showFwdToContact; |
|
496 } |
|
497 |
|
498 // --------------------------------------------------------- |
|
499 // CCARecordedChatsContainer::FwdGroupVisible |
|
500 // --------------------------------------------------------- |
|
501 // |
|
502 TBool CCARecordedChatsContainer::FwdGroupVisible() |
|
503 { |
|
504 // groups |
|
505 TBool groupsSupported = iAppUI->UISessionManager().IsSupported( |
|
506 CCAUISessionManager::EGroup ); |
|
507 |
|
508 TInt numGroups( 0 ); |
|
509 TRAPD( err, numGroups = iRecordedChatsPC.GroupCountL( ETrue ) ); |
|
510 if ( err != KErrNone ) |
|
511 { |
|
512 CActiveScheduler::Current()->Error( err ); |
|
513 } |
|
514 |
|
515 // we have to have groups supported and visible to show the forward-menu |
|
516 TBool showFwdToGroup = groupsSupported && ( numGroups > 0 ); |
|
517 |
|
518 CHAT_DP( D_CHAT_LIT( "CCARecordedChatsContainer::\ |
|
519 FwdGroupVisible - fwd show group: %d" ), |
|
520 ( TInt ) showFwdToGroup ); |
|
521 |
|
522 return showFwdToGroup; |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------- |
|
526 // CCARecordedChatsContainer::IsObjectSelected |
|
527 // --------------------------------------------------------- |
|
528 // |
|
529 TBool CCARecordedChatsContainer::IsObjectSelected( TBool& aIsOpenable, TBool& aSavePossible ) |
|
530 { |
|
531 MCAConversationMessage* msg = iChatView ? iChatView->SelectedMessage() : NULL; |
|
532 if ( !msg ) |
|
533 { |
|
534 // Nothing selected |
|
535 return EFalse; |
|
536 } |
|
537 |
|
538 TBool object = EFalse; |
|
539 |
|
540 if ( msg->ContentType() == TEnumsPC::EContentPicture || |
|
541 msg->ContentType() == TEnumsPC::EContentOther ) |
|
542 { |
|
543 // We have object |
|
544 object = ETrue; |
|
545 } |
|
546 |
|
547 |
|
548 switch ( msg->ContentProcessState() ) |
|
549 { |
|
550 case TEnumsPC::EContentNotSupported: |
|
551 case TEnumsPC::EContentCorrupted: |
|
552 case TEnumsPC::EContentNotSupportedDrm: |
|
553 { |
|
554 // Not supported or corrupted, can't open |
|
555 aIsOpenable = EFalse; |
|
556 break; |
|
557 } |
|
558 case TEnumsPC::EThumbnailReady: |
|
559 default: |
|
560 { |
|
561 if ( msg->ContentData().Length() == 0 ) |
|
562 { |
|
563 // No content, don't allow opening |
|
564 aIsOpenable = EFalse; |
|
565 } |
|
566 else |
|
567 { |
|
568 // Allow opening |
|
569 aIsOpenable = ETrue; |
|
570 |
|
571 //fix - refer Ui Spec Approved Version 1.0 |
|
572 //(Instant Messaging NG 001 151006.pdf) |
|
573 //Section 10.2.10 Pg 131 - |
|
574 //"In case user has saved the image already or sent it |
|
575 //by himself, this option(save) is not available." |
|
576 aSavePossible = ( ( msg->MessagerType() == TEnumsPC::EMessageSent ) |
|
577 || ( msg->IsImageSaved() ) ) |
|
578 ? EFalse : ETrue ; |
|
579 } |
|
580 } |
|
581 } |
|
582 |
|
583 return object; |
|
584 } |
|
585 |
|
586 // --------------------------------------------------------- |
|
587 // CCARecordedChatsContainer::SelectedMessage |
|
588 // --------------------------------------------------------- |
|
589 // |
|
590 MCAConversationMessage* CCARecordedChatsContainer::SelectedMessage() |
|
591 { |
|
592 return iChatView ? iChatView->SelectedMessage() : NULL; |
|
593 } |
|
594 |
|
595 // --------------------------------------------------------- |
|
596 // CCARecordedChatsContainer::ForwardToGroupL() |
|
597 // (other items were commented in a header). |
|
598 // --------------------------------------------------------- |
|
599 // |
|
600 void CCARecordedChatsContainer::ForwardToGroupL() |
|
601 { |
|
602 MCAConversationMessage* message = SelectedMessage(); |
|
603 if ( !message ) |
|
604 { |
|
605 // nothing selected |
|
606 return; |
|
607 } |
|
608 |
|
609 |
|
610 /** |
|
611 * 1) PairsArray is Owned. Ownership is transferred from |
|
612 * 2) There's no need to skip groups in this case. but we do need to make sure |
|
613 the pairs are in correct order after sorting |
|
614 * 3) We can use CCAServerContactsArray, as we deal with descriptor tuple |
|
615 just as with contacts. the class naming is a bit misleading |
|
616 */ |
|
617 MCAServerContactsArrayPC* pairsArray |
|
618 = iRecordedChatsPC.GetPairArrayForServerContactsArrayLC(); |
|
619 |
|
620 |
|
621 HBufC* emptyText = iEikonEnv->AllocReadResourceLC( |
|
622 R_CHAT_IBOX_FRIENDS_OFFLINE ); |
|
623 HBufC* title = iEikonEnv->AllocReadResourceLC( |
|
624 R_PRIVATE_CHAT_FORWARD_TITLE_GROUP ); |
|
625 |
|
626 TInt selectedIndex( 0 ); |
|
627 TInt retVal( IMDialogUtils::DisplayListQueryDialogL( &selectedIndex, |
|
628 pairsArray, |
|
629 R_PRIVATE_CHAT_LIST_SELECT_RECIP_DLG, |
|
630 *title, |
|
631 *emptyText, ETrue ) ); |
|
632 |
|
633 CleanupStack::PopAndDestroy( 2, emptyText ); // title, emptyText |
|
634 |
|
635 if ( retVal == EAknSoftkeyOk || retVal == EAknSoftkeyDone |
|
636 || retVal == EAknSoftkeySelect ) |
|
637 { |
|
638 // Check if there is highlighted item |
|
639 HBufC* item = SelectedItemL(); |
|
640 CleanupStack::PushL( item ); |
|
641 |
|
642 if ( item->Length() > 0 ) |
|
643 { |
|
644 // Set forwarded message |
|
645 message->SetForwardPartL( item ); |
|
646 } |
|
647 else |
|
648 { |
|
649 // Clear previous forward part |
|
650 message->SetForwardPartL( NULL ); |
|
651 } |
|
652 |
|
653 CleanupStack::PopAndDestroy( item ); //item |
|
654 //Bound checking on pairsArray |
|
655 if ( selectedIndex >= 0 && selectedIndex < pairsArray->MdcaCount() ) |
|
656 { |
|
657 TInt err( iAppUI->GroupUtils()->JoinGroupL( EFalse, |
|
658 pairsArray->WVIdL( selectedIndex )->iWVID, |
|
659 KNullDesC, message ) ); |
|
660 |
|
661 if ( TEnumsPC::EUnregistered == iAppUI->RetForwardTo() ) |
|
662 { |
|
663 iAppUI->SetResetForwardTo( TEnumsPC::ERegister ); |
|
664 iAppUI->GroupUtils()->PrepareToSwitchBackL( iRecordedChatArrayProvider.RecordedChatName(), |
|
665 KUidRecordedChatView, |
|
666 KUidChatView ); |
|
667 } |
|
668 else if ( TEnumsPC::ERegister == iAppUI->RetForwardTo() ) |
|
669 { |
|
670 iAppUI->SetResetForwardTo( TEnumsPC::EAlreadyRegistered ); |
|
671 } |
|
672 if ( err ) |
|
673 { |
|
674 CActiveScheduler::Current()->Error( err ); |
|
675 } |
|
676 } |
|
677 |
|
678 } |
|
679 |
|
680 //always dont use CleanupStack::PopAndDestroy(pairsArray) |
|
681 //because there might be a object slicing happening |
|
682 //when the pairsArray is transferred from the creator |
|
683 //to the caller. Hence one will end up deleting the wrong ptr. |
|
684 //Hence it is better to use CleanupStack::PopAndDestroy(), as |
|
685 //we dont know wat the creator has pushed onto the CleanupStack |
|
686 CleanupStack::PopAndDestroy(); //pairsArray |
|
687 } |
|
688 |
|
689 |
|
690 // --------------------------------------------------------- |
|
691 // CCARecordedChatsContainer::ForwardToContactL() |
|
692 // (other items were commented in a header). |
|
693 // --------------------------------------------------------- |
|
694 // |
|
695 void CCARecordedChatsContainer::ForwardToContactL() |
|
696 { |
|
697 MCAConversationMessage* message = SelectedMessage(); |
|
698 if ( !message ) |
|
699 { |
|
700 // nothing selected |
|
701 return; |
|
702 } |
|
703 CDesCArray* selectedContacts = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
704 CleanupStack::PushL( selectedContacts ); |
|
705 |
|
706 CDesCArray* selectedIdentifications = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
707 CleanupStack::PushL( selectedIdentifications ); |
|
708 |
|
709 MCASkinVariant* skinVar = static_cast<CCAApp*>( iAppUI->Application() ) |
|
710 ->VariantFactory()->SkinVariantL(); |
|
711 |
|
712 // show selection dialog |
|
713 if ( !CCAContactSelectionDialog::ShowDialogL( |
|
714 *selectedContacts, |
|
715 *( iAppUI->GetProcessManager().GetArrayInterface() ), |
|
716 *skinVar, |
|
717 *( iAppUI->GetProcessManager().GetSettingsInterface() ), |
|
718 iAppUI->MbmFullPath(), |
|
719 TEnumsPC::ESingleSelect, |
|
720 R_CONTACT_SELECTION_DIALOG, |
|
721 *iViewSwitcher.CAStatusPane(), |
|
722 selectedIdentifications ) ) |
|
723 { |
|
724 // no contacts |
|
725 CleanupStack::PopAndDestroy( 2, selectedContacts ); // selectedContacts,selectedIdentifications |
|
726 return; |
|
727 } |
|
728 |
|
729 |
|
730 // handle selected contact (if any) |
|
731 if ( selectedContacts->MdcaCount() == 1 ) |
|
732 { |
|
733 TPtrC wvid( selectedContacts->MdcaPoint( 0 ) );//User ID |
|
734 |
|
735 // User made selection -> set temporary identification for the wv id |
|
736 // Get identification through temp identification handler |
|
737 // code merge 14 nov, 2006 |
|
738 MCAMainViewArrayPC* mainViewArrayPC = iAppUI->GetProcessManager().GetArrayInterface(); |
|
739 |
|
740 |
|
741 //Add the conversation item to open chats array before switching the view |
|
742 mainViewArrayPC->InsertConversationItemL( wvid, |
|
743 selectedIdentifications->MdcaPoint( 0 ) ); |
|
744 |
|
745 // Check if there is highlighted item |
|
746 HBufC* item = SelectedItemL(); |
|
747 CleanupStack::PushL( item ); |
|
748 |
|
749 if ( item->Length() > 0 ) |
|
750 { |
|
751 // Set forwarded message |
|
752 message->SetForwardPartL( item ); |
|
753 } |
|
754 else |
|
755 { |
|
756 // Clear previous forward part |
|
757 message->SetForwardPartL( NULL ); |
|
758 } |
|
759 |
|
760 CleanupStack::PopAndDestroy( item ); |
|
761 |
|
762 // Store message, in case it gets deleted. |
|
763 iAppUI->SetForwardMessageL( message ); |
|
764 |
|
765 TCADnlConvView dnlConView; |
|
766 dnlConView.iWVID = wvid; |
|
767 dnlConView.iIsForwarded = ETrue; |
|
768 dnlConView.iForwardedMessage = iAppUI->ForwardMessage(); |
|
769 dnlConView.iSAPChanged = EFalse; |
|
770 dnlConView.iSwitchTab = EFalse; |
|
771 TCADnlConvViewBuf convMsgBuf( dnlConView ); |
|
772 CHAT_DP( D_CHAT_LIT( "**forward \"%S\" to contact %S" ), |
|
773 &dnlConView.iForwardedMessage, &dnlConView.iWVID ); |
|
774 |
|
775 // prevent AppShell from flashing during view switch, |
|
776 // flash the main view instead |
|
777 // if refresh is required refreshview can be called. |
|
778 iViewSwitcher.SwitchViewL( KUidConversationsView, KUidConvViewMsgId, |
|
779 convMsgBuf ); |
|
780 |
|
781 |
|
782 if ( TEnumsPC::EUnregistered == iAppUI->RetForwardTo() ) |
|
783 { |
|
784 iAppUI->SetResetForwardTo( TEnumsPC::ERegister ); |
|
785 iAppUI->GroupUtils()->PrepareToSwitchBackL( iRecordedChatArrayProvider.RecordedChatName(), |
|
786 KUidRecordedChatView, |
|
787 KUidConversationsView ); |
|
788 } |
|
789 else if ( TEnumsPC::ERegister == iAppUI->RetForwardTo() ) |
|
790 { |
|
791 iAppUI->SetResetForwardTo( TEnumsPC::EAlreadyRegistered ); |
|
792 } |
|
793 |
|
794 } |
|
795 |
|
796 CleanupStack::PopAndDestroy( 2, selectedContacts ); // selectedContacts, selectedIdentifications |
|
797 } |
|
798 |
|
799 // ----------------------------------------------------------------------------- |
|
800 // CCARecordedChatsContainer::SetItemHighlightL |
|
801 // (other items were commented in a header). |
|
802 // ----------------------------------------------------------------------------- |
|
803 // |
|
804 void CCARecordedChatsContainer::SetItemHighlightL( TBool aHighlight ) |
|
805 { |
|
806 if ( iChatView ) |
|
807 { |
|
808 iChatView->SetHighlight( aHighlight ); |
|
809 } |
|
810 } |
|
811 |
|
812 // --------------------------------------------------------- |
|
813 // CCARecordedChatsContainer::FreeMemoryForViewSwitch |
|
814 // --------------------------------------------------------- |
|
815 // |
|
816 void CCARecordedChatsContainer::FreeMemoryForViewSwitch() |
|
817 { |
|
818 delete iChatView; |
|
819 iChatView = NULL; |
|
820 } |
|
821 |
|
822 // --------------------------------------------------------- |
|
823 // CCARecordedChatsContainer::UpdateCbaL |
|
824 // --------------------------------------------------------- |
|
825 // |
|
826 void CCARecordedChatsContainer::UpdateCbaL() |
|
827 { |
|
828 TInt cbaRes = R_CHAT_SOFTKEYS_OPTIONS_BACK__EMPTY; // Default: Options/Back |
|
829 TBool ignore; |
|
830 TBool unUsedParamSave = EFalse; |
|
831 HBufC* item = iChatView ? iChatView->SelectedItemL() : NULL; |
|
832 CleanupStack::PushL( item ); |
|
833 |
|
834 if ( IsObjectSelected( ignore , unUsedParamSave ) ) |
|
835 { |
|
836 // Options/Back/Open |
|
837 cbaRes = R_CHAT_SOFTKEYS_OPTIONS_BACK__OPEN; |
|
838 } |
|
839 else if ( item && item->Length() > 0 ) |
|
840 { |
|
841 // automatic find item selected |
|
842 cbaRes = R_CHAT_SOFTKEYS_OPTIONS_BACK__CONTEXTOPTIONS; |
|
843 } |
|
844 CleanupStack::PopAndDestroy( item ); |
|
845 |
|
846 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
847 cba->SetCommandSetL( cbaRes ); |
|
848 cba->DrawNow(); |
|
849 } |
|
850 |
|
851 // --------------------------------------------------------- |
|
852 // CCARecordedChatsContainer::OpenContextMenuL |
|
853 // --------------------------------------------------------- |
|
854 // |
|
855 void CCARecordedChatsContainer::ShowContextMenuL( |
|
856 TContextLaunchEvent aLaunchEvent ) |
|
857 { |
|
858 if ( IMUtils::CRKeyL( KCRUidIMVariation, |
|
859 KIMVariationKey ) & EIMFeatRecordedChatOptions ) |
|
860 { |
|
861 // New options |
|
862 TBool ignore; |
|
863 TBool unUsedParamSave( EFalse ); |
|
864 if ( IsObjectSelected( ignore , unUsedParamSave ) ) |
|
865 { |
|
866 // Single click don't open objects |
|
867 if ( aLaunchEvent != ESingleClick ) |
|
868 { |
|
869 iAppUI->ProcessCommandL( EChatClientOpenObject ); |
|
870 } |
|
871 } |
|
872 else |
|
873 { |
|
874 // Double click don't open find menu |
|
875 if ( SelectedItemType() != KErrNotFound && |
|
876 aLaunchEvent != EDoubleClick ) |
|
877 { |
|
878 iRecipientObserver.ShowPopUpMenuL(); |
|
879 } |
|
880 } |
|
881 } |
|
882 else if ( aLaunchEvent == EDoubleClick || |
|
883 aLaunchEvent == EKeyActivation ) |
|
884 { |
|
885 // Old options |
|
886 iRecipientObserver.ShowPopUpMenuL(); |
|
887 } |
|
888 } |
|
889 |
|
890 // --------------------------------------------------------- |
|
891 // CCARecordedChatsContainer::HandleControlEventL |
|
892 // --------------------------------------------------------- |
|
893 // |
|
894 void CCARecordedChatsContainer::HandleControlEventL( CCoeControl* aControl, |
|
895 TCoeEvent aEventType ) |
|
896 { |
|
897 if ( CATouchUtils::PenEnabled() ) |
|
898 { |
|
899 |
|
900 if ( EEventRequestFocus == aEventType ) |
|
901 { |
|
902 if ( aControl == ( CCoeControl* )iChatView ) |
|
903 { |
|
904 // Focus to editor |
|
905 UpdateCbaL(); |
|
906 } |
|
907 } |
|
908 } |
|
909 } |
|
910 |
|
911 // --------------------------------------------------------- |
|
912 // CCARecordedChatsContainer::HandleMessageAddedL |
|
913 // --------------------------------------------------------- |
|
914 // |
|
915 void CCARecordedChatsContainer::HandleMessageAddedL( const TInt /*aMessageCount*/ ) |
|
916 { |
|
917 UpdateCbaL(); |
|
918 |
|
919 iChatView->UnRegisterRichTxtCtrlObserver(); |
|
920 } |
|
921 |
|
922 // End of File |
|
923 |