|
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 class for chat group view |
|
15 * |
|
16 */ |
|
17 #include "CCAAppSettingsSAPExt.h" |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CCAChatViewContainer.h" |
|
21 #include "MCAGroupUtilsPC.h" |
|
22 #include "CCAAppUi.h" |
|
23 #include "CCAApp.h" |
|
24 #include "CCAVariantFactory.h" |
|
25 #include "CCAUISessionManager.h" |
|
26 #include "CCAMessageEditor.h" |
|
27 #include "CCAChatViewControl.h" |
|
28 #include "CCAInviteEditor.h" |
|
29 #include "CCAMessageExtensionsHandler.h" |
|
30 #include "CCAGroupUtils.h" |
|
31 #include "CCAPicture.h" |
|
32 #include "CCAStatusPanehandler.h" |
|
33 #include "CCAUiMessageUtils.h" |
|
34 #include "cautils.h" |
|
35 #include "CCAChatView.h" |
|
36 |
|
37 #include "MCAConversationMessage.h" |
|
38 #include "MCALayoutInfo.h" |
|
39 #include "MCASkinVariant.h" |
|
40 #include "MCARecipientObserver.h" |
|
41 #include "CCAPCUtils.h" |
|
42 #include "IMUtils.h" |
|
43 #include "IMDialogUtils.h" |
|
44 #include "IMNoteMapper.h" |
|
45 #include "CAExternalInterface.h" |
|
46 #include "chatdebugprint.h" |
|
47 #include "chatdebugassert.h" |
|
48 #include "CCAContactSelectionDialog.h" |
|
49 |
|
50 #include "chatngclient.hrh" |
|
51 #include "imnginternalcrkeys.h" |
|
52 #include "imprivatecrkeys.h" |
|
53 #include "imvariant.hrh" |
|
54 //added for showing the editing indicator |
|
55 #include "CCAEditIndicator.h" |
|
56 #include "MCAProcessManager.h" |
|
57 #include "MCAGroupPC.h" |
|
58 #include "MCAServerContactsArrayPC.h" |
|
59 #include <finditemengine.h> |
|
60 #include <chatNG.mbg> |
|
61 #include <chatNG.rsg> |
|
62 #include <csxhelp/imng.hlp.hrh> |
|
63 #include <gulicon.h> |
|
64 #include <AknBidiTextUtils.h> // KAknBidiExtraSpacePerLine |
|
65 #include <AknsUtils.h> |
|
66 #include <aknenv.h> |
|
67 #include <txtrich.h> |
|
68 #include <impsgroupprops.h> |
|
69 #include <stringloader.h> |
|
70 #include <AknQueryDialog.h> |
|
71 #include <AknsConstants.h> |
|
72 #include <AppLayout.cdl.h> //cdl |
|
73 #include <AknLayoutScalable_Apps.cdl.h> |
|
74 #include <AknFepGlobalEnums.h> // for EAknFepSoftkeySpell |
|
75 #include <barsread.h> |
|
76 |
|
77 #include "CATouchUtils.h" |
|
78 #include <AknSettingCache.h> |
|
79 // The Settings have been moved to Cenrep (also retained in the Resource file), |
|
80 // so the enums for keys and central repository header is added here |
|
81 #include "VariantKeys.h" |
|
82 #ifdef RD_MULTIPLE_DRIVE |
|
83 #include <centralrepository.h> |
|
84 #include <IMPSServiceSettingsUINGInternalCRKeys.h> |
|
85 #include <E32std.h> |
|
86 #include <EIKAPP.H> |
|
87 #include <eikappui.h> |
|
88 #include <eikenv.h> |
|
89 #include <eikbtgpc.h> |
|
90 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
91 //CONSTANTS |
|
92 const TInt KErrNotSaved = -999; |
|
93 #endif |
|
94 |
|
95 // ================= MEMBER FUNCTIONS ======================= |
|
96 |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CCAChatViewContainer::CCAChatViewContainer |
|
100 // Default constructor must not leave. |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 CCAChatViewContainer::CCAChatViewContainer( MCAViewSwitcher& aViewSwitcher, |
|
104 MCAGroupPC* aGroupPC, |
|
105 MCARecipientObserver& aRecipientObserver, |
|
106 CCAMessageExtensionsHandler& aMessageHandler, |
|
107 CEikButtonGroupContainer* aCba, |
|
108 TInt& aTabId , |
|
109 CCAChatView * aView ) |
|
110 |
|
111 : iRecipientObserver( aRecipientObserver ), |
|
112 iViewSwitcher( aViewSwitcher ), |
|
113 iGroupPC( aGroupPC ), |
|
114 iMessageExtensionsHandler( aMessageHandler ), |
|
115 iCba( aCba ), |
|
116 iTabId( aTabId ), |
|
117 iView( aView ) |
|
118 { |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CCAChatViewContainer::NewL |
|
123 // Symbian constructor can leave. |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 CCAChatViewContainer* CCAChatViewContainer::NewL( const TRect& aRect, |
|
127 MCAViewSwitcher& aViewSwitcher, |
|
128 MCAGroupPC* aGroupPC, |
|
129 MCARecipientObserver& aRecipientObserver, |
|
130 MObjectProvider* aParent, |
|
131 CCAMessageExtensionsHandler& aMessageHandler, |
|
132 CEikButtonGroupContainer* aCba, |
|
133 const TBool aActivateFromTabSwitch, TInt& aTabId , CCAChatView * aView ) |
|
134 { |
|
135 CCAChatViewContainer* self = new ( ELeave ) CCAChatViewContainer( |
|
136 aViewSwitcher, aGroupPC , aRecipientObserver, |
|
137 aMessageHandler, aCba, aTabId, aView ); |
|
138 |
|
139 CleanupStack::PushL( self ); |
|
140 self->ConstructL( aRect, aParent, aActivateFromTabSwitch ); |
|
141 CleanupStack::Pop( self ); |
|
142 return self; |
|
143 } |
|
144 |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // CCAChatViewContainer::ConstructL |
|
148 // Symbian OS two phased constructor |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 void CCAChatViewContainer::ConstructL( const TRect& aRect, |
|
152 MObjectProvider* aParent, |
|
153 const TBool aActivateFromTabSwitch ) |
|
154 { |
|
155 iAppUi = static_cast<CCAAppUi*>( iEikonEnv->AppUi() ); |
|
156 |
|
157 // This must be done first. |
|
158 SetMopParent( aParent ); |
|
159 |
|
160 CreateWindowL(); |
|
161 CCAApp* app = static_cast<CCAApp*>( |
|
162 iEikonEnv->EikAppUi()->Application() ); |
|
163 iSkinVar = app->VariantFactory()->SkinVariantL(); |
|
164 |
|
165 iGroupId = iGroupPC->ActiveGroupId().AllocL(); |
|
166 |
|
167 iGroupUtilsPC = iAppUi->GetProcessManager().GetGroupUtilsInterface() ; |
|
168 |
|
169 //Get group interface |
|
170 iIsLoggedIn = iAppUi->UISessionManager().IsLoggedIn(); |
|
171 |
|
172 AknEditUtils::SAknEditorParameters editorParams; |
|
173 editorParams.iCursorYesNo = ETrue; |
|
174 editorParams.iAllowedToMoveInsertionPoint = ETrue; |
|
175 editorParams.iCharacterCase = EAknEditorTextCase; |
|
176 editorParams.iEditingSpace = IMUtils::MaxMsgLength(); |
|
177 editorParams.iEditingWindow = KMaxLines; // max 2 lines in the editor |
|
178 editorParams.iJustification = EAknEditorAlignBidi; |
|
179 editorParams.iOverflowYesNo = EFalse; |
|
180 iEditor = new ( ELeave ) CCAMessageEditor( iMessageExtensionsHandler ); |
|
181 iEditor->SetMopParent( this ); |
|
182 AknEditUtils::ConstructEditingL( iEditor, editorParams ); |
|
183 iEditor->SetContainerWindowL( *this ); |
|
184 iEditor->SetAllowPictures( ETrue ); |
|
185 |
|
186 iEditor->SetEdwinSizeObserver( this ); |
|
187 iEditor->SetMessageEditorObserver( this ); |
|
188 |
|
189 // create chat view control |
|
190 |
|
191 |
|
192 LoadBitmapsL(); |
|
193 |
|
194 MCAMsgAddedToRichTxtCtrlObserver* observer = NULL; |
|
195 |
|
196 if ( aActivateFromTabSwitch && !iAppUi->FocusFlag() ) |
|
197 { |
|
198 observer = this; |
|
199 } |
|
200 |
|
201 iChatView = CCAChatViewControl::NewL( aRect, *this, |
|
202 *iGroupPC, |
|
203 *iAppUi->GetProcessManager().GetSettingsInterface(), |
|
204 iMessageExtensionsHandler, |
|
205 iPrivIcon, iToMe, |
|
206 iUnsupported, |
|
207 iCorrupted, |
|
208 ETrue, |
|
209 observer |
|
210 ); |
|
211 |
|
212 iChatView->SetObserver( this ); |
|
213 |
|
214 |
|
215 iGroupPC->SetGroupEventObserverL( this, *iGroupId ); |
|
216 |
|
217 iAppUi->LayoutInfo()->SetLayoutID( TChatListBoxLayout::EWithEditor ); |
|
218 iAppUi->LayoutInfo()->SetEditorVisibility( ETrue ); |
|
219 SetRect( aRect ); |
|
220 |
|
221 iEditor->SetupSkinContextL(); |
|
222 iEditor->SetCursorPosL( 0, EFalse ); |
|
223 |
|
224 if ( !aActivateFromTabSwitch ) |
|
225 { |
|
226 iEditor->SetFocus( ETrue ); |
|
227 iChatView->SetFocus( EFalse ); |
|
228 iAppUi->SetFocusFlag( ETrue ); |
|
229 } |
|
230 else |
|
231 { |
|
232 iEditor->SetFocus( EFalse ); |
|
233 iChatView->SetFocus( ETrue ); |
|
234 } |
|
235 |
|
236 iEditor->SetObserver( this ); |
|
237 |
|
238 iRecipients = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
239 iSentRecipients = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
240 |
|
241 iIsEditorStateChanged = EFalse; |
|
242 |
|
243 iSendkeyInMsgList = ( IMUtils::CRKeyL( KCRUidIMVariation, KIMVariationKey ) |
|
244 & EIMFeatSendkeyInMsgList ); |
|
245 |
|
246 ActivateL(); |
|
247 TBool tempFlag = aActivateFromTabSwitch; |
|
248 if ( iAppUi->FocusFlag() && aActivateFromTabSwitch ) |
|
249 { |
|
250 tempFlag = EFalse; |
|
251 } |
|
252 |
|
253 ResetAfterSendL( tempFlag ); |
|
254 |
|
255 CHAT_DP( D_CHAT_LIT( "CursorPos(): %d" ), iEditor->CursorPos() ); |
|
256 CHAT_DP( D_CHAT_LIT( "TextLength(): %d" ), iEditor->TextLength() ); |
|
257 iAppUi->AddLayoutChangeObserver( this ); |
|
258 |
|
259 // Observe tap events |
|
260 iChatView->SetTapObserver( this, EMessageList ); |
|
261 iEditor->SetTapObserver( this, EMessageEditor ); |
|
262 iEditIndicator = CCAEditIndicator::NewL( *iEditor ) ; |
|
263 ifocusFlag = EFalse; |
|
264 } |
|
265 |
|
266 // Destructor |
|
267 CCAChatViewContainer::~CCAChatViewContainer() |
|
268 { |
|
269 |
|
270 delete iEditIndicator; |
|
271 delete iEditor; |
|
272 delete iPrivIcon; |
|
273 delete iToMe; |
|
274 delete iUnsupported; |
|
275 delete iCorrupted; |
|
276 delete iPrivToMany; |
|
277 delete iChatView; |
|
278 |
|
279 if ( iRecipients ) |
|
280 { |
|
281 iRecipients->Reset(); |
|
282 } |
|
283 delete iRecipients; |
|
284 |
|
285 if ( iSentRecipients ) |
|
286 { |
|
287 iSentRecipients->Reset(); |
|
288 } |
|
289 delete iSentRecipients; |
|
290 |
|
291 if ( iGroupId && iGroupPC ) |
|
292 { |
|
293 TRAP_IGNORE( iGroupPC->SetGroupEventObserverL( NULL, *iGroupId ) ); |
|
294 } |
|
295 |
|
296 delete iGroupId; |
|
297 |
|
298 if ( iAppUi ) |
|
299 { |
|
300 if ( !iAppUi->IsUnderDestruction() ) |
|
301 { |
|
302 iAppUi->LayoutInfo()->SetEditorVisibility( EFalse ); |
|
303 iAppUi->RemoveLayoutChangeObserver( this ); |
|
304 |
|
305 } |
|
306 } |
|
307 |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // CCAChatViewContainer::IsObjectSelected |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 TBool CCAChatViewContainer::IsObjectSelected( TBool& aIsOpenable , |
|
315 TBool& aSavePossible ) |
|
316 { |
|
317 MCAConversationMessage* msg = iChatView->SelectedMessage(); |
|
318 if ( !msg ) |
|
319 { |
|
320 // Nothing selected |
|
321 return EFalse; |
|
322 } |
|
323 |
|
324 TBool object = EFalse; |
|
325 |
|
326 if ( msg->ContentType() == TEnumsPC::EContentPicture || |
|
327 msg->ContentType() == TEnumsPC::EContentOther ) |
|
328 { |
|
329 // We have object |
|
330 object = ETrue; |
|
331 } |
|
332 |
|
333 |
|
334 switch ( msg->ContentProcessState() ) |
|
335 { |
|
336 case TEnumsPC::EContentNotSupported: |
|
337 case TEnumsPC::EContentCorrupted: |
|
338 case TEnumsPC::EContentNotSupportedDrm: |
|
339 { |
|
340 // Not supported or corrupted, can't open |
|
341 aIsOpenable = EFalse; |
|
342 break; |
|
343 } |
|
344 case TEnumsPC::EThumbnailReady: |
|
345 default: |
|
346 { |
|
347 if ( msg->ContentData().Length() == 0 ) |
|
348 { |
|
349 // No content, don't allow opening |
|
350 aIsOpenable = EFalse; |
|
351 } |
|
352 else |
|
353 { |
|
354 // Allow opening |
|
355 aIsOpenable = ETrue; |
|
356 |
|
357 //fix - refer Ui Spec Approved Version 1.0 |
|
358 //(Instant Messaging NG 001 151006.pdf) |
|
359 //Section 10.2.10 Pg 131 - |
|
360 //"In case user has saved the image already or sent it |
|
361 //by himself, this option(save) is not available." |
|
362 aSavePossible = ( ( msg->MessagerType() == TEnumsPC::EMessageSent ) |
|
363 || ( msg->IsImageSaved() ) ) |
|
364 ? EFalse : ETrue ; |
|
365 } |
|
366 } |
|
367 } |
|
368 |
|
369 return object; |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------- |
|
373 // CCAChatViewContainer::SelectedMessage |
|
374 // --------------------------------------------------------- |
|
375 // |
|
376 MCAConversationMessage* CCAChatViewContainer::SelectedMessage() |
|
377 { |
|
378 return iChatView->SelectedMessage(); |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // CCAChatViewContainer::SetItemHighlight |
|
383 // (other items were commented in a header). |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 void CCAChatViewContainer::SetItemHighlight( TBool aHighlight ) |
|
387 { |
|
388 iChatView->SetHighlight( aHighlight ); |
|
389 iItemHighlight = aHighlight; |
|
390 } |
|
391 |
|
392 // --------------------------------------------------------- |
|
393 // CCAChatViewContainer::FetchMessages |
|
394 // --------------------------------------------------------- |
|
395 // |
|
396 void CCAChatViewContainer::FetchMessages( TBool aFetch ) |
|
397 { |
|
398 iChatView->FetchMessages( aFetch ); |
|
399 } |
|
400 |
|
401 |
|
402 // --------------------------------------------------------- |
|
403 // CCAChatViewContainer::ResizeIcons |
|
404 // --------------------------------------------------------- |
|
405 // |
|
406 void CCAChatViewContainer::ResizeIcons( TRect aParentRect ) |
|
407 { |
|
408 TSize size( aParentRect.Height(), aParentRect.Height() ); |
|
409 AknIconUtils::SetSize( iPrivIcon->Bitmap(), size ); |
|
410 AknIconUtils::SetSize( iPrivToMany->Bitmap(), size ); |
|
411 AknIconUtils::SetSize( iToMe->Bitmap(), size ); |
|
412 iMessageExtensionsHandler.SizeChanged( size ); |
|
413 } |
|
414 |
|
415 // --------------------------------------------------------- |
|
416 // CCAChatViewContainer::SelectedItem |
|
417 // --------------------------------------------------------- |
|
418 // |
|
419 HBufC* CCAChatViewContainer::SelectedItemL() |
|
420 { |
|
421 return iChatView->SelectedItemL(); |
|
422 } |
|
423 |
|
424 // ----------------------------------------------------------------------------- |
|
425 // CCAChatViewContainer::SelectedItemType |
|
426 // (other items were commented in a header). |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 TInt CCAChatViewContainer::SelectedItemType() |
|
430 { |
|
431 return iChatView->SelectedItemType(); |
|
432 } |
|
433 |
|
434 // --------------------------------------------------------- |
|
435 // CCAChatViewContainer::IsInvitationAllowed |
|
436 // Checks if user can invite friends to this group |
|
437 // --------------------------------------------------------- |
|
438 // |
|
439 TBool CCAChatViewContainer::IsInvitationAllowed() const |
|
440 { |
|
441 return iGroupUtilsPC->IsJoined( *iGroupId ); |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------- |
|
445 // CCAChatViewContainer::InviteFriendsToGroupL |
|
446 // Start invite editor for current group |
|
447 // --------------------------------------------------------- |
|
448 // |
|
449 void CCAChatViewContainer::InviteFriendsToGroupL() |
|
450 { |
|
451 |
|
452 //hide tabs |
|
453 iAppUi->CAStatusPane()->ClearNaviPaneL(); |
|
454 |
|
455 CCAInviteEditor* editor = CCAInviteEditor::NewLC( |
|
456 *iGroupId ); |
|
457 |
|
458 editor->CreateAndSendInvitation( *( iAppUi->GroupUtils() ) ); |
|
459 CleanupStack::PopAndDestroy( editor ); |
|
460 |
|
461 //Show tabs |
|
462 iAppUi->CAStatusPane()->RestoreNaviPane(); |
|
463 |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------- |
|
467 // CCAChatViewContainer::IsStopped |
|
468 // This method checks if scroll mode is on or off |
|
469 // --------------------------------------------------------- |
|
470 // |
|
471 TBool CCAChatViewContainer::IsStopped() const |
|
472 { |
|
473 return iChatView->Highlighted(); |
|
474 } |
|
475 |
|
476 // --------------------------------------------------------- |
|
477 // CCAChatViewContainer::StartScrollingL() |
|
478 // This method is called when scrolling is started again |
|
479 // --------------------------------------------------------- |
|
480 // |
|
481 void CCAChatViewContainer::StartScrollingL( const TBool aActivateFromTabSwitch/*=EFalse*/ ) |
|
482 { |
|
483 // disable highlight and set focus to editor |
|
484 if ( iChatView->Highlighted() ) |
|
485 { |
|
486 iChatView->DisableHighlightL(); |
|
487 } |
|
488 |
|
489 if ( !aActivateFromTabSwitch ) |
|
490 { |
|
491 iEditor->SetFocus( ETrue, EDrawNow ); |
|
492 iChatView->SetFocus( EFalse, EDrawNow ); |
|
493 } |
|
494 else |
|
495 { |
|
496 iEditor->SetFocus( EFalse, EDrawNow ); |
|
497 iChatView->SetFocus( ETrue, EDrawNow ); |
|
498 } |
|
499 iEditor->DrawDeferred(); |
|
500 UpdateCbaL(); |
|
501 } |
|
502 |
|
503 // --------------------------------------------------------- |
|
504 // CCAChatViewContainer::StopScrollingL() |
|
505 // (other items were commented in a header). |
|
506 // --------------------------------------------------------- |
|
507 // |
|
508 void CCAChatViewContainer::StopScrollingL() |
|
509 { |
|
510 // unfocus editor (highlighting is enabled |
|
511 // automatically in OfferKeyEvent of ChatView) |
|
512 iEditor->SetFocus( EFalse, EDrawNow ); |
|
513 iEditor->DrawDeferred(); |
|
514 // Set editor cursor pos to end of text |
|
515 iEditor->SetCursorPosL( iEditor->TextLength(), EFalse ); |
|
516 iChatView->SetFocus( ETrue ); |
|
517 UpdateCbaL(); |
|
518 } |
|
519 |
|
520 // --------------------------------------------------------- |
|
521 // CCAChatViewContainer::UpdateCbaL() |
|
522 // --------------------------------------------------------- |
|
523 // |
|
524 void CCAChatViewContainer::UpdateCbaL() |
|
525 { |
|
526 TInt cbaRes( R_CHAT_SOFTKEYS_OPTIONS_CONTINUE__EMPTY ); |
|
527 |
|
528 if ( !iCba ) |
|
529 { |
|
530 return; |
|
531 } |
|
532 |
|
533 if ( !iChatView->GetMessageCount() ) |
|
534 { |
|
535 //if the message list is empty |
|
536 if ( !iEditor->IsFocused() ) |
|
537 { |
|
538 //if editor is not in focus then the rightSK must be "continue" |
|
539 iCba->SetCommandSetL( cbaRes ); |
|
540 iCba->DrawNow(); |
|
541 return; |
|
542 } |
|
543 } |
|
544 |
|
545 if ( iChatView->Highlighted() ) |
|
546 { |
|
547 // focus on chatview |
|
548 TBool ignore; |
|
549 TBool dummyArgument( EFalse ); |
|
550 HBufC* item = iChatView->SelectedItemL(); |
|
551 CleanupStack::PushL( item ); |
|
552 |
|
553 if ( IsObjectSelected( ignore, dummyArgument ) ) |
|
554 { |
|
555 // openable object selected |
|
556 cbaRes = R_CHAT_SOFTKEYS_OPTIONS_CONTINUE__OPEN; |
|
557 } |
|
558 else if ( item && item->Length() > 0 ) |
|
559 { |
|
560 // automatic find item selected |
|
561 cbaRes = R_CHAT_SOFTKEYS_OPTIONS_CONTINUE__CONTEXTOPTIONS; |
|
562 } |
|
563 |
|
564 CleanupStack::PopAndDestroy( item ); |
|
565 } |
|
566 else |
|
567 { |
|
568 // focus on editor |
|
569 cbaRes = iEditor->TextLength() > 0 ? |
|
570 R_CHAT_SOFTKEYS_OPTIONS_BACK__SEND : |
|
571 R_CHAT_SOFTKEYS_OPTIONS_BACK__EMPTY; |
|
572 } |
|
573 |
|
574 // Check that there is not "Spell" in the left button |
|
575 // ControlOrNull() is needed for 3.0 backport. |
|
576 if ( !( iCba->ControlOrNull( EAknFepSoftkeySpell ) && |
|
577 iCba->IsCommandVisible( EAknFepSoftkeySpell ) ) ) |
|
578 { |
|
579 iCba->SetCommandSetL( cbaRes ); |
|
580 iCba->DrawNow(); |
|
581 } |
|
582 } |
|
583 |
|
584 // --------------------------------------------------------- |
|
585 // CCAChatViewContainer::SetItemEmphasize( TBool aIsEmphasized ) |
|
586 // This method sets the item emphasization on |
|
587 // --------------------------------------------------------- |
|
588 // |
|
589 void CCAChatViewContainer::SetItemEmphasize( const TBool aIsEmphasized ) |
|
590 { |
|
591 iIsEmphasis = aIsEmphasized; |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------- |
|
595 // CCAChatViewContainer::IsEmphasized() |
|
596 // This method tells if item is emphasized or not |
|
597 // --------------------------------------------------------- |
|
598 // |
|
599 TBool CCAChatViewContainer::IsEmphasized() const |
|
600 { |
|
601 return iIsEmphasis; |
|
602 } |
|
603 |
|
604 // --------------------------------------------------------- |
|
605 // CCAChatViewContainer::Editor() |
|
606 // This method returns pointer to CEikGlobalTextEditor |
|
607 // --------------------------------------------------------- |
|
608 // |
|
609 CCAMessageEditor& CCAChatViewContainer::Editor() const |
|
610 { |
|
611 return *iEditor; |
|
612 } |
|
613 |
|
614 |
|
615 // --------------------------------------------------------- |
|
616 // CCAConversationsContainer::ForwardToGroupL() |
|
617 // (other items were commented in a header). |
|
618 // --------------------------------------------------------- |
|
619 // |
|
620 void CCAChatViewContainer::ForwardToGroupL() |
|
621 { |
|
622 MCAConversationMessage* message = iChatView->SelectedMessage(); |
|
623 if ( !message ) |
|
624 { |
|
625 // nothing selected |
|
626 return; |
|
627 } |
|
628 |
|
629 MCAServerContactsArrayPC* pairsArray = |
|
630 iGroupPC->GetGroupPairArrayLC(); |
|
631 |
|
632 HBufC* emptyText = iEikonEnv->AllocReadResourceLC( |
|
633 R_CHAT_IBOX_FRIENDS_OFFLINE ); |
|
634 HBufC* title = iEikonEnv->AllocReadResourceLC( |
|
635 R_PRIVATE_CHAT_FORWARD_TITLE_GROUP ); |
|
636 |
|
637 TInt selectedIndex( 0 ); |
|
638 TInt retVal( IMDialogUtils::DisplayListQueryDialogL( &selectedIndex, |
|
639 pairsArray, |
|
640 R_PRIVATE_CHAT_LIST_SELECT_RECIP_DLG, |
|
641 *title, |
|
642 *emptyText, |
|
643 ETrue ) ); |
|
644 //Note: code scanner warning is ignored for using magic numbers |
|
645 CleanupStack::PopAndDestroy( 2, emptyText ); // title, emptyText |
|
646 |
|
647 if ( retVal == EAknSoftkeyOk || retVal == EAknSoftkeyDone |
|
648 || retVal == EAknSoftkeySelect ) |
|
649 { |
|
650 |
|
651 // Check if there is highlighted item |
|
652 HBufC* item = SelectedItemL(); |
|
653 CleanupStack::PushL( item ); |
|
654 |
|
655 if ( item->Length() > 0 ) |
|
656 { |
|
657 // Set forwarded message, ownership is transferred |
|
658 message->SetForwardPartL( item ); |
|
659 } |
|
660 else |
|
661 { |
|
662 // Clear previous forward message |
|
663 message->SetForwardPartL( NULL ); |
|
664 } |
|
665 |
|
666 CleanupStack::PopAndDestroy( item ); |
|
667 |
|
668 TInt err = iAppUi->GroupUtils()->JoinGroupL( |
|
669 ETrue, |
|
670 pairsArray->WVIdL( selectedIndex )->iWVID, |
|
671 KNullDesC, message ); |
|
672 |
|
673 if ( err ) |
|
674 { |
|
675 CActiveScheduler::Current()->Error( err ); |
|
676 } |
|
677 if ( TEnumsPC::EUnregistered == iAppUi->RetForwardTo() ) |
|
678 { |
|
679 iAppUi->SetResetForwardTo( TEnumsPC::ERegister ); |
|
680 iAppUi->GroupUtils()->PrepareToSwitchBackL( iGroupId->Des(), |
|
681 KUidChatView, |
|
682 KUidChatView ); |
|
683 } |
|
684 else if ( TEnumsPC::ERegister == iAppUi->RetForwardTo() ) |
|
685 { |
|
686 iAppUi->SetResetForwardTo( TEnumsPC::EAlreadyRegistered ); |
|
687 } |
|
688 } |
|
689 //always dont use CleanupStack::PopAndDestroy(pairsArray) |
|
690 //because there might be a object slicing happening |
|
691 //when the pairsArray is transferred from the creator |
|
692 //to the caller. Hence one will end up deleting the wrong ptr. |
|
693 //Hence it is better to use CleanupStack::PopAndDestroy(), as |
|
694 //we dont know wat the creator has pushed onto the CleanupStack |
|
695 CleanupStack::PopAndDestroy();//pairsArray |
|
696 } |
|
697 |
|
698 |
|
699 // --------------------------------------------------------- |
|
700 // CCAConversationsContainer::ForwardToContactL() |
|
701 // (other items were commented in a header). |
|
702 // --------------------------------------------------------- |
|
703 // |
|
704 void CCAChatViewContainer::ForwardToContactL() |
|
705 { |
|
706 MCAConversationMessage* message = iChatView->SelectedMessage(); |
|
707 if ( !message ) |
|
708 { |
|
709 // nothing selected |
|
710 return; |
|
711 } |
|
712 |
|
713 MCASkinVariant* skinVar = static_cast<CCAApp*>( iAppUi->Application() ) |
|
714 ->VariantFactory()->SkinVariantL(); |
|
715 |
|
716 |
|
717 CDesCArray* selectedContacts = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
718 CleanupStack::PushL( selectedContacts ); |
|
719 |
|
720 CDesCArray* selectedIdentifications = new ( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
721 CleanupStack::PushL( selectedIdentifications ); |
|
722 |
|
723 MCASettingsPC* settingsPC = iAppUi->GetProcessManager().GetSettingsInterface(); |
|
724 MCAMainViewArrayPC* mainViewArrayPC = iAppUi->GetProcessManager().GetArrayInterface(); |
|
725 |
|
726 // show selection dialog |
|
727 TBool contacts( CCAContactSelectionDialog::ShowDialogL( *selectedContacts, |
|
728 *mainViewArrayPC, |
|
729 *skinVar, *settingsPC, |
|
730 iAppUi->MbmFullPath(), |
|
731 TEnumsPC::ESingleSelect, |
|
732 R_CONTACT_SELECTION_DIALOG, |
|
733 *iAppUi->CAStatusPane(), |
|
734 selectedIdentifications ) ); |
|
735 if ( !contacts ) |
|
736 { |
|
737 // no contacts |
|
738 //Note: code scanner warning is ignored for using magic numbers |
|
739 CleanupStack::PopAndDestroy( 2, selectedContacts ); // selectedContacts, selectedIdentifications |
|
740 return; |
|
741 } |
|
742 |
|
743 // allow tabs - suppose user would have received new messages |
|
744 iAppUi->CAStatusPane()->RestoreNaviPane(); |
|
745 |
|
746 // handle selected contact (if any) |
|
747 |
|
748 |
|
749 TInt count( selectedContacts->MdcaCount() ); |
|
750 CHAT_DP( D_CHAT_LIT( "selection count %d" ), count ); |
|
751 |
|
752 //if( selectedContacts->Count() == 1 ) |
|
753 if ( count == 1 ) |
|
754 { |
|
755 TPtrC wvid( selectedContacts->MdcaPoint( 0 ) ); |
|
756 |
|
757 // User made selection -> set temporary identification for the wv id |
|
758 MCAMainViewArrayPC* mainViewArrayPC = |
|
759 iAppUi->GetProcessManager().GetArrayInterface(); |
|
760 |
|
761 |
|
762 //Add the conversation item to open chats array before switching the view |
|
763 mainViewArrayPC->InsertConversationItemL( wvid, |
|
764 selectedIdentifications->MdcaPoint( 0 ) ); |
|
765 |
|
766 |
|
767 // Check if there is highlighted item |
|
768 HBufC* item = SelectedItemL(); |
|
769 CleanupStack::PushL( item ); |
|
770 |
|
771 if ( item->Length() > 0 ) |
|
772 { |
|
773 // Set forwarded message |
|
774 message->SetForwardPartL( item ); |
|
775 } |
|
776 else |
|
777 { |
|
778 message->SetForwardPartL( NULL ); |
|
779 } |
|
780 |
|
781 CleanupStack::PopAndDestroy( item ); |
|
782 |
|
783 // Store message, in case it gets destroyed. |
|
784 iAppUi->SetForwardMessageL( message ); |
|
785 |
|
786 if ( TEnumsPC::EUnregistered == iAppUi->RetForwardTo() ) |
|
787 { |
|
788 iAppUi->SetResetForwardTo( TEnumsPC::ERegister ); |
|
789 iAppUi->GroupUtils()->PrepareToSwitchBackL( iGroupId->Des(), |
|
790 KUidChatView, |
|
791 KUidConversationsView ); |
|
792 } |
|
793 else if ( TEnumsPC::ERegister == iAppUi->RetForwardTo() ) |
|
794 { |
|
795 iAppUi->SetResetForwardTo( TEnumsPC::EAlreadyRegistered ); |
|
796 } |
|
797 TCADnlConvView dnlConView; |
|
798 dnlConView.iWVID = wvid; |
|
799 dnlConView.iIsForwarded = ETrue; |
|
800 dnlConView.iForwardedMessage = iAppUi->ForwardMessage(); |
|
801 dnlConView.iSAPChanged = EFalse; |
|
802 dnlConView.iSwitchTab = EFalse; |
|
803 |
|
804 TCADnlConvViewBuf convMsgBuf( dnlConView ); |
|
805 CHAT_DP( D_CHAT_LIT( "**forward \"%S\" to contact %S" ), |
|
806 &dnlConView.iForwardedMessage, &dnlConView.iWVID ); |
|
807 |
|
808 iAppUi->ActivateLocalViewL( KUidConversationsView, KUidConvViewMsgId, convMsgBuf ); |
|
809 |
|
810 |
|
811 } |
|
812 //Note: code scanner warning is ignored |
|
813 CleanupStack::PopAndDestroy( 2, selectedContacts ); // selectedContacts,selectedIdentifications |
|
814 } |
|
815 |
|
816 |
|
817 // --------------------------------------------------------- |
|
818 // CCAChatViewContainer::SendMessageL() |
|
819 // This method handles message sending to engine |
|
820 // --------------------------------------------------------- |
|
821 // |
|
822 void CCAChatViewContainer::SendMessageL() |
|
823 { |
|
824 if ( iAppUi->UISessionManager().IsLoggedIn() ) |
|
825 { |
|
826 TInt textLength( iEditor->TextLength() ); |
|
827 if ( textLength == 0 ) |
|
828 { |
|
829 // setting focus back to editor window |
|
830 iEditor->SetFocus( ETrue ); |
|
831 iChatView->SetFocus( EFalse ); |
|
832 return; |
|
833 } |
|
834 |
|
835 HBufC* msgBuf = iMessageExtensionsHandler.ProcessMessageLC( *iEditor ); |
|
836 TPtr msgPtr( msgBuf->Des() ); |
|
837 TInt offset( 0 ); |
|
838 |
|
839 // Check message if there is other than empty chars |
|
840 TInt len( msgPtr.Length() ); |
|
841 TBool contaisOnlyEmptyChars( ETrue ); |
|
842 |
|
843 for ( TInt i( 0 ); ( i < len ) && contaisOnlyEmptyChars; ++i ) |
|
844 { |
|
845 TPtrC c = msgPtr.Mid( i, 1 ); // next character |
|
846 TInt position = ( KEmptyCharacters() ).FindC( c ); |
|
847 |
|
848 if ( position == KErrNotFound ) |
|
849 { |
|
850 // c not found from empty characters --> c is not empty char |
|
851 contaisOnlyEmptyChars = EFalse; |
|
852 } |
|
853 } |
|
854 |
|
855 if ( contaisOnlyEmptyChars ) |
|
856 { |
|
857 // message contains only empty character |
|
858 // don't send message and setting focus back to editor window |
|
859 iEditor->SetFocus( ETrue ); |
|
860 iChatView->SetFocus( EFalse ); |
|
861 CleanupStack::PopAndDestroy( msgBuf ); |
|
862 return; |
|
863 } |
|
864 |
|
865 // check if the message still is a whisper message, |
|
866 // did the user erase the recipient |
|
867 TBool isWhisper = ETrue; |
|
868 |
|
869 // the pics are in different place with mirrored layout |
|
870 if ( AknLayoutUtils::LayoutMirrored() ) |
|
871 { |
|
872 offset = msgPtr.FindC( KSemicolon ); |
|
873 // the rest are privmsg header |
|
874 if ( offset >= 0 ) // if found |
|
875 { |
|
876 //1 is space |
|
877 msgPtr.Delete( 0, offset + 1 ); |
|
878 } |
|
879 else |
|
880 { |
|
881 // user erased the recipient |
|
882 isWhisper = EFalse; |
|
883 } |
|
884 } |
|
885 else |
|
886 { |
|
887 if ( msgPtr[0] == CEditableText::EPictureCharacter && |
|
888 msgPtr[2] == CEditableText::EPictureCharacter ) |
|
889 { |
|
890 offset = msgPtr.FindC( KSemicolon ); |
|
891 msgPtr.Delete( 0, offset + KPictureChar ); |
|
892 } |
|
893 else if ( msgPtr[0] == CEditableText::EPictureCharacter ) |
|
894 { |
|
895 offset = msgPtr.FindC( KSemicolon ); |
|
896 msgPtr.Delete( 0, offset + KPictureChar ); |
|
897 } |
|
898 else |
|
899 { |
|
900 // user erased the recipient |
|
901 isWhisper = EFalse; |
|
902 } |
|
903 } |
|
904 |
|
905 // send message |
|
906 if ( msgPtr.Length() > 0 ) |
|
907 { |
|
908 |
|
909 |
|
910 if ( ! isWhisper ) |
|
911 { |
|
912 // no longer a whisper message, address this message to all |
|
913 iRecipients->Reset(); |
|
914 } |
|
915 |
|
916 |
|
917 iGroupPC->SendMessageL( msgPtr, *iRecipients ); |
|
918 |
|
919 TInt editorFlags = ( iEditor->AknEdwinFlags() | EAknEditorFlagNoEditIndicators ); |
|
920 iEditor->SetAknEditorFlags( editorFlags ); |
|
921 |
|
922 ResetAfterSendL(); |
|
923 |
|
924 |
|
925 } |
|
926 |
|
927 CleanupStack::PopAndDestroy( msgBuf ); |
|
928 } |
|
929 else |
|
930 { |
|
931 iAppUi->UISessionManager().LoginL( MCAUiLoginCmdCB::ELogin ); |
|
932 if ( iAppUi->UISessionManager().IsLoggedIn() ) |
|
933 { |
|
934 if ( iGroupUtilsPC->IsJoined( *iGroupId ) ) |
|
935 { |
|
936 SendMessageL(); |
|
937 } |
|
938 else |
|
939 { |
|
940 iAppUi->GroupUtils()->JoinGroupL( EFalse, *iGroupId ); |
|
941 if ( iGroupUtilsPC->IsJoined( *iGroupId ) ) |
|
942 { |
|
943 SendMessageL(); |
|
944 } |
|
945 } |
|
946 } |
|
947 } |
|
948 |
|
949 // for some reason we're not redrawn, so force it |
|
950 DrawNow(); |
|
951 } |
|
952 |
|
953 // --------------------------------------------------------- |
|
954 // CCAChatViewContainer::SendImageL() |
|
955 // (other items were commented in a header). |
|
956 // --------------------------------------------------------- |
|
957 // |
|
958 void CCAChatViewContainer::SendObjectL( TBool aNewFile, |
|
959 TNewServiceFileType aFileType /*= ENewFileServiceImage */ ) |
|
960 { |
|
961 if ( iAppUi->UISessionManager().IsLoggedIn() ) |
|
962 { |
|
963 |
|
964 |
|
965 // get members |
|
966 CDesCArray* members = new( ELeave )CDesCArrayFlat( 1 ); |
|
967 CleanupStack::PushL( members ); |
|
968 |
|
969 |
|
970 |
|
971 TPtrC groupid = iGroupPC->ActiveGroupId(); |
|
972 TBool isGroupFound = iGroupUtilsPC->FindGroup( groupid ); |
|
973 |
|
974 if ( isGroupFound ) |
|
975 { |
|
976 // get joined members |
|
977 iGroupUtilsPC->GetParticipantsL( *members, groupid ); |
|
978 } |
|
979 |
|
980 TInt index; |
|
981 if ( members->Find( *iAppUi->ScreenNamePtr(), index ) == KErrNone ) |
|
982 { |
|
983 members->Delete( index ); |
|
984 members->Compress(); |
|
985 } |
|
986 |
|
987 members->Sort( ECmpCollated ); |
|
988 |
|
989 CCAUiMessageUtils* utils = CCAUiMessageUtils::NewLC(); |
|
990 |
|
991 |
|
992 if ( aNewFile ) |
|
993 { |
|
994 // create new |
|
995 utils->SendNewFileL( aFileType, *iGroupPC, |
|
996 iGroupPC->ScreenName(), members, IsWhisperAllowedL() ); |
|
997 } |
|
998 else |
|
999 { |
|
1000 // from photos |
|
1001 utils->SendImageL( *iGroupPC, |
|
1002 iGroupPC->ScreenName(), members, IsWhisperAllowedL() ); |
|
1003 } |
|
1004 //Note: code scanner warning is ignored |
|
1005 CleanupStack::PopAndDestroy( 2, members ); // utils, members |
|
1006 } |
|
1007 else |
|
1008 { |
|
1009 iAppUi->UISessionManager().LoginL( MCAUiLoginCmdCB::ELogin ); |
|
1010 if ( iAppUi->UISessionManager().IsLoggedIn() ) |
|
1011 { |
|
1012 if ( iGroupUtilsPC->IsJoined( *iGroupId ) ) |
|
1013 { |
|
1014 SendObjectL( aNewFile, aFileType ); |
|
1015 } |
|
1016 else |
|
1017 { |
|
1018 iAppUi->GroupUtils()->JoinGroupL( EFalse, *iGroupId ); |
|
1019 if ( iGroupUtilsPC->IsJoined( *iGroupId ) ) |
|
1020 { |
|
1021 SendObjectL( aNewFile, aFileType ); |
|
1022 } |
|
1023 } |
|
1024 } |
|
1025 } |
|
1026 } |
|
1027 |
|
1028 // --------------------------------------------------------- |
|
1029 // CCAChatViewContainer::InitPrivateMessageL() |
|
1030 // Initialises privatemessage. Sets the icons to the editor |
|
1031 // (other items were commented in a header). |
|
1032 // --------------------------------------------------------- |
|
1033 // |
|
1034 void CCAChatViewContainer::InitPrivateMessageL( const TDesC& aNickName, |
|
1035 const TBool aGroupMsg ) |
|
1036 { |
|
1037 iCurrentNickInPrivMsg = aNickName; |
|
1038 iIsGroupMsgInPrivMsg = aGroupMsg; |
|
1039 |
|
1040 HBufC* nickHb = |
|
1041 HBufC::NewLC( aNickName.Length() + KAknBidiExtraSpacePerLine ); |
|
1042 |
|
1043 TPtr nickVisPtr( nickHb->Des() ); |
|
1044 nickVisPtr.Append( aNickName ); |
|
1045 |
|
1046 HBufC* msg = iEditor->GetTextInHBufL(); |
|
1047 CleanupStack::PushL( msg ); |
|
1048 |
|
1049 |
|
1050 if ( msg ) |
|
1051 { |
|
1052 TPtr msgPtr( msg->Des() ); |
|
1053 TInt scIndex( msgPtr.FindC( KSemicolon ) ); |
|
1054 CHAT_DP( D_CHAT_LIT( "scIndex = %d" ), scIndex ); |
|
1055 if ( scIndex >= 0 ) |
|
1056 { |
|
1057 //KPictureChar is for space and icon |
|
1058 TPtrC tmpMsg( msgPtr.Mid( scIndex + KPictureChar ) ); |
|
1059 CHAT_DP( D_CHAT_LIT( "tmpMsg:%S" ), &tmpMsg ); |
|
1060 *msg = tmpMsg; |
|
1061 CHAT_DP( D_CHAT_LIT( "msg:%S" ), msg ); |
|
1062 } |
|
1063 } |
|
1064 |
|
1065 TInt textLength( iEditor->TextLength() ); |
|
1066 //Read picture char from position zero to one |
|
1067 TPtrC pictureChar( iEditor->Text()->Read( 0, 1 ) ); |
|
1068 |
|
1069 CCAPicture* privIconPic = new ( ELeave ) CCAPicture( |
|
1070 *CCoeEnv::Static()->SystemGc().Device(), |
|
1071 iPrivIcon, -1 ); |
|
1072 |
|
1073 CleanupStack::PushL( privIconPic ); |
|
1074 |
|
1075 TPictureHeader privIconHeader; |
|
1076 privIconHeader.iPicture = TSwizzle<CPicture>( privIconPic ); |
|
1077 |
|
1078 if ( textLength > 0 && pictureChar[0] != CEditableText::EPictureCharacter ) |
|
1079 { |
|
1080 if ( AknLayoutUtils::LayoutMirrored() ) |
|
1081 { |
|
1082 CreatePrivMsgAHHeaderL( privIconHeader, aGroupMsg, nickVisPtr, msg ); |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 CreatePrivMsgHeaderL( privIconHeader, aGroupMsg, nickVisPtr, msg ); |
|
1087 } |
|
1088 |
|
1089 } |
|
1090 else if ( ( pictureChar[0] == CEditableText::EPictureCharacter ) || |
|
1091 ( textLength == 0 ) ) |
|
1092 { |
|
1093 if ( AknLayoutUtils::LayoutMirrored() ) |
|
1094 { |
|
1095 CreatePrivMsgAHHeaderL( privIconHeader, aGroupMsg, |
|
1096 nickVisPtr, msg ); |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 CreatePrivMsgHeaderL( privIconHeader, aGroupMsg, nickVisPtr, msg ); |
|
1101 } |
|
1102 } |
|
1103 |
|
1104 // apply formatting for private message icon |
|
1105 TCharFormat charFormat; |
|
1106 TCharFormatMask charFormatMask; |
|
1107 charFormat.iFontPresentation.iPictureAlignment = |
|
1108 TFontPresentation::EAlignCentered; |
|
1109 charFormatMask.SetAttrib( EAttFontPictureAlignment ); |
|
1110 iEditor->RichText()->ApplyCharFormatL( charFormat, charFormatMask, |
|
1111 0, iEditor->TextLength() ); |
|
1112 |
|
1113 iEditor->HandleTextChangedL(); |
|
1114 |
|
1115 TInt nickLengthInPixels( 0 ); |
|
1116 |
|
1117 TAknLayoutId layoutId; |
|
1118 CAknEnv::Static()->GetCurrentLayoutId( layoutId ); |
|
1119 |
|
1120 const CFont* font; |
|
1121 if ( layoutId == EAknLayoutIdAPAC ) |
|
1122 { |
|
1123 font = ApacPlain12(); |
|
1124 } |
|
1125 else |
|
1126 { |
|
1127 font = LatinPlain12(); |
|
1128 } |
|
1129 |
|
1130 if ( !aGroupMsg ) |
|
1131 { |
|
1132 nickLengthInPixels = font->TextWidthInPixels( nickVisPtr ); |
|
1133 } |
|
1134 |
|
1135 nickLengthInPixels += ( font->TextWidthInPixels( KSpace ) ) + |
|
1136 font->TextWidthInPixels( KSemicolon ); |
|
1137 |
|
1138 iEditor->SetCursorPosL( iEditor->Text()->DocumentLength(), EFalse ); |
|
1139 |
|
1140 CleanupStack::Pop( privIconPic ); |
|
1141 //Note: code scanner warning is ignored |
|
1142 CleanupStack::PopAndDestroy( 2, nickHb ); // msg, nickHb |
|
1143 } |
|
1144 |
|
1145 // --------------------------------------------------------- |
|
1146 // CCAChatViewContainer::Recipients() |
|
1147 // Returns recipients array |
|
1148 // (other items were commented in a header). |
|
1149 // --------------------------------------------------------- |
|
1150 // |
|
1151 CDesCArrayFlat& CCAChatViewContainer::Recipients() const |
|
1152 { |
|
1153 return *iRecipients; |
|
1154 } |
|
1155 |
|
1156 // --------------------------------------------------------- |
|
1157 // CCAChatViewContainer::SentRecipients() |
|
1158 // Returns handle to sent recipients |
|
1159 // (other items were commented in a header). |
|
1160 // --------------------------------------------------------- |
|
1161 // |
|
1162 CDesCArrayFlat* CCAChatViewContainer::SentRecipients() const |
|
1163 { |
|
1164 return iSentRecipients; |
|
1165 } |
|
1166 |
|
1167 // --------------------------------------------------------- |
|
1168 // CCAChatViewContainer::ResetAfterSendL() |
|
1169 // Resets arrays, lines and nick length after send |
|
1170 // (other items were commented in a header). |
|
1171 // --------------------------------------------------------- |
|
1172 // |
|
1173 void CCAChatViewContainer::ResetAfterSendL( const TBool aActivateFromTabSwitch/*=EFalse*/ ) |
|
1174 { |
|
1175 iEditor->ResetL(); |
|
1176 |
|
1177 if ( !aActivateFromTabSwitch ) |
|
1178 { |
|
1179 iEditor->SetFocus( ETrue, EDrawNow ); |
|
1180 iChatView->SetFocus( EFalse, EDrawNow ); |
|
1181 } |
|
1182 else |
|
1183 { |
|
1184 iEditor->SetFocus( EFalse, EDrawNow ); |
|
1185 iChatView->SetFocus( ETrue, EDrawNow ); |
|
1186 } |
|
1187 |
|
1188 iIsPrivateMsgActive = EFalse; |
|
1189 iCurrentNickInPrivMsg.Zero(); |
|
1190 iCurrentTextLenght = 0; |
|
1191 iNickLength = 0; |
|
1192 iRecipients->Reset(); |
|
1193 iEditor->EnableCcpuSupportL( ETrue ); |
|
1194 iEditor->SetTextLimit( IMUtils::MaxMsgLength() ); |
|
1195 iEditor->SetAknEditorCurrentCase( EAknEditorTextCase ); |
|
1196 StartScrollingL( aActivateFromTabSwitch ); // Call to update CBA |
|
1197 } |
|
1198 |
|
1199 // --------------------------------------------------------- |
|
1200 // CCAChatViewContainer::DisplayInfoNoteL() |
|
1201 // Displays info note for corresponding resource id |
|
1202 // (other items were commented in a header). |
|
1203 // --------------------------------------------------------- |
|
1204 // |
|
1205 void CCAChatViewContainer::DisplayInfoNoteL( const TInt aResourceId ) |
|
1206 { |
|
1207 CAknNoteDialog* infoNote = new ( ELeave ) CAknNoteDialog( CAknNoteDialog:: |
|
1208 EConfirmationTone, CAknNoteDialog::EShortTimeout ); |
|
1209 |
|
1210 infoNote->ExecuteLD( aResourceId ); |
|
1211 } |
|
1212 |
|
1213 // --------------------------------------------------------- |
|
1214 // CCAChatViewContainer::ClearSelectionL |
|
1215 // (other items were commented in a header). |
|
1216 // --------------------------------------------------------- |
|
1217 // |
|
1218 void CCAChatViewContainer::ClearSelectionL( const TInt aSelectionLength ) |
|
1219 { |
|
1220 HBufC* tmpMsg = iEditor->GetTextInHBufL(); |
|
1221 TPtr tmpPtr( tmpMsg->Des() ); |
|
1222 CleanupStack::PushL( tmpMsg ); |
|
1223 tmpPtr.Delete( 0, aSelectionLength ); |
|
1224 iEditor->ResetL(); |
|
1225 iEditor->SetTextL( &*tmpMsg ); |
|
1226 CleanupStack::PopAndDestroy( tmpMsg ); |
|
1227 iEditor->DrawNow(); |
|
1228 iIsPrivateMsgActive = EFalse; |
|
1229 iNickLength = 0; |
|
1230 iRecipients->Reset(); |
|
1231 } |
|
1232 |
|
1233 // --------------------------------------------------------- |
|
1234 // CCAChatViewContainer::CreatePrivMsgHeaderL |
|
1235 // (other items were commented in a header). |
|
1236 // --------------------------------------------------------- |
|
1237 // |
|
1238 void CCAChatViewContainer::CreatePrivMsgHeaderL( TPictureHeader& aIconHeader, |
|
1239 const TBool& aGroupMsg, |
|
1240 TDesC& aNick, |
|
1241 HBufC* aMsg ) |
|
1242 { |
|
1243 //Richtext pointer cannot be put to local variable and that's why it is used |
|
1244 //via methods |
|
1245 |
|
1246 // if already exist the prefix of private message, delete it. |
|
1247 if ( iNickLength > 0 && iEditor->Text()->DocumentLength() >= iNickLength ) |
|
1248 { |
|
1249 iEditor->RichText()->DeleteL( 0, iNickLength ); |
|
1250 } |
|
1251 |
|
1252 // reset the prefix of private message |
|
1253 TInt originalLength = iEditor->Text()->DocumentLength(); |
|
1254 |
|
1255 iEditor->RichText()->InsertL( 0, KSemicolon ); |
|
1256 |
|
1257 if ( aGroupMsg ) |
|
1258 { |
|
1259 CCAPicture* privToMany = new ( ELeave ) CCAPicture( |
|
1260 *CCoeEnv::Static()->SystemGc().Device(), |
|
1261 iPrivToMany ); |
|
1262 |
|
1263 CleanupStack::PushL( privToMany ); |
|
1264 |
|
1265 TPictureHeader groupIconHeader; |
|
1266 groupIconHeader.iPicture = TSwizzle<CPicture>( privToMany ); |
|
1267 |
|
1268 iEditor->RichText()->InsertL( 0, groupIconHeader ); |
|
1269 CleanupStack::Pop( privToMany ); |
|
1270 } |
|
1271 else |
|
1272 { |
|
1273 iEditor->RichText()->InsertL( 0, aNick ); |
|
1274 } |
|
1275 |
|
1276 iEditor->RichText()->InsertL( 0, KSpace ); |
|
1277 iEditor->RichText()->InsertL( 0, aIconHeader ); |
|
1278 |
|
1279 iNickLength = iEditor->Text()->DocumentLength() - originalLength; |
|
1280 } |
|
1281 |
|
1282 |
|
1283 // --------------------------------------------------------- |
|
1284 // CCAChatViewContainer::CreatePrivMsgAHHeaderL |
|
1285 // (other items were commented in a header). |
|
1286 // --------------------------------------------------------- |
|
1287 // |
|
1288 void CCAChatViewContainer::CreatePrivMsgAHHeaderL( TPictureHeader& aIconHeader, |
|
1289 const TBool& aGroupMsg, |
|
1290 TDesC& aNick, |
|
1291 HBufC* aMsg ) |
|
1292 { |
|
1293 //Richtext pointer cannot be put to local variable and that's why it is used |
|
1294 //via methods |
|
1295 |
|
1296 // if already exist the prefix of private message, delete it. |
|
1297 if ( iNickLength > 0 && iEditor->Text()->DocumentLength() >= iNickLength ) |
|
1298 { |
|
1299 iEditor->RichText()->DeleteL( 0, iNickLength ); |
|
1300 } |
|
1301 |
|
1302 // reset the prefix of private message |
|
1303 TInt originalLength = iEditor->Text()->DocumentLength(); |
|
1304 |
|
1305 iEditor->RichText()->InsertL( 0, KSemicolon ); |
|
1306 iEditor->RichText()->InsertL( 0, KArabicSign ); |
|
1307 |
|
1308 if ( aGroupMsg ) |
|
1309 { |
|
1310 CCAPicture* privToMany = new ( ELeave ) CCAPicture( |
|
1311 *CCoeEnv::Static()->SystemGc().Device(), |
|
1312 iPrivToMany ); |
|
1313 |
|
1314 CleanupStack::PushL( privToMany ); |
|
1315 |
|
1316 TPictureHeader groupIconHeader; |
|
1317 groupIconHeader.iPicture = TSwizzle<CPicture>( privToMany ); |
|
1318 |
|
1319 CleanupStack::Pop(); |
|
1320 iEditor->RichText()->InsertL( 0, groupIconHeader ); |
|
1321 } |
|
1322 else |
|
1323 { |
|
1324 iEditor->RichText()->InsertL( 0, KArabicSign ); |
|
1325 iEditor->RichText()->InsertL( 0, aNick ); |
|
1326 } |
|
1327 |
|
1328 iEditor->RichText()->InsertL( 0, KSpace ); |
|
1329 iEditor->RichText()->InsertL( 0, KArabicSign ); |
|
1330 iEditor->RichText()->InsertL( 0, aIconHeader ); |
|
1331 iEditor->RichText()->InsertL( 0, KArabicSign ); |
|
1332 |
|
1333 iNickLength = iEditor->Text()->DocumentLength() - originalLength; |
|
1334 } |
|
1335 |
|
1336 // --------------------------------------------------------- |
|
1337 // CCAChatViewContainer::LoadBitmapsL |
|
1338 // (other items were commented in a header). |
|
1339 // --------------------------------------------------------- |
|
1340 // |
|
1341 void CCAChatViewContainer::LoadBitmapsL() |
|
1342 { |
|
1343 //Removed the ownership of iConnUI from this file and made it a reference |
|
1344 //APPUI owns this connection UI instance and shares the same with this component. |
|
1345 // get user-defined colors from SAP settings |
|
1346 CCAAppSettingsSAPExt* SAPExtension = CCAAppSettingsSAPExt::NewLC( iAppUi->ConnectionUI() ); |
|
1347 TInt ownCol( SAPExtension->IntValueL( KIMOwnMessageColourKey ) ); |
|
1348 TInt otherCol( SAPExtension->IntValueL( KIMOthersMessageColourKey ) ); |
|
1349 CleanupStack::PopAndDestroy( SAPExtension ); |
|
1350 |
|
1351 TRgb* ownRgbCol = NULL; |
|
1352 TRgb* otherRgbCol = NULL; |
|
1353 |
|
1354 TBool useCustomOtherMsgColor = EFalse; |
|
1355 if ( otherCol != KErrNotFound ) |
|
1356 { |
|
1357 otherRgbCol = new ( ELeave ) TRgb( otherCol ); |
|
1358 CleanupStack::PushL( otherRgbCol ); |
|
1359 useCustomOtherMsgColor = ETrue; |
|
1360 } |
|
1361 |
|
1362 TBool useCustomOwnMsgColor = EFalse; |
|
1363 if ( ownCol != KErrNotFound ) |
|
1364 { |
|
1365 ownRgbCol = new ( ELeave ) TRgb( ownCol ); |
|
1366 CleanupStack::PushL( ownRgbCol ); |
|
1367 useCustomOwnMsgColor = ETrue; |
|
1368 } |
|
1369 |
|
1370 // check resource colours |
|
1371 // The color settings are fetched from Resource file, and not from the Cenrep, that is the reason for using IntResourceValueFromRssL instead of IntResourceValueL |
|
1372 TBool defaultColors = IMUtils::IntResourceValueFromRssL( |
|
1373 RSC_CHAT_DEFAULT_MESSAGE_COLORS ); |
|
1374 |
|
1375 if ( !useCustomOwnMsgColor && !defaultColors ) |
|
1376 { |
|
1377 // user-defined color not defined and resource colour in use |
|
1378 TResourceReader reader; |
|
1379 CCoeEnv::Static()->CreateResourceReaderLC( reader, |
|
1380 RSC_CHAT_MESSAGE_COLOR ); |
|
1381 TUint8 red( reader.ReadUint8() ); |
|
1382 TUint8 green( reader.ReadUint8() ); |
|
1383 TUint8 blue( reader.ReadUint8() ); |
|
1384 |
|
1385 CleanupStack::PopAndDestroy(); // reader |
|
1386 |
|
1387 if ( !ownRgbCol ) |
|
1388 { |
|
1389 ownRgbCol = new ( ELeave ) TRgb( red, green, blue ); |
|
1390 CleanupStack::PushL( ownRgbCol ); |
|
1391 } |
|
1392 else |
|
1393 { |
|
1394 *ownRgbCol = TRgb( red, green, blue ); |
|
1395 } |
|
1396 |
|
1397 useCustomOwnMsgColor = ETrue; |
|
1398 } |
|
1399 |
|
1400 if ( !useCustomOtherMsgColor && !defaultColors ) |
|
1401 { |
|
1402 // user-defined color not defined and resource colour in use |
|
1403 TResourceReader reader; |
|
1404 CCoeEnv::Static()->CreateResourceReaderLC( reader, |
|
1405 RSC_CHAT_OWN_MESSAGE_COLOR ); |
|
1406 TUint8 red( reader.ReadUint8() ); |
|
1407 TUint8 green( reader.ReadUint8() ); |
|
1408 TUint8 blue( reader.ReadUint8() ); |
|
1409 |
|
1410 CleanupStack::PopAndDestroy(); // reader |
|
1411 |
|
1412 if ( !otherRgbCol ) |
|
1413 { |
|
1414 otherRgbCol = new ( ELeave ) TRgb( red, green, blue ); |
|
1415 CleanupStack::PushL( otherRgbCol ); |
|
1416 } |
|
1417 else |
|
1418 { |
|
1419 *otherRgbCol = TRgb( red, green, blue ); |
|
1420 } |
|
1421 |
|
1422 useCustomOwnMsgColor = ETrue; |
|
1423 } |
|
1424 |
|
1425 CGulIcon* iconTemp; |
|
1426 |
|
1427 // if custom colors are defined, use them |
|
1428 if ( useCustomOwnMsgColor ) |
|
1429 { |
|
1430 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_tome, |
|
1431 EMbmChatngQgn_prop_im_tome_mask, |
|
1432 iAppUi->MbmFullPath(), EFalse, ownRgbCol ); |
|
1433 } |
|
1434 else |
|
1435 { |
|
1436 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_tome, |
|
1437 EMbmChatngQgn_prop_im_tome_mask, |
|
1438 iAppUi->MbmFullPath() ); |
|
1439 } |
|
1440 |
|
1441 CleanupStack::PushL( iconTemp ); |
|
1442 IMUtils::UpdateIcon( iPrivIcon, iconTemp ); |
|
1443 //iconTemp is removed from CleanupStack and does not have valid value |
|
1444 |
|
1445 //it can be safely reused |
|
1446 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_many, |
|
1447 EMbmChatngQgn_prop_im_many_mask, |
|
1448 iAppUi->MbmFullPath() ); |
|
1449 CleanupStack::PushL( iconTemp ); |
|
1450 IMUtils::UpdateIcon( iPrivToMany, iconTemp ); |
|
1451 //iconTemp is removed from CleanupStack and does not have valid value |
|
1452 |
|
1453 //it can be safely reused |
|
1454 // if custom colors are defined, use them |
|
1455 if ( useCustomOtherMsgColor ) |
|
1456 { |
|
1457 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_tome, |
|
1458 EMbmChatngQgn_prop_im_tome_mask, |
|
1459 iAppUi->MbmFullPath(), EFalse, otherRgbCol ); |
|
1460 } |
|
1461 else |
|
1462 { |
|
1463 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_tome, |
|
1464 EMbmChatngQgn_prop_im_tome_mask, |
|
1465 iAppUi->MbmFullPath() ); |
|
1466 } |
|
1467 CleanupStack::PushL( iconTemp ); |
|
1468 IMUtils::UpdateIcon( iToMe, iconTemp ); |
|
1469 //iconTemp is removed from CleanupStack and does not have valid value |
|
1470 |
|
1471 //it can be safely reused |
|
1472 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_image_corrupted, |
|
1473 EMbmChatngQgn_prop_image_corrupted_mask, |
|
1474 iAppUi->MbmFullPath() ); |
|
1475 CleanupStack::PushL( iconTemp ); |
|
1476 IMUtils::UpdateIcon( iCorrupted, iconTemp ); |
|
1477 //iconTemp is removed from CleanupStack and does not have valid value |
|
1478 |
|
1479 //it can be safely reused |
|
1480 iconTemp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_unknown, |
|
1481 EMbmChatngQgn_prop_unknown_mask, |
|
1482 iAppUi->MbmFullPath() ); |
|
1483 CleanupStack::PushL( iconTemp ); |
|
1484 IMUtils::UpdateIcon( iUnsupported, iconTemp ); |
|
1485 //iconTemp is removed from CleanupStack and does not have valid value |
|
1486 |
|
1487 if ( useCustomOwnMsgColor ) |
|
1488 { |
|
1489 CleanupStack::PopAndDestroy(); // ownRgbCol |
|
1490 } |
|
1491 |
|
1492 if ( useCustomOtherMsgColor ) |
|
1493 { |
|
1494 CleanupStack::PopAndDestroy(); // otherRgbCol |
|
1495 } |
|
1496 } |
|
1497 |
|
1498 |
|
1499 // --------------------------------------------------------- |
|
1500 // CCAChatViewContainer::ApplicationUserSentThis() const |
|
1501 // (other items were commented in a header). |
|
1502 // --------------------------------------------------------- |
|
1503 // |
|
1504 TBool CCAChatViewContainer::ApplicationUserSentThis() const |
|
1505 { |
|
1506 TBool ret( EFalse ); |
|
1507 MCAConversationMessage* msg = iChatView->SelectedMessage(); |
|
1508 if ( msg ) |
|
1509 { |
|
1510 ret = ( msg->MessagerType() == TEnumsPC::EMessageSent ); |
|
1511 } |
|
1512 return ret; |
|
1513 } |
|
1514 |
|
1515 // --------------------------------------------------------- |
|
1516 // CCAChatViewContainer::Received() const |
|
1517 // (other items were commented in a header). |
|
1518 // --------------------------------------------------------- |
|
1519 // |
|
1520 TBool CCAChatViewContainer::Received() const |
|
1521 { |
|
1522 TBool ret( EFalse ); |
|
1523 MCAConversationMessage* msg = iChatView->SelectedMessage(); |
|
1524 if ( msg ) |
|
1525 { |
|
1526 ret = ( msg->MessagerType() == TEnumsPC::EMessageReceived ); |
|
1527 } |
|
1528 return ret; |
|
1529 } |
|
1530 |
|
1531 // --------------------------------------------------------- |
|
1532 // CCAChatViewContainer::SaveChatL() |
|
1533 // (other items were commented in a header). |
|
1534 // --------------------------------------------------------- |
|
1535 // |
|
1536 |
|
1537 void CCAChatViewContainer::SaveChatL() |
|
1538 { |
|
1539 TBool isMemorySelected = ETrue; |
|
1540 #ifdef RD_MULTIPLE_DRIVE // show note |
|
1541 isMemorySelected = ShowMemorySelectionDialogL(); |
|
1542 #endif |
|
1543 |
|
1544 // if the location has not been set, don't do record |
|
1545 if ( !isMemorySelected ) |
|
1546 { |
|
1547 return; |
|
1548 } |
|
1549 |
|
1550 HBufC* logFileName = HBufC::NewLC( KMaxLogFileName ); |
|
1551 TPtr logFileNamePtr( logFileName->Des() ); |
|
1552 |
|
1553 logFileNamePtr.Copy( iGroupPC->GroupName().Left( KMaxLogFileName ) ); |
|
1554 |
|
1555 TInt result( IMDialogUtils::DisplayTextQueryDialogL( logFileNamePtr, |
|
1556 RSC_CHATNG_LOGDIALOG_PROMPT, R_CHATCLIENT_LOG_NAME_QUERY, |
|
1557 ETrue // T9 |
|
1558 ) ); |
|
1559 |
|
1560 if ( result == EAknSoftkeyOk || result == EAknSoftkeyDone ) |
|
1561 { |
|
1562 #ifdef RD_MULTIPLE_DRIVE // show note |
|
1563 TInt error = KErrNone; |
|
1564 TRAP( error , iGroupPC->SaveChatL( *logFileName ) ); |
|
1565 |
|
1566 if ( error != KErrNotSaved && error != KErrDiskFull ) |
|
1567 #else |
|
1568 iGroupPC->SaveChatL( *logFileName ); |
|
1569 #endif |
|
1570 |
|
1571 { |
|
1572 IMDialogUtils::DisplayConfirmationNoteL( R_QTN_CHAT_SAVING_SAVED ); |
|
1573 } |
|
1574 #ifdef RD_MULTIPLE_DRIVE |
|
1575 else if ( error == KErrDiskFull ) |
|
1576 { |
|
1577 TBuf< KMaxPath > defaultDrive; |
|
1578 |
|
1579 CRepository* cenrep = CRepository::NewL( KWVSettingsCenRepUid ); |
|
1580 |
|
1581 TInt err = cenrep->Get( KIMPSCRIMDefaultMemoryDrive, defaultDrive ); |
|
1582 |
|
1583 CleanupStack::PushL( cenrep ); |
|
1584 CleanupStack::PopAndDestroy( cenrep ); |
|
1585 cenrep = NULL; |
|
1586 |
|
1587 if ( err != KErrNone ) |
|
1588 { |
|
1589 User::Leave( err ); |
|
1590 } |
|
1591 TInt driveNo = 0; |
|
1592 err = RFs::CharToDrive( defaultDrive[0], driveNo ); |
|
1593 if ( err != KErrNone ) |
|
1594 { |
|
1595 User::Leave( err ); |
|
1596 } |
|
1597 TDriveNumber driveNumber = TDriveNumber( driveNo ); |
|
1598 |
|
1599 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
1600 |
|
1601 TDriveInfo driveInfo; |
|
1602 err = fs.Drive( driveInfo, driveNumber ); |
|
1603 if ( err != KErrNone ) |
|
1604 { |
|
1605 User::Leave( err ); |
|
1606 } |
|
1607 if ( driveInfo.iDriveAtt & KDriveAttRemovable ) |
|
1608 { |
|
1609 HBufC* prompt = iEikonEnv->AllocReadResourceLC( R_CHAT_MEMLO_MMC_NOT_ENOUGH_MEMORY ); |
|
1610 IMDialogUtils::DisplayErrorNoteL( *prompt, ETrue ); |
|
1611 CleanupStack::PopAndDestroy( prompt ); |
|
1612 } |
|
1613 else |
|
1614 { |
|
1615 HBufC* prompt = iEikonEnv->AllocReadResourceLC( R_CHAT_MEMLO_NOT_ENOUGH_MEMORY ); |
|
1616 IMDialogUtils::DisplayErrorNoteL( *prompt, ETrue ); |
|
1617 CleanupStack::PopAndDestroy( prompt ); |
|
1618 } |
|
1619 |
|
1620 } |
|
1621 |
|
1622 #endif |
|
1623 } |
|
1624 CleanupStack::PopAndDestroy( logFileName ); |
|
1625 } |
|
1626 |
|
1627 |
|
1628 // --------------------------------------------------------- |
|
1629 // CCAChatViewContainer::SetLoggingOffL() |
|
1630 // (other items were commented in a header). |
|
1631 // --------------------------------------------------------- |
|
1632 // |
|
1633 void CCAChatViewContainer::SetLoggingOffL() |
|
1634 { |
|
1635 if ( iGroupPC->IsLoggingOn() ) |
|
1636 { |
|
1637 iAppUi->ShowWaitDialogL( R_QTN_GEN_NOTE_SAVING ); |
|
1638 |
|
1639 |
|
1640 TRAPD( err, iGroupPC->EndLoggingL() ); |
|
1641 |
|
1642 iAppUi->DismissWaitDialogL( err ); |
|
1643 if ( err == KErrNone ) |
|
1644 { |
|
1645 IMDialogUtils::DisplayNoteDialogL( R_QTN_RECORDING_ENDED ); |
|
1646 } |
|
1647 } |
|
1648 } |
|
1649 |
|
1650 // --------------------------------------------------------- |
|
1651 // CCAChatViewContainer::IsWhisperAllowedL() const |
|
1652 // (other items were commented in a header). |
|
1653 // --------------------------------------------------------- |
|
1654 // |
|
1655 TBool CCAChatViewContainer::IsWhisperAllowedL() const |
|
1656 { |
|
1657 CHAT_DP( D_CHAT_LIT( "CCAChatViewContainer::IsWhisperAllowedL()" ) ); |
|
1658 |
|
1659 if ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_GROUP_WHISPER ) ) |
|
1660 { |
|
1661 return iWhisperingAllowed; |
|
1662 } |
|
1663 else |
|
1664 { |
|
1665 return EFalse; |
|
1666 } |
|
1667 } |
|
1668 |
|
1669 |
|
1670 // --------------------------------------------------------- |
|
1671 // CCAChatViewContainer::IsUserAdminL() |
|
1672 // (other items were commented in a header). |
|
1673 // --------------------------------------------------------- |
|
1674 // |
|
1675 TBool CCAChatViewContainer::IsUserAdmin() const |
|
1676 { |
|
1677 CHAT_DP( D_CHAT_LIT( "CCAChatViewContainer::IsUserAdminL()" ) ); |
|
1678 return( iGroupUtilsPC->IsAdmin( *iGroupId ) || iGroupUtilsPC->IsOwnGroup( *iGroupId ) ); |
|
1679 } |
|
1680 |
|
1681 // --------------------------------------------------------- |
|
1682 // CCAChatViewContainer::IsGroupOpen() |
|
1683 // (other items were commented in a header). |
|
1684 // --------------------------------------------------------- |
|
1685 // |
|
1686 TBool CCAChatViewContainer::IsGroupOpen() const |
|
1687 { |
|
1688 |
|
1689 // In error situation let the group be closed i.e. EFalse |
|
1690 CHAT_DP( D_CHAT_LIT( "CCAChatViewContainer::IsGroupOpen()" ) ); |
|
1691 CHAT_DP( D_CHAT_LIT( "%d = iChatGroup->IsOpenL()" ), iIsOpen ); |
|
1692 return iIsOpen; |
|
1693 } |
|
1694 |
|
1695 // --------------------------------------------------------- |
|
1696 // CCAChatViewContainer::ExtensionFits() |
|
1697 // (other items were commented in a header). |
|
1698 // --------------------------------------------------------- |
|
1699 // |
|
1700 TBool CCAChatViewContainer::ExtensionFits( TInt aLength ) |
|
1701 { |
|
1702 TBool retVal( ETrue ); |
|
1703 if ( iEditor->MaxLength() - iEditor->TextLength() < aLength ) |
|
1704 { |
|
1705 retVal = EFalse; |
|
1706 } |
|
1707 return retVal; |
|
1708 } |
|
1709 |
|
1710 // logic: |
|
1711 // 1. no groups/groups not supported --> hide "to group" |
|
1712 // 2. no contacts --> hide "to contact" |
|
1713 // 3. 1 and 2 --> hide forward menu completely |
|
1714 // 4. contacts, but no online contacts, show All contacts are Offline |
|
1715 // 5. skip always the current contact we're conversing with |
|
1716 |
|
1717 // --------------------------------------------------------- |
|
1718 // CCAChatViewContainer::FwdContactVisible |
|
1719 // --------------------------------------------------------- |
|
1720 // |
|
1721 TBool CCAChatViewContainer::FwdContactVisible() |
|
1722 { |
|
1723 // contacts |
|
1724 TInt numContacts = iGroupPC->ContactCount(); |
|
1725 |
|
1726 TBool showFwdToContact = numContacts > 0; |
|
1727 |
|
1728 CHAT_DP( D_CHAT_LIT( |
|
1729 "CCAChatViewContainer::FwdContactVisible - contacts %d, show %d" ), |
|
1730 numContacts, showFwdToContact ); |
|
1731 |
|
1732 return showFwdToContact; |
|
1733 } |
|
1734 |
|
1735 // --------------------------------------------------------- |
|
1736 // CCAChatViewContainer::FwdGroupVisible |
|
1737 // --------------------------------------------------------- |
|
1738 // |
|
1739 TBool CCAChatViewContainer::FwdGroupVisible() |
|
1740 { |
|
1741 // groups |
|
1742 TBool groupsSupported = iAppUi->UISessionManager().IsSupported( CCAUISessionManager::EGroup ); |
|
1743 TInt numGroups = iGroupPC->GroupCount( ETrue ); |
|
1744 |
|
1745 // we have to have groups supported and visible to show the forward-menu |
|
1746 // If there is only one group we have to be in it so does not need to show menuitem. |
|
1747 TBool showFwdToGroup = groupsSupported && ( numGroups > 1 ); |
|
1748 |
|
1749 CHAT_DP( D_CHAT_LIT( "CCAChatViewContainer::FwdGroupVisible - fwd show group: %d" ), ( TInt ) showFwdToGroup ); |
|
1750 |
|
1751 return showFwdToGroup; |
|
1752 } |
|
1753 |
|
1754 // --------------------------------------------------------- |
|
1755 // CCAChatViewContainer::ReplyL() |
|
1756 // Reply function |
|
1757 // (other items were commented in a header). |
|
1758 // --------------------------------------------------------- |
|
1759 // |
|
1760 void CCAChatViewContainer::ReplyL() |
|
1761 { |
|
1762 MCAConversationMessage* msg = iChatView->SelectedMessage(); |
|
1763 if ( msg ) |
|
1764 { |
|
1765 TPtrC sender( msg->Sender() ); |
|
1766 iRecipients->AppendL( sender ); |
|
1767 InitPrivateMessageL( sender, EFalse ); |
|
1768 |
|
1769 StartScrollingL(); |
|
1770 iAppUi->SetFocusFlag(ETrue); |
|
1771 } |
|
1772 } |
|
1773 |
|
1774 // --------------------------------------------------------- |
|
1775 // CCAChatViewContainer::EditChatGroupPropertiesL() |
|
1776 // Edits chat group properties. Launches setting dialog |
|
1777 // (other items were commented in a header). |
|
1778 // --------------------------------------------------------- |
|
1779 // |
|
1780 void CCAChatViewContainer::EditChatGroupPropertiesL() |
|
1781 { |
|
1782 |
|
1783 TBool highlight = iChatView->Highlighted(); |
|
1784 |
|
1785 if ( !highlight ) |
|
1786 { |
|
1787 iEditor->SetFocus( EFalse ); |
|
1788 } |
|
1789 |
|
1790 // Prohibit the tab group at this moment |
|
1791 //iAppUi->CAStatusPane()->ProhibitTabGroup( ETrue ); |
|
1792 |
|
1793 TInt result = iAppUi->GroupUtils()->EditChatGroupPropertiesL( *iGroupId ); |
|
1794 |
|
1795 //iAppUi->CAStatusPane()->RestoreNaviPane(); |
|
1796 |
|
1797 if ( !highlight && result != EAknSoftkeyExit ) |
|
1798 { |
|
1799 iEditor->SetFocus( ETrue ); |
|
1800 } |
|
1801 } |
|
1802 |
|
1803 // --------------------------------------------------------- |
|
1804 // CCAChatViewContainer::LeaveGroupL() |
|
1805 // This function starts leaving procedure |
|
1806 // (other items were commented in a header). |
|
1807 // --------------------------------------------------------- |
|
1808 // |
|
1809 void CCAChatViewContainer::LeaveGroupL() |
|
1810 { |
|
1811 //Save group conversation if logging is on |
|
1812 SetLoggingOffL(); |
|
1813 |
|
1814 iAppUi->GroupUtils()->LeaveGroupL( *iGroupId ); |
|
1815 |
|
1816 // Deregister group from switch back views |
|
1817 iAppUi->DeRegisterSwitchBack( KUidChatView, *iGroupId ); |
|
1818 } |
|
1819 |
|
1820 // --------------------------------------------------------- |
|
1821 // CCAChatViewContainer::DisplayChatInfoL() |
|
1822 // Displays chat info |
|
1823 // (other items were commented in a header). |
|
1824 // --------------------------------------------------------- |
|
1825 // |
|
1826 void CCAChatViewContainer::DisplayChatInfoL() |
|
1827 { |
|
1828 iAppUi->GroupUtils()->DisplayChatInfoL( *iGroupId ); |
|
1829 } |
|
1830 |
|
1831 |
|
1832 // --------------------------------------------------------- |
|
1833 // CCAChatViewContainer::HandleEdwinSizeEventL( CEikEdwin* aEdwin, |
|
1834 // TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize ) |
|
1835 // This method is called when editor is extended to two lines |
|
1836 // --------------------------------------------------------- |
|
1837 // |
|
1838 TBool CCAChatViewContainer::HandleEdwinSizeEventL( CEikEdwin* /*aEdwin*/, |
|
1839 TEdwinSizeEvent aEventType, TSize /*aDesirableEdwinSize*/ ) |
|
1840 { |
|
1841 if ( aEventType == EEventSizeChanging ) |
|
1842 { |
|
1843 SizeChanged(); |
|
1844 |
|
1845 DrawNow(); |
|
1846 return ETrue; |
|
1847 } |
|
1848 return EFalse; |
|
1849 } |
|
1850 |
|
1851 // --------------------------------------------------------- |
|
1852 // CCAChatViewContainer::HandleTapEventL() |
|
1853 // (other items were commented in a header). |
|
1854 // --------------------------------------------------------- |
|
1855 // |
|
1856 void CCAChatViewContainer::HandleTapEventL( TTapEvent aEvent, |
|
1857 TUint aControlId ) |
|
1858 { |
|
1859 // Handle the tap events which occur in our child controls: |
|
1860 // Message list and Message editor. |
|
1861 switch ( aControlId ) |
|
1862 { |
|
1863 case EMessageList: |
|
1864 { |
|
1865 // Focused message was double tapped |
|
1866 if ( aEvent == MCATapEventObserver::EDoubleTap ) |
|
1867 { |
|
1868 // Activate tapped item |
|
1869 TBool ignore; |
|
1870 TBool dummyArgument( EFalse ); |
|
1871 if ( IsObjectSelected( ignore, dummyArgument ) ) |
|
1872 { |
|
1873 iAppUi->ProcessCommandL( EChatClientOpenObject ); |
|
1874 } |
|
1875 |
|
1876 } |
|
1877 // Message or item was tapped |
|
1878 else if ( aEvent == MCATapEventObserver::ESingleTap ) |
|
1879 { |
|
1880 // Find objects activate with single tap |
|
1881 iRecipientObserver.ShowPopUpMenuL(); |
|
1882 } |
|
1883 break; |
|
1884 } |
|
1885 case EMessageEditor: |
|
1886 { |
|
1887 // Nothing to do here ATM. |
|
1888 // Focus transition is handled in HandleControlEventL |
|
1889 break; |
|
1890 } |
|
1891 default: |
|
1892 { |
|
1893 // There is an unhandled object or the object returned wrong |
|
1894 // controlId. Check the implementation. |
|
1895 __CHAT_ASSERT_DEBUG( EFalse ); |
|
1896 break; |
|
1897 } |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 // --------------------------------------------------------- |
|
1902 // CCAChatViewContainer::CheckIfPrivateMessageL() |
|
1903 // Checks if written message has private icons |
|
1904 // (other items were commented in a header). |
|
1905 // --------------------------------------------------------- |
|
1906 // |
|
1907 TBool CCAChatViewContainer::CheckIfPrivateMessageL() |
|
1908 { |
|
1909 TInt cursosPos( iEditor->CursorPos() ); |
|
1910 //KPictureChar stands for for space and ':' character |
|
1911 cursosPos -= KPictureChar; |
|
1912 |
|
1913 if ( cursosPos >= 0 && cursosPos <= iNickLength ) |
|
1914 { |
|
1915 TPtrC text( iEditor->Text()->Read( cursosPos, 1 ) ); |
|
1916 |
|
1917 if ( text[0] == KColon ) |
|
1918 { |
|
1919 TInt selectionLength( iEditor->SelectionLength() ); |
|
1920 if ( selectionLength > 0 ) |
|
1921 { |
|
1922 ClearSelectionL( selectionLength ); |
|
1923 iEditor->EnableCcpuSupportL( ETrue ); |
|
1924 } |
|
1925 else |
|
1926 { |
|
1927 iEditor->SetSelectionL( iEditor->CursorPos(), 0 ); |
|
1928 iEditor->EnableCcpuSupportL( EFalse ); |
|
1929 } |
|
1930 return ETrue; |
|
1931 } |
|
1932 } |
|
1933 return EFalse; |
|
1934 } |
|
1935 |
|
1936 // --------------------------------------------------------- |
|
1937 // CCAChatViewContainer::DoHandleGroupPropertiesChangedL |
|
1938 // (other items were commented in a header). |
|
1939 // --------------------------------------------------------- |
|
1940 // |
|
1941 void CCAChatViewContainer::DoHandleGroupPropertiesChangedL() |
|
1942 { |
|
1943 TBool isGroupProps( EFalse ); |
|
1944 iGroupPC->GetPropertiesL( isGroupProps ); |
|
1945 if ( isGroupProps ) |
|
1946 { |
|
1947 TPtrC groupName = iGroupPC->GroupName(); |
|
1948 if ( groupName.Length() > 0 ) |
|
1949 { |
|
1950 // use name when possible |
|
1951 iViewSwitcher.CAStatusPane()->SetTitleL( groupName ); |
|
1952 } |
|
1953 else if ( iGroupId ) |
|
1954 { |
|
1955 // GroupId is the second option |
|
1956 iViewSwitcher.CAStatusPane()->SetTitleL( |
|
1957 CCAPCUtils::DisplayId( *iGroupId ) ); |
|
1958 } |
|
1959 iWhisperingAllowed = ( TEnumsPC::EImpsPropYes == iGroupPC->IsPrivateAllowed() ); |
|
1960 iIsOpen = ( TEnumsPC::EImpsPropYes == iGroupPC->IsOpen() ); |
|
1961 } |
|
1962 else |
|
1963 { |
|
1964 // We don't know the states so assume the worst |
|
1965 iWhisperingAllowed = EFalse; |
|
1966 iIsOpen = EFalse; |
|
1967 } |
|
1968 |
|
1969 |
|
1970 } |
|
1971 |
|
1972 // --------------------------------------------------------- |
|
1973 // CCAChatViewContainer::DoHandleGroupLeftL() |
|
1974 // (other items were commented in a header). |
|
1975 // --------------------------------------------------------- |
|
1976 // |
|
1977 void CCAChatViewContainer::DoHandleGroupLeftL( TInt aReason ) |
|
1978 { |
|
1979 // don't redraw the list box.otherwise we might crash after background to |
|
1980 // foreground switch |
|
1981 IMNoteMapper::ShowNoteL( aReason ); |
|
1982 //SwitchView and DeleteTab is called here as there can be group leave |
|
1983 //because the creater has removed the group or banned the user from the group |
|
1984 |
|
1985 iAppUi->CAStatusPane()->SynchroniseAndRemoveTabGroup(); |
|
1986 iViewSwitcher.SwitchViewL( KUidFriendsListView ); |
|
1987 } |
|
1988 |
|
1989 // --------------------------------------------------------- |
|
1990 // CCAChatViewContainer::LayoutChangedL |
|
1991 // (other items were commented in a header). |
|
1992 // --------------------------------------------------------- |
|
1993 // |
|
1994 void CCAChatViewContainer::LayoutChangedL( TInt aType ) |
|
1995 { |
|
1996 LoadBitmapsL(); |
|
1997 TRect mainPaneRect; |
|
1998 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
1999 SetRect( mainPaneRect ); |
|
2000 |
|
2001 // Update skin context of editor |
|
2002 if ( iEditor ) |
|
2003 { |
|
2004 iEditor->SetupSkinContextL( ETrue ); |
|
2005 } |
|
2006 |
|
2007 CCoeControl::HandleResourceChange( aType ); |
|
2008 } |
|
2009 |
|
2010 // --------------------------------------------------------- |
|
2011 // CCAChatViewContainer::HandleGroupLeft |
|
2012 // (other items were commented in a header). |
|
2013 // --------------------------------------------------------- |
|
2014 // |
|
2015 void CCAChatViewContainer::HandleGroupLeft( TInt aReason ) |
|
2016 { |
|
2017 CHAT_DP_TXT( " !! CCAChatViewContainer::HandleGroupLeft !!!" ); |
|
2018 TRAPD( err, DoHandleGroupLeftL( aReason ) ); |
|
2019 |
|
2020 if ( err ) |
|
2021 { |
|
2022 CActiveScheduler::Current()->Error( err ); |
|
2023 } |
|
2024 } |
|
2025 |
|
2026 // --------------------------------------------------------- |
|
2027 // CCAChatViewContainer::HandleGroupPropertiesChanged() |
|
2028 // (other items were commented in a header). |
|
2029 // --------------------------------------------------------- |
|
2030 // |
|
2031 void CCAChatViewContainer::HandleGroupPropertiesChanged() |
|
2032 { |
|
2033 TRAPD( err, DoHandleGroupPropertiesChangedL() ); |
|
2034 if ( err ) |
|
2035 { |
|
2036 CActiveScheduler::Current()->Error( err ); |
|
2037 } |
|
2038 } |
|
2039 |
|
2040 |
|
2041 // --------------------------------------------------------- |
|
2042 // CCAChatViewContainer::SizeChanged() |
|
2043 // Called by framework when the view size is changed |
|
2044 // --------------------------------------------------------- |
|
2045 // |
|
2046 void CCAChatViewContainer::SizeChanged() |
|
2047 { |
|
2048 |
|
2049 TInt lines( iEditor->NumberOfLines() ); |
|
2050 |
|
2051 if ( lines > KMaxLines ) // ignore events for more than 2 lines |
|
2052 { |
|
2053 lines = 2; |
|
2054 } |
|
2055 lines--; // convert to index |
|
2056 |
|
2057 TAknLayoutRect rp; |
|
2058 if ( lines == 1 ) |
|
2059 { |
|
2060 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( |
|
2061 TChatListBoxLayout::EWithEditor2Lines ) ); |
|
2062 } |
|
2063 else |
|
2064 { |
|
2065 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( |
|
2066 TChatListBoxLayout::EWithEditor ) ); |
|
2067 } |
|
2068 |
|
2069 // Set icon sizes, do this before setting the rect for |
|
2070 // chat view to prevent icon sizes from changing after chat |
|
2071 // view rect is set. |
|
2072 ResizeIcons( TextRect() ); |
|
2073 |
|
2074 // set rect for chat view |
|
2075 iChatView->SetRect( rp.Rect() ); |
|
2076 |
|
2077 |
|
2078 TAknLayoutRect wpl; |
|
2079 wpl.LayoutRect( Rect(), AknLayoutScalable_Apps::im_writing_pane( 1 - lines ) ); |
|
2080 |
|
2081 TAknWindowLineLayout myWPLayout( AknLayoutScalable_Apps::im_writing_pane( 1 - lines ) ); |
|
2082 |
|
2083 iOutLine.LayoutRect( iAppUi->LayoutInfo()->MainPaneRect(), myWPLayout ); |
|
2084 |
|
2085 iVertLine.LayoutRect( wpl.Rect(), AppLayout::IM_writing_field_elements_Line_1( lines ) ); |
|
2086 |
|
2087 iHoriline.LayoutRect( wpl.Rect(), AppLayout::IM_writing_field_elements_Line_2() ); |
|
2088 |
|
2089 TAknMultiLineTextLayout mlwpt = AppLayout::Multiline_IM_writing_pane_texts_Line_1( lines + 1 ); |
|
2090 |
|
2091 AknLayoutUtils::LayoutEdwin( iEditor , wpl.Rect(), mlwpt, EAknsCIQsnTextColorsCG25 ); |
|
2092 |
|
2093 FocusChanged( EDrawNow ); |
|
2094 |
|
2095 DrawNow(); |
|
2096 } |
|
2097 |
|
2098 // --------------------------------------------------------- |
|
2099 // CCAChatViewContainer::CountComponentControls() const |
|
2100 // --------------------------------------------------------- |
|
2101 // |
|
2102 TInt CCAChatViewContainer::CountComponentControls() const |
|
2103 { |
|
2104 //chatview, iEditor |
|
2105 return KControlCount; |
|
2106 } |
|
2107 |
|
2108 // --------------------------------------------------------- |
|
2109 // CCAChatViewContainer::ComponentControl(TInt aIndex) const |
|
2110 // --------------------------------------------------------- |
|
2111 // |
|
2112 CCoeControl* CCAChatViewContainer::ComponentControl( TInt aIndex ) const |
|
2113 { |
|
2114 switch ( aIndex ) |
|
2115 { |
|
2116 case 0: |
|
2117 { |
|
2118 return iChatView; |
|
2119 } |
|
2120 case 1: |
|
2121 { |
|
2122 return iEditor; |
|
2123 |
|
2124 } |
|
2125 default: |
|
2126 { |
|
2127 return NULL; |
|
2128 |
|
2129 } |
|
2130 } |
|
2131 } |
|
2132 |
|
2133 // --------------------------------------------------------- |
|
2134 // CCAChatViewContainer::Draw(const TRect& aRect) const |
|
2135 // --------------------------------------------------------- |
|
2136 // |
|
2137 void CCAChatViewContainer::Draw( const TRect& aRect ) const |
|
2138 { |
|
2139 CWindowGc& gc = SystemGc(); |
|
2140 |
|
2141 // Draw skinned background |
|
2142 iSkinVar->ClearChatListBoxBackGround( |
|
2143 gc, aRect, |
|
2144 iSkinVar->MainPaneBackgroundContext() ); |
|
2145 |
|
2146 TRect editorRect( iEditor->Rect() ); |
|
2147 TRect outlineRect( iOutLine.Rect() ); |
|
2148 TRect parent( Rect() ); |
|
2149 |
|
2150 TBool skinnedDraw = iSkinVar->DrawSkinnedEditor( this, gc, parent, editorRect, outlineRect ); |
|
2151 |
|
2152 if ( ! skinnedDraw ) |
|
2153 { |
|
2154 DrawUtils::ClearBetweenRects( gc, Rect(), iEditor->Rect() ); |
|
2155 |
|
2156 iOutLine.DrawOutLineRect( gc ); |
|
2157 iHoriline.DrawRect( gc ); |
|
2158 iVertLine.DrawRect( gc ); |
|
2159 } |
|
2160 } |
|
2161 |
|
2162 |
|
2163 // --------------------------------------------------------- |
|
2164 // CCAChatViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
2165 // TEventCode aType ) |
|
2166 // Handles keyevents |
|
2167 // --------------------------------------------------------- |
|
2168 // |
|
2169 TKeyResponse CCAChatViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
2170 TEventCode aType ) |
|
2171 { |
|
2172 CHAT_DP( D_CHAT_LIT( "CCAChatViewContainer::OfferKeyEventL key %d" ), aKeyEvent.iCode ); |
|
2173 |
|
2174 if ( ( IsStopped() || !iEditor->IsFocused() ) ) |
|
2175 { |
|
2176 if ( aKeyEvent.iScanCode >= '0' && aKeyEvent.iScanCode <= '9' ) |
|
2177 { |
|
2178 // stop the automatic scrolling and start manual |
|
2179 // if user presses any of the number keys (0-9) |
|
2180 StartScrollingL(); |
|
2181 // Key event gets passed to editor after this |
|
2182 } |
|
2183 } |
|
2184 |
|
2185 if ( aType == EEventKeyDown ) |
|
2186 { |
|
2187 //if "#" is pressed start and timer and show the editing indicator |
|
2188 if ( ( aKeyEvent.iScanCode == KHashKey ) && |
|
2189 ( iEditor->TextLength() == 0 ) ) |
|
2190 { |
|
2191 |
|
2192 if ( !iEditIndicator->IsIndicatorActive() ) |
|
2193 { |
|
2194 iEditIndicator->StartTimer(); |
|
2195 } |
|
2196 |
|
2197 } |
|
2198 } |
|
2199 |
|
2200 switch ( aKeyEvent.iCode ) |
|
2201 { |
|
2202 // flowthrough |
|
2203 case EKeyEnter: |
|
2204 case EKeyOK: |
|
2205 case EKeyPhoneSend: |
|
2206 { |
|
2207 if ( iView->GetIfMenuPopup() ) |
|
2208 { |
|
2209 return EKeyWasConsumed; |
|
2210 } |
|
2211 if ( iEditor->IsFocused() ) |
|
2212 { |
|
2213 iEditor->SetFocus( EFalse ); |
|
2214 // trapping error so that focus can be returned to editor |
|
2215 TRAPD( err, SendMessageL() ); |
|
2216 if ( err ) |
|
2217 { |
|
2218 CActiveScheduler::Current()->Error( err ); |
|
2219 } |
|
2220 iEditor->SetFocus( ETrue ); |
|
2221 } |
|
2222 else if ( aKeyEvent.iCode == EKeyEnter |
|
2223 || aKeyEvent.iCode == EKeyOK |
|
2224 && iChatView->Highlighted() ) |
|
2225 { |
|
2226 TBool ignore; |
|
2227 TBool dummyArgument( EFalse ); |
|
2228 |
|
2229 if ( IsObjectSelected( ignore, dummyArgument ) ) |
|
2230 { |
|
2231 iAppUi->ProcessCommandL( EChatClientOpenObject ); |
|
2232 } |
|
2233 else |
|
2234 { |
|
2235 iRecipientObserver.ShowPopUpMenuL(); |
|
2236 } |
|
2237 } |
|
2238 else if ( iSendkeyInMsgList ) |
|
2239 { |
|
2240 if ( aKeyEvent.iCode == EKeyPhoneSend |
|
2241 && iChatView->Highlighted() |
|
2242 && iChatView->SelectedItemType() |
|
2243 == CFindItemEngine::EFindItemSearchPhoneNumberBin ) |
|
2244 { |
|
2245 // Phone number highlighted, send key pressed -> call |
|
2246 iAppUi->ProcessCommandL( EChatClientCall ); |
|
2247 } |
|
2248 } |
|
2249 return EKeyWasConsumed; |
|
2250 } |
|
2251 |
|
2252 case EKeyBackspace: |
|
2253 { |
|
2254 // if bitmap is selected, it is deleted "normally" in |
|
2255 // iEditor's OfferKeyEvent |
|
2256 if ( iEditor->SelectionLength() > 0 ) |
|
2257 { |
|
2258 break; |
|
2259 } |
|
2260 |
|
2261 if ( CheckIfPrivateMessageL() ) // if there are private icons, don't go back |
|
2262 { |
|
2263 return EKeyWasConsumed; |
|
2264 } |
|
2265 else |
|
2266 { |
|
2267 TInt cursorPos( iEditor->CursorPos() ); |
|
2268 if ( cursorPos > 0 ) // at least one char in editor |
|
2269 { |
|
2270 TPtrC ptr = iEditor->RichText()->Read( ( cursorPos - 1 ), 1 ); |
|
2271 // if a char to be "backspaced" is a picture |
|
2272 if ( ptr[ 0 ] == CEditableText::EPictureCharacter ) |
|
2273 { |
|
2274 iMessageExtensionsHandler.DeleteExtensionL( *iEditor, |
|
2275 EMessageExtensionSmiley, cursorPos - 1 ); |
|
2276 return EKeyWasConsumed; |
|
2277 } |
|
2278 } |
|
2279 |
|
2280 //If cursor pos is less than 2 then it is set to 2 |
|
2281 //KPictureChar for picture characters. (Two icons) |
|
2282 if ( cursorPos < KPictureChar ) |
|
2283 { |
|
2284 cursorPos = 2; |
|
2285 } |
|
2286 |
|
2287 CHAT_DP( D_CHAT_LIT( "CursorPos(): %d" ), cursorPos ); |
|
2288 } |
|
2289 break; |
|
2290 } |
|
2291 |
|
2292 case EKeyLeftArrow: |
|
2293 { |
|
2294 if ( !iEditor->IsFocused() || |
|
2295 ( iEditor->CursorPos() <= iNickLength && |
|
2296 iNickLength > 0 ) ) |
|
2297 { |
|
2298 TKeyResponse res = iAppUi->OfferTabEventL( aKeyEvent, aType ); |
|
2299 if ( ifocusFlag ) |
|
2300 { |
|
2301 StartScrollingL(); |
|
2302 ifocusFlag = EFalse; |
|
2303 } |
|
2304 else |
|
2305 { |
|
2306 iAppUi->SetFocusFlag( EFalse ); |
|
2307 } |
|
2308 return res; |
|
2309 } |
|
2310 break; |
|
2311 } |
|
2312 |
|
2313 case EKeyRightArrow: |
|
2314 { |
|
2315 if ( !iEditor->IsFocused() ) |
|
2316 { |
|
2317 TKeyResponse res = iAppUi->OfferTabEventL( aKeyEvent, aType ); |
|
2318 if ( ifocusFlag ) |
|
2319 { |
|
2320 StartScrollingL(); |
|
2321 ifocusFlag = EFalse; |
|
2322 } |
|
2323 else |
|
2324 { |
|
2325 iAppUi->SetFocusFlag( EFalse ); |
|
2326 } |
|
2327 return res; |
|
2328 } |
|
2329 |
|
2330 TInt cursorPos( iEditor->CursorPos() ); |
|
2331 |
|
2332 if ( ( cursorPos >= 0 ) && |
|
2333 ( cursorPos < iNickLength ) && |
|
2334 ( iNickLength > 0 ) ) |
|
2335 { |
|
2336 TPtrC text( iEditor->Text()->Read( cursorPos, 1 ) ); |
|
2337 |
|
2338 if ( text[0] == CEditableText::EPictureCharacter ) |
|
2339 { |
|
2340 iEditor->SetCursorPosL( iNickLength, EFalse ); |
|
2341 return EKeyWasConsumed; |
|
2342 } |
|
2343 } |
|
2344 else if ( cursorPos == iEditor->TextLength() ) |
|
2345 { |
|
2346 iEditor->SetCursorPosL( iNickLength, EFalse ); |
|
2347 return EKeyWasConsumed; |
|
2348 } |
|
2349 break; |
|
2350 } |
|
2351 |
|
2352 case EKeyDownArrow: // flowthrough |
|
2353 case EKeyUpArrow: |
|
2354 { |
|
2355 if ( iEditor->IsFocused() ) |
|
2356 { |
|
2357 // editor is focused, try to offer the key |
|
2358 if ( iEditor->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) |
|
2359 { |
|
2360 // editor took it |
|
2361 return EKeyWasConsumed; |
|
2362 } |
|
2363 } |
|
2364 |
|
2365 // offer the key to our chat control |
|
2366 TKeyResponse res = static_cast<CCoeControl*>( iChatView ) |
|
2367 ->OfferKeyEventL( aKeyEvent, aType ); |
|
2368 |
|
2369 if ( iChatView->Highlighted() ) |
|
2370 { |
|
2371 // change the cba |
|
2372 StopScrollingL(); |
|
2373 |
|
2374 iAppUi->SetFocusFlag( EFalse ); |
|
2375 } |
|
2376 else |
|
2377 { |
|
2378 // change the cba |
|
2379 StartScrollingL(); |
|
2380 |
|
2381 iAppUi->SetFocusFlag( ETrue ); |
|
2382 } |
|
2383 return res; |
|
2384 } |
|
2385 } |
|
2386 |
|
2387 if ( iEditor->IsFocused() ) |
|
2388 { |
|
2389 TKeyResponse resp = iEditor->OfferKeyEventL( aKeyEvent, aType ); |
|
2390 |
|
2391 TInt cursorPos( iEditor->CursorPos() ); |
|
2392 if ( ( cursorPos >= 0 ) && |
|
2393 ( cursorPos < iNickLength ) && |
|
2394 ( iNickLength > 0 ) ) |
|
2395 { |
|
2396 TPtrC text( iEditor->Text()->Read( cursorPos, 1 ) ); |
|
2397 |
|
2398 if ( text[0] == CEditableText::EPictureCharacter ) |
|
2399 { |
|
2400 iEditor->SetCursorPosL( iNickLength, EFalse ); |
|
2401 } |
|
2402 } |
|
2403 |
|
2404 // Update CBA only when there is not a shift held down |
|
2405 if ( !( aKeyEvent.iModifiers & EModifierShift ) ) |
|
2406 { |
|
2407 UpdateCbaL(); |
|
2408 } |
|
2409 TInt inputLang = iAvkonEnv->SettingCache().InputLanguage(); // when the language has candidate |
|
2410 if ( ( inputLang != ELangPrcChinese ) && ( inputLang != ELangHongKongChinese )// pane then switching between tabs shouldnot |
|
2411 && ( inputLang != ELangTaiwanChinese ) && ( inputLang != ELangJapanese ) ) // happen, when editor is empty. |
|
2412 { |
|
2413 if ( resp == EKeyWasNotConsumed && iEditor->TextLength() == 0 |
|
2414 && aType == EEventKeyDown |
|
2415 && ( aKeyEvent.iScanCode == EStdKeyLeftArrow |
|
2416 || aKeyEvent.iScanCode == EStdKeyRightArrow ) ) |
|
2417 { |
|
2418 StopScrollingL(); |
|
2419 ifocusFlag = ETrue; |
|
2420 iAppUi->SetFocusFlag( ETrue ); |
|
2421 } |
|
2422 } |
|
2423 return resp; |
|
2424 } |
|
2425 |
|
2426 return EKeyWasNotConsumed; |
|
2427 } |
|
2428 |
|
2429 |
|
2430 // --------------------------------------------------------- |
|
2431 // CCAChatViewContainer::HandleMessageEditorEventL |
|
2432 // --------------------------------------------------------- |
|
2433 // |
|
2434 void CCAChatViewContainer::HandleMessageEditorEventL( TEditorEvent aEvent ) |
|
2435 { |
|
2436 switch ( aEvent ) |
|
2437 { |
|
2438 case EEditorContentCleared: // Flowthrough |
|
2439 { |
|
2440 // Call StartScrollingL to update CBA if needed |
|
2441 StartScrollingL(); |
|
2442 break; |
|
2443 } |
|
2444 case EEditorFirstContentAdded: |
|
2445 { |
|
2446 if ( !iEditor->IsFocused() ) |
|
2447 { |
|
2448 StartScrollingL(); |
|
2449 } |
|
2450 break; |
|
2451 } |
|
2452 default: |
|
2453 { |
|
2454 break; |
|
2455 } |
|
2456 } |
|
2457 } |
|
2458 |
|
2459 // --------------------------------------------------------- |
|
2460 // CCAChatViewContainer::GetHelpContext |
|
2461 // This function is called when Help application is launched |
|
2462 // (other items were commented in a header). |
|
2463 // --------------------------------------------------------- |
|
2464 // |
|
2465 void CCAChatViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
2466 { |
|
2467 aContext.iMajor = KUidChatClient; |
|
2468 aContext.iContext = KIMNG_HLP_CONVERSATIONS ; |
|
2469 } |
|
2470 // --------------------------------------------------------- |
|
2471 // CCAConversationsContainer::FocusChanged |
|
2472 // This function is called when focus has been changed |
|
2473 // (other items were commented in a header). |
|
2474 // --------------------------------------------------------- |
|
2475 // |
|
2476 void CCAChatViewContainer::FocusChanged(TDrawNow aDrawNow) |
|
2477 { |
|
2478 if ( iEditor && iAppUi->FocusFlag() ) |
|
2479 { |
|
2480 iEditor->SetFocus( IsFocused() ); |
|
2481 } |
|
2482 |
|
2483 CCoeControl::FocusChanged( aDrawNow ); |
|
2484 } |
|
2485 |
|
2486 // --------------------------------------------------------- |
|
2487 // CCAChatViewContainer::RefreshEditorL |
|
2488 // --------------------------------------------------------- |
|
2489 // |
|
2490 void CCAChatViewContainer::RefreshEditorL() |
|
2491 { |
|
2492 iEditor->RefreshEditorL(); |
|
2493 } |
|
2494 |
|
2495 // --------------------------------------------------------- |
|
2496 // CCAChatViewContainer::IsItemHighlight |
|
2497 // --------------------------------------------------------- |
|
2498 // |
|
2499 TBool CCAChatViewContainer::IsItemHighlight() const |
|
2500 { |
|
2501 return iItemHighlight; |
|
2502 } |
|
2503 |
|
2504 // --------------------------------------------------------- |
|
2505 // CCAChatViewContainer::TextRect |
|
2506 // --------------------------------------------------------- |
|
2507 // |
|
2508 const TRect CCAChatViewContainer::TextRect() const |
|
2509 { |
|
2510 TInt lines( iEditor->NumberOfLines() ); |
|
2511 |
|
2512 if ( lines > KMaxLines ) // ignore events for more than 2 lines |
|
2513 { |
|
2514 lines = 2; |
|
2515 } |
|
2516 lines--; // convert to index |
|
2517 |
|
2518 TAknLayoutRect rp; |
|
2519 if ( lines == 1 ) |
|
2520 { |
|
2521 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( 0 |
|
2522 /*TChatListBoxLayout::EWithEditor2Lines*/ ) ); |
|
2523 } |
|
2524 else |
|
2525 { |
|
2526 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( 1 |
|
2527 /*TChatListBoxLayout::EWithEditor*/ ) ); |
|
2528 } |
|
2529 |
|
2530 TAknLayoutText text; |
|
2531 text.LayoutText( rp.Rect(), |
|
2532 AknLayoutScalable_Apps::im_reading_pane_t1( 1 ).LayoutLine() ); |
|
2533 |
|
2534 return text.TextRect(); |
|
2535 } |
|
2536 |
|
2537 // --------------------------------------------------------- |
|
2538 // CCAChatViewContainer::HandleControlEventL |
|
2539 // --------------------------------------------------------- |
|
2540 // |
|
2541 void CCAChatViewContainer::HandleControlEventL( CCoeControl* aControl, |
|
2542 TCoeEvent aEventType ) |
|
2543 { |
|
2544 if ( EEventRequestFocus == aEventType ) |
|
2545 { |
|
2546 if ( aControl == ( CCoeControl* )iEditor ) |
|
2547 { |
|
2548 // Focus to editor |
|
2549 StartScrollingL(); |
|
2550 iAppUi->SetFocusFlag( ETrue ); |
|
2551 } |
|
2552 else // aControl == iChatView |
|
2553 { |
|
2554 // Focus to messagelist |
|
2555 StopScrollingL(); |
|
2556 iAppUi->SetFocusFlag( EFalse ); |
|
2557 } |
|
2558 } |
|
2559 |
|
2560 if ( CATouchUtils::PenEnabled() ) |
|
2561 { |
|
2562 if ( EEventStateChanged == aEventType ) |
|
2563 { |
|
2564 if ( aControl == ( CCoeControl* )iEditor ) |
|
2565 { |
|
2566 // Update MSK - When using virtual keyboard |
|
2567 // on touch enabled devices, one is bound to receive |
|
2568 // EEventStateChanged. Hence handle the same |
|
2569 UpdateCbaL(); |
|
2570 } |
|
2571 } |
|
2572 } |
|
2573 |
|
2574 } |
|
2575 |
|
2576 |
|
2577 // --------------------------------------------------------- |
|
2578 // CCAChatViewContainer::SwitchTabL |
|
2579 // --------------------------------------------------------- |
|
2580 // |
|
2581 void CCAChatViewContainer::SwitchTabL() |
|
2582 { |
|
2583 |
|
2584 if ( iGroupId ) |
|
2585 { |
|
2586 |
|
2587 iGroupPC->SetGroupEventObserverL( NULL, *iGroupId ); |
|
2588 |
|
2589 delete iGroupId; |
|
2590 iGroupId = NULL; |
|
2591 } |
|
2592 |
|
2593 iGroupId = iGroupPC->ActiveGroupId().AllocL(); |
|
2594 |
|
2595 HandleGroupPropertiesChanged(); |
|
2596 |
|
2597 iGroupPC->SetGroupEventObserverL( this, *iGroupId ); |
|
2598 |
|
2599 delete iChatView; |
|
2600 iChatView = NULL; |
|
2601 |
|
2602 MCAMsgAddedToRichTxtCtrlObserver* observer = NULL; |
|
2603 |
|
2604 if ( !iAppUi->FocusFlag() ) |
|
2605 { |
|
2606 observer = this; |
|
2607 } |
|
2608 |
|
2609 iChatView = CCAChatViewControl::NewL( Rect(), *this, |
|
2610 *iGroupPC, |
|
2611 *iAppUi->GetProcessManager().GetSettingsInterface(), |
|
2612 iMessageExtensionsHandler, |
|
2613 iPrivIcon, iToMe, |
|
2614 iUnsupported, |
|
2615 iCorrupted, |
|
2616 ETrue, |
|
2617 observer |
|
2618 ); |
|
2619 |
|
2620 iChatView->SetObserver( this ); |
|
2621 |
|
2622 SizeChanged(); |
|
2623 |
|
2624 // Observe tap events |
|
2625 iChatView->SetTapObserver( this, EMessageList ); |
|
2626 |
|
2627 iAppUi->LayoutInfo()->SetLayoutID( TChatListBoxLayout::EWithEditor ); |
|
2628 iAppUi->LayoutInfo()->SetEditorVisibility( ETrue ); |
|
2629 |
|
2630 if ( iAppUi->FocusFlag() ) |
|
2631 { |
|
2632 StartScrollingL(); |
|
2633 } |
|
2634 } |
|
2635 |
|
2636 // --------------------------------------------------------- |
|
2637 // CCAChatViewContainer::HandleMessageAddedL |
|
2638 // --------------------------------------------------------- |
|
2639 // |
|
2640 void CCAChatViewContainer::HandleMessageAddedL( const TInt aMessageCount ) |
|
2641 { |
|
2642 //called by tabswitch. hence set the foxus to the last message |
|
2643 if ( iGroupPC->MessageCount() == aMessageCount ) |
|
2644 { |
|
2645 iChatView->MoveHighlightL( CCARichTextContainer::EPrevious ); |
|
2646 |
|
2647 iChatView->UnRegisterRichTxtCtrlObserver(); |
|
2648 |
|
2649 UpdateCbaL(); |
|
2650 } |
|
2651 |
|
2652 } |
|
2653 |
|
2654 #ifdef RD_MULTIPLE_DRIVE |
|
2655 // ----------------------------------------------------------------------------- |
|
2656 // CCAChatViewContainer::ShowMemorySelectionDialogL |
|
2657 // New actual filename for new history file. |
|
2658 // ----------------------------------------------------------------------------- |
|
2659 // |
|
2660 TBool CCAChatViewContainer::ShowMemorySelectionDialogL() |
|
2661 { |
|
2662 CHAT_DP_TXT( "CCALoggerManager::ShowMemorySelectionDialogL" ); |
|
2663 |
|
2664 ///////// read settings from cenrep /////////////// |
|
2665 |
|
2666 TBuf< KMaxPath > defaultDrive; |
|
2667 TBuf< KMaxPath > pathTempWithoutDrive; |
|
2668 TBuf< KMaxPath > driveAndPath; |
|
2669 |
|
2670 CRepository* cenrep = NULL; |
|
2671 TRAPD( err, cenrep = CRepository::NewL( KWVSettingsCenRepUid ) ); |
|
2672 |
|
2673 if ( err == KErrNone ) |
|
2674 { |
|
2675 // creation of cenrep OK |
|
2676 CleanupStack::PushL( cenrep ); |
|
2677 err = cenrep->Get( KIMPSCRIMDefaultMemoryDrive, defaultDrive ); |
|
2678 if ( err != KErrNone ) |
|
2679 { |
|
2680 CleanupStack::PopAndDestroy( cenrep ); |
|
2681 cenrep = NULL; |
|
2682 User::Leave( err ); |
|
2683 } |
|
2684 // end of reading from cenrep |
|
2685 |
|
2686 |
|
2687 TInt driveNo = 0; |
|
2688 err = RFs::CharToDrive( defaultDrive[0], driveNo ); |
|
2689 TDriveNumber driveNumber = TDriveNumber( driveNo ); |
|
2690 |
|
2691 // Check drive's media status |
|
2692 TBool isDriveOk = iAppUi->GetDriveStatusL( driveNumber ); |
|
2693 if ( !isDriveOk ) |
|
2694 { |
|
2695 |
|
2696 // prompt the user to save into a different drive....... |
|
2697 CAknMemorySelectionDialogMultiDrive* dlg = CAknMemorySelectionDialogMultiDrive::NewL( |
|
2698 ECFDDialogTypeSave, |
|
2699 EFalse ); |
|
2700 |
|
2701 HBufC* rootBuffer = HBufC::NewLC( KMaxPath ); |
|
2702 TPtr rootBufferPtr ( rootBuffer->Des() ); |
|
2703 |
|
2704 HBufC* defaultFolderBuffer = HBufC::NewLC( KMaxPath ); |
|
2705 TPtr defaultFolderBufferPtr ( defaultFolderBuffer->Des() ); |
|
2706 |
|
2707 CleanupStack::PushL( dlg ); |
|
2708 TBool ret( dlg->ExecuteL( driveNumber, &rootBufferPtr, &defaultFolderBufferPtr ) ); |
|
2709 CleanupStack::PopAndDestroy( dlg ); |
|
2710 |
|
2711 CleanupStack::PopAndDestroy( defaultFolderBuffer ); |
|
2712 |
|
2713 if ( ret ) |
|
2714 { |
|
2715 // update the centrep sheet also..as user changed the default folder... |
|
2716 cenrep->Set( KIMPSCRIMDefaultMemoryDrive, rootBufferPtr.Left( 3 ) ); |
|
2717 driveAndPath.Append( rootBufferPtr.Left( 2 ) ); // append the drive root here with user selected drive... |
|
2718 CleanupStack::PopAndDestroy( rootBuffer ); |
|
2719 CleanupStack::PopAndDestroy( cenrep ); |
|
2720 cenrep = NULL; |
|
2721 } |
|
2722 else |
|
2723 { |
|
2724 CleanupStack::PopAndDestroy( rootBuffer ); |
|
2725 CleanupStack::PopAndDestroy( cenrep ); |
|
2726 cenrep = NULL; |
|
2727 } |
|
2728 // use selected memory |
|
2729 return ret; |
|
2730 } |
|
2731 else |
|
2732 { |
|
2733 CleanupStack::PopAndDestroy( cenrep ); |
|
2734 cenrep = NULL; |
|
2735 // use the default memory |
|
2736 return ETrue; |
|
2737 } |
|
2738 } |
|
2739 |
|
2740 // cenrep create error |
|
2741 return EFalse; |
|
2742 } |
|
2743 |
|
2744 |
|
2745 #endif |
|
2746 |
|
2747 // End of File |