|
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 conversations view |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknSettingCache.h> |
|
19 |
|
20 #include "CAPresenceManager.h" |
|
21 #include "MCAPresence.h" |
|
22 #include "ccafetchwaiter.h" |
|
23 #include "ccasyncchecker.h" |
|
24 #include "ImpsCSPAllErrors.h" |
|
25 |
|
26 // INCLUDE FILES |
|
27 #include "CCAConversationsContainer.h" |
|
28 #include "MCAViewSwitcher.h" |
|
29 #include "CCAMessageEditor.h" |
|
30 #include "ChatDefinitions.h" |
|
31 #include "ChatDebugPrint.h" |
|
32 #include "CCAAppUi.h" |
|
33 #include "CCAContactEditor.h" |
|
34 #include "CCAStatusPaneHandler.h" |
|
35 #include "MCABlockingPC.h" |
|
36 #include "IMDialogUtils.h" |
|
37 #include "MCARecipientObserver.h" |
|
38 #include "CAExternalinterface.h" |
|
39 #include "IMNoteMapper.h" |
|
40 #include "CCABlockingUI.h" |
|
41 #include "chatngclient.hrh" |
|
42 #include "CCAApp.h" |
|
43 #include "CCAVariantFactory.h" |
|
44 #include "MCASkinVariant.h" |
|
45 #include "CCAUISessionManager.h" |
|
46 #include "CCAMessageExtensionsHandler.h" |
|
47 #include "CCAChatViewControl.h" |
|
48 #include "IMDialogUtils.h" |
|
49 |
|
50 #include "TCAChatListBoxLayout.h" |
|
51 #include "IMUtils.h" |
|
52 #include "CAUtils.h" |
|
53 #include "ccawaitnote.h" |
|
54 #include "chatdebugassert.h" |
|
55 #include "CCAPCUtils.h" |
|
56 |
|
57 #include "MCAMessageErrorInformer.h" |
|
58 #include "MCAMessageUtils.h" |
|
59 #include "MCAMessageCreator.h" |
|
60 #include "MCAMessageContainerInfo.h" |
|
61 #include "MCAMessageUtils.h" |
|
62 #include "MCAContentProcessor.h" |
|
63 #include "MCASettingsPC.h" |
|
64 #include "MCAConversationMessage.h" |
|
65 #include "MCALayoutInfo.h" |
|
66 |
|
67 |
|
68 #include "imnginternalcrkeys.h" |
|
69 #include "imprivatecrkeys.h" |
|
70 #include "imvariant.hrh" |
|
71 #include "CCAAppSettingsSAPExt.h" |
|
72 |
|
73 |
|
74 #include "MCAUiLoginCmdCB.h" |
|
75 #include "MCAConversationPC.h" |
|
76 #include "CCAEditIndicator.h" |
|
77 #include "MCAProcessManager.h" |
|
78 #include "CCAUiMessageUtils.h" |
|
79 #include "MCALoginPC.h" |
|
80 #include "MCALoginRefreshObserverPC.h" |
|
81 |
|
82 #include <finditemengine.h> |
|
83 #include <apgcli.h> |
|
84 #include <S32FILE.H> |
|
85 #include <npdapi.h> |
|
86 #include <chatNG.mbg> |
|
87 #include <chatNG.rsg> |
|
88 #include <aknnotedialog.h> |
|
89 #include <StringLoader.h> |
|
90 #include <csxhelp/imng.hlp.hrh> |
|
91 #include <impserrors.h> |
|
92 #include <txtrich.h> |
|
93 #include <gulicon.h> |
|
94 #include <AknLayout.cdl.h> //cdl |
|
95 #include <AppLayout.cdl.h> //cdl |
|
96 #include <AknsUtils.h> |
|
97 #include <AknLayoutScalable_Apps.cdl.h> |
|
98 #include <aknnotewrappers.h> |
|
99 #include <AknFepGlobalEnums.h> // for EAknFepSoftkeySpell |
|
100 #include <barsread.h> |
|
101 |
|
102 #include "CATouchUtils.h" |
|
103 |
|
104 // The Settings have been moved to Cenrep (also retained in the Resource file), |
|
105 // so the enums for keys and central repository header is added here |
|
106 #include "VariantKeys.h" |
|
107 #ifdef RD_MULTIPLE_DRIVE |
|
108 #include <centralrepository.h> |
|
109 #include <IMPSServiceSettingsUINGInternalCRKeys.h> |
|
110 #include <E32std.h> |
|
111 #include <EIKAPP.H> |
|
112 #include <eikappui.h> |
|
113 #include <eikenv.h> |
|
114 #include <eikbtgpc.h> |
|
115 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
116 //CONSTANTS |
|
117 const TInt KErrNotSaved = -999; |
|
118 #endif |
|
119 |
|
120 // CONSTANTS |
|
121 // Maximum amount of lines in the editor |
|
122 const TInt KChatConvEditorMaxLines = 2; |
|
123 |
|
124 |
|
125 // ============================ MEMBER FUNCTIONS =============================== |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CCAConversationsContainer::NewL |
|
130 // Symbian constructor can leave. |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CCAConversationsContainer* CCAConversationsContainer::NewL( |
|
134 const TRect& aRect, |
|
135 MCAViewSwitcher& aViewSwitcher, |
|
136 MCAConversationPC* aCCAConversationManagerPC, |
|
137 MCARecipientObserver& aRecipientObserver, |
|
138 MObjectProvider* aParent, |
|
139 CCAMessageExtensionsHandler& aMessageHandler, |
|
140 MCATitleUpdater& aTitleUpdater, |
|
141 MCAEditorContentStorage& aEditorContentStorage, |
|
142 CEikButtonGroupContainer* aCba, |
|
143 TBool aActivateFromTabSwitch, |
|
144 TInt& aTabId ) |
|
145 { |
|
146 CCAConversationsContainer* self = new ( ELeave ) CCAConversationsContainer( |
|
147 aViewSwitcher, aCCAConversationManagerPC, aRecipientObserver, |
|
148 aMessageHandler, aTitleUpdater, aEditorContentStorage, aCba, aTabId ); |
|
149 |
|
150 CleanupStack::PushL( self ); |
|
151 self->ConstructL( aRect, aParent, aActivateFromTabSwitch ); |
|
152 CleanupStack::Pop( self ); |
|
153 return self; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CCAConversationsContainer::CCAConversationsContainer |
|
158 // Default constructor must not leave |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 CCAConversationsContainer::CCAConversationsContainer( |
|
162 MCAViewSwitcher& aViewSwitcher, |
|
163 MCAConversationPC* aCCAConversationManagerPC, |
|
164 MCARecipientObserver& aRecipientObserver, |
|
165 CCAMessageExtensionsHandler& aMessageHandler, |
|
166 MCATitleUpdater& aTitleUpdater, |
|
167 MCAEditorContentStorage& aEditorContentStorage, |
|
168 CEikButtonGroupContainer* aCba, |
|
169 TInt& aTabId ) |
|
170 |
|
171 : iViewSwitcher( aViewSwitcher ), |
|
172 iRecipientObserver( aRecipientObserver ), |
|
173 iIsChangeToOnlineAskedOnce( EFalse ), |
|
174 iMessageExtensionsHandler( aMessageHandler ), |
|
175 iTitleUpdater( aTitleUpdater ), |
|
176 iEditorContentStorage( aEditorContentStorage ), |
|
177 iCba( aCba ), |
|
178 iConversationPC( aCCAConversationManagerPC ), |
|
179 iTabId( aTabId ) |
|
180 { |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CCAConversationsContainer::ConstructL |
|
185 // Symbian 2nd phase constructor can leave. |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CCAConversationsContainer::ConstructL( const TRect& aRect, |
|
189 MObjectProvider* aParent, |
|
190 TBool aActivateFromTabSwitch ) |
|
191 { |
|
192 // for getting mbm path from CCAAppUi |
|
193 iAppUi = static_cast<CCAAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
194 iAppUi->AddLayoutChangeObserver( this ); |
|
195 |
|
196 // This must be done first. |
|
197 SetMopParent( aParent ); |
|
198 |
|
199 CreateWindowL(); |
|
200 CCAApp* app = static_cast<CCAApp*>( |
|
201 CEikonEnv::Static()->EikAppUi()->Application() ); |
|
202 iSkinVar = app->VariantFactory()->SkinVariantL(); |
|
203 |
|
204 AknEditUtils::SAknEditorParameters editorParams; |
|
205 editorParams.iCursorYesNo = ETrue; |
|
206 editorParams.iAllowedToMoveInsertionPoint = ETrue; |
|
207 editorParams.iCharacterCase = EAknEditorTextCase; |
|
208 editorParams.iEditingSpace = IMUtils::MaxMsgLength(); |
|
209 editorParams.iEditingWindow = KChatConvEditorMaxLines; |
|
210 editorParams.iJustification = EAknEditorAlignBidi; |
|
211 editorParams.iOverflowYesNo = EFalse; |
|
212 |
|
213 iEditor = new ( ELeave ) CCAMessageEditor( iMessageExtensionsHandler ); |
|
214 iEditor->SetMopParent( this ); |
|
215 AknEditUtils::ConstructEditingL( iEditor, editorParams ); |
|
216 iEditor->SetContainerWindowL( *this ); |
|
217 iEditor->SetAllowPictures( ETrue ); |
|
218 |
|
219 iEditor->SetEdwinSizeObserver( this ); |
|
220 iEditor->SetMessageEditorObserver( this ); |
|
221 |
|
222 LoadBitmapsL(); |
|
223 |
|
224 MCAMsgAddedToRichTxtCtrlObserver* observer = NULL; |
|
225 |
|
226 if ( aActivateFromTabSwitch && !iAppUi->FocusFlag() ) |
|
227 { |
|
228 observer = this; |
|
229 } |
|
230 |
|
231 iChatView = CCAChatViewControl::NewL( aRect, *this, |
|
232 *iConversationPC, |
|
233 *iAppUi->GetProcessManager().GetSettingsInterface(), |
|
234 iMessageExtensionsHandler, |
|
235 iFromMe, |
|
236 iToMe, |
|
237 iUnsupported, |
|
238 iCorrupted, |
|
239 ETrue, |
|
240 observer ); |
|
241 |
|
242 iChatView->SetObserver( this ); |
|
243 |
|
244 iAppUi->LayoutInfo()->SetLayoutID( TChatListBoxLayout::EWithEditor ); |
|
245 iAppUi->LayoutInfo()->SetEditorVisibility( ETrue ); |
|
246 |
|
247 iEditor->SetupSkinContextL(); |
|
248 iEditor->SetCursorPosL( 0, EFalse ); |
|
249 |
|
250 if ( !aActivateFromTabSwitch ) |
|
251 { |
|
252 iEditor->SetFocus( ETrue ); |
|
253 iAppUi->SetFocusFlag( ETrue ); |
|
254 iChatView->SetFocus( EFalse ); |
|
255 } |
|
256 else |
|
257 { |
|
258 iEditor->SetFocus( EFalse ); |
|
259 iChatView->SetFocus( ETrue ); |
|
260 } |
|
261 |
|
262 iEditor->SetObserver( this ); |
|
263 |
|
264 iBlockingUI = CCABlockingUI::NewL( iAppUi->GetProcessManager().GetBlockingInterface() ); |
|
265 |
|
266 iSendkeyInMsgList = ( IMUtils::CRKeyL( KCRUidIMVariation, KIMVariationKey ) |
|
267 & EIMFeatSendkeyInMsgList ); |
|
268 |
|
269 SetRect( aRect ); |
|
270 |
|
271 ActivateL(); |
|
272 TBool tempFlag = aActivateFromTabSwitch; |
|
273 if ( iAppUi->FocusFlag() && aActivateFromTabSwitch ) |
|
274 { |
|
275 tempFlag = EFalse; |
|
276 } |
|
277 |
|
278 ResetAfterSendL( tempFlag ); |
|
279 |
|
280 CHAT_DP( D_CHAT_LIT( "CursorPos(): %d" ), iEditor->CursorPos() ); |
|
281 CHAT_DP( D_CHAT_LIT( "TextLength(): %d" ), iEditor->TextLength() ); |
|
282 |
|
283 // Observe tap events |
|
284 iChatView->SetTapObserver( this, EMessageList ); |
|
285 iEditor->SetTapObserver( this, EMessageEditor ); |
|
286 |
|
287 iEditIndicator = CCAEditIndicator::NewL( *iEditor ) ; |
|
288 ifocusFlag = EFalse; |
|
289 } |
|
290 |
|
291 // Destructor |
|
292 CCAConversationsContainer::~CCAConversationsContainer() |
|
293 { |
|
294 |
|
295 delete iFromMe; |
|
296 delete iToMe; |
|
297 delete iUnsupported; |
|
298 delete iCorrupted; |
|
299 delete iChatView; |
|
300 |
|
301 delete iEditIndicator; |
|
302 delete iEditor; |
|
303 delete iBlockingUI; |
|
304 if ( iAppUi ) |
|
305 { |
|
306 if ( !iAppUi->IsUnderDestruction() ) |
|
307 { |
|
308 iAppUi->LayoutInfo()->SetEditorVisibility( EFalse ); |
|
309 iAppUi->RemoveLayoutChangeObserver( this ); |
|
310 |
|
311 } |
|
312 } |
|
313 } |
|
314 |
|
315 |
|
316 // --------------------------------------------------------- |
|
317 // CCAConversationsContainer::IsObjectSelected |
|
318 // --------------------------------------------------------- |
|
319 // |
|
320 TBool CCAConversationsContainer::IsObjectSelected( TBool& aIsOpenable , TBool& aSavePossible ) |
|
321 { |
|
322 MCAConversationMessage* msg = iChatView->SelectedMessage(); |
|
323 if ( !msg ) |
|
324 { |
|
325 // Nothing selected |
|
326 return EFalse; |
|
327 } |
|
328 |
|
329 TBool object = EFalse; |
|
330 |
|
331 if ( msg->ContentType() == TEnumsPC::EContentPicture || |
|
332 msg->ContentType() == TEnumsPC::EContentOther ) |
|
333 { |
|
334 // We have object |
|
335 object = ETrue; |
|
336 } |
|
337 |
|
338 |
|
339 switch ( msg->ContentProcessState() ) |
|
340 { |
|
341 case TEnumsPC::EContentNotSupported: |
|
342 case TEnumsPC::EContentCorrupted: |
|
343 case TEnumsPC::EContentNotSupportedDrm: |
|
344 { |
|
345 // Not supported or corrupted, can't open |
|
346 aIsOpenable = EFalse; |
|
347 break; |
|
348 } |
|
349 case TEnumsPC::EThumbnailReady: |
|
350 default: |
|
351 { |
|
352 if ( msg->ContentData().Length() == 0 ) |
|
353 { |
|
354 // No content, don't allow opening |
|
355 aIsOpenable = EFalse; |
|
356 } |
|
357 else |
|
358 { |
|
359 // Allow opening |
|
360 aIsOpenable = ETrue; |
|
361 |
|
362 //fix - refer Ui Spec Approved Version 1.0 |
|
363 //(Instant Messaging NG 001 151006.pdf) |
|
364 //Section 10.2.10 Pg 131 - |
|
365 //"In case user has saved the image already or sent it |
|
366 //by himself, this option(save) is not available." |
|
367 aSavePossible = ( ( msg->MessagerType() == TEnumsPC::EMessageSent ) |
|
368 || ( msg->IsImageSaved() ) ) |
|
369 ? EFalse : ETrue ; |
|
370 } |
|
371 } |
|
372 } |
|
373 |
|
374 return object; |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------- |
|
378 // CCAConversationsContainer::SelectedMessage |
|
379 // --------------------------------------------------------- |
|
380 // |
|
381 MCAConversationMessage* CCAConversationsContainer::SelectedMessage() |
|
382 { |
|
383 return iChatView->SelectedMessage(); |
|
384 } |
|
385 |
|
386 // --------------------------------------------------------- |
|
387 // CCAConversationsContainer::FetchMessages |
|
388 // --------------------------------------------------------- |
|
389 // |
|
390 void CCAConversationsContainer::FetchMessages( TBool aFetch ) |
|
391 { |
|
392 iChatView->FetchMessages( aFetch ); |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------- |
|
396 // CCAConversationsContainer::SelectedItem() |
|
397 // --------------------------------------------------------- |
|
398 // |
|
399 HBufC* CCAConversationsContainer::SelectedItemL() |
|
400 { |
|
401 return iChatView->SelectedItemL(); |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CCAConversationsContainer::SelectedItemType |
|
406 // (other items were commented in a header). |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 TInt CCAConversationsContainer::SelectedItemType() |
|
410 { |
|
411 return iChatView->SelectedItemType(); |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------- |
|
415 // CCAConversationsContainer::IsStopped() |
|
416 // This method checks if scroll mode is on or off |
|
417 // --------------------------------------------------------- |
|
418 // |
|
419 TBool CCAConversationsContainer::IsStopped() const |
|
420 { |
|
421 return iChatView->Highlighted(); |
|
422 } |
|
423 |
|
424 // ----------------------------------------------------------------------------- |
|
425 // CCAConversationsContainer::SetItemHighlightL |
|
426 // (other items were commented in a header). |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void CCAConversationsContainer::SetItemHighlightL( TBool aHighlight ) |
|
430 { |
|
431 iChatView->SetHighlight( aHighlight ); |
|
432 iItemHighlight = aHighlight; |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------- |
|
436 // CCAChatViewContainer::StartScrollingL() |
|
437 // This method is called when scrolling is started again |
|
438 // --------------------------------------------------------- |
|
439 // |
|
440 void CCAConversationsContainer::StartScrollingL( TBool aActivateFromTabSwitch/*=EFalse*/ ) |
|
441 { |
|
442 // disable highlight and set focus to editor |
|
443 if ( iChatView->Highlighted() ) |
|
444 { |
|
445 iChatView->DisableHighlightL(); |
|
446 } |
|
447 if ( !aActivateFromTabSwitch ) |
|
448 { |
|
449 iEditor->SetFocus( ETrue, EDrawNow ); |
|
450 iChatView->SetFocus( EFalse, EDrawNow ); |
|
451 } |
|
452 else |
|
453 { |
|
454 iEditor->SetFocus( EFalse, EDrawNow ); |
|
455 iChatView->SetFocus( ETrue, EDrawNow ); |
|
456 } |
|
457 |
|
458 iEditor->DrawDeferred(); |
|
459 UpdateCbaL(); |
|
460 } |
|
461 |
|
462 // --------------------------------------------------------- |
|
463 // CCAChatViewContainer::StopScrollingL() |
|
464 // (other items were commented in a header). |
|
465 // --------------------------------------------------------- |
|
466 // |
|
467 void CCAConversationsContainer::StopScrollingL() |
|
468 { |
|
469 // unfocus editor (highlighting is enabled |
|
470 // automatically in OfferKeyEvent of ChatView) |
|
471 iEditor->SetFocus( EFalse, EDrawNow ); |
|
472 iChatView->SetFocus( ETrue, EDrawNow ); |
|
473 iEditor->DrawDeferred(); |
|
474 // Set editor cursor pos to end of text |
|
475 iEditor->SetCursorPosL( iEditor->TextLength(), EFalse ); |
|
476 UpdateCbaL(); |
|
477 } |
|
478 |
|
479 // --------------------------------------------------------- |
|
480 // CCAChatViewContainer::UpdateCbaL() |
|
481 // --------------------------------------------------------- |
|
482 // |
|
483 void CCAConversationsContainer::UpdateCbaL() |
|
484 { |
|
485 TInt cbaRes( R_CHAT_SOFTKEYS_OPTIONS_CONTINUE__EMPTY ); |
|
486 if ( !iCba ) |
|
487 { |
|
488 return; |
|
489 } |
|
490 |
|
491 if ( !iChatView->GetMessageCount() ) |
|
492 { |
|
493 //if the message list is empty |
|
494 if ( !iEditor->IsFocused() ) |
|
495 { |
|
496 //if editor is not in focus then the rightSK must be "continue" |
|
497 iCba->SetCommandSetL( cbaRes ); |
|
498 iCba->DrawNow(); |
|
499 return; |
|
500 } |
|
501 } |
|
502 |
|
503 if ( iChatView->Highlighted() ) |
|
504 { |
|
505 // focus on chatview |
|
506 TBool ignore; |
|
507 HBufC* item = iChatView->SelectedItemL(); |
|
508 CleanupStack::PushL( item ); |
|
509 TBool dummyArgument( EFalse ); |
|
510 if ( IsObjectSelected( ignore, dummyArgument ) ) |
|
511 { |
|
512 // openable object selected |
|
513 cbaRes = R_CHAT_SOFTKEYS_OPTIONS_CONTINUE__OPEN; |
|
514 } |
|
515 else if ( item && item->Length() > 0 ) |
|
516 { |
|
517 // automatic find item selected |
|
518 cbaRes = R_CHAT_SOFTKEYS_OPTIONS_CONTINUE__CONTEXTOPTIONS; |
|
519 } |
|
520 CleanupStack::PopAndDestroy( item ); |
|
521 } |
|
522 else |
|
523 { |
|
524 // focus on editor |
|
525 cbaRes = iEditor->TextLength() > 0 ? |
|
526 R_CHAT_SOFTKEYS_OPTIONS_BACK__SEND : |
|
527 R_CHAT_SOFTKEYS_OPTIONS_BACK__EMPTY; |
|
528 } |
|
529 |
|
530 // Check that there is not "Spell" in the left button |
|
531 // ControlOrNull() is needed for 3.0 backport. |
|
532 if ( !( iCba->ControlOrNull( EAknFepSoftkeySpell ) && |
|
533 iCba->IsCommandVisible( EAknFepSoftkeySpell ) ) ) |
|
534 { |
|
535 iCba->SetCommandSetL( cbaRes ); |
|
536 iCba->DrawNow(); |
|
537 } |
|
538 } |
|
539 |
|
540 // --------------------------------------------------------- |
|
541 // CCAConversationsContainer::Editor() |
|
542 // This method returns pointer to CEikGlobalTextEditor |
|
543 // --------------------------------------------------------- |
|
544 // |
|
545 CCAMessageEditor& CCAConversationsContainer::Editor() const |
|
546 { |
|
547 return *iEditor; |
|
548 } |
|
549 |
|
550 TBool CCAConversationsContainer::Sending() const |
|
551 { |
|
552 return iSending; |
|
553 } |
|
554 |
|
555 void CCAConversationsContainer::ResetSending() |
|
556 { |
|
557 iSending = EFalse; |
|
558 } |
|
559 |
|
560 |
|
561 // --------------------------------------------------------- |
|
562 // CCAConversationsContainer::CheckBlockedL |
|
563 // --------------------------------------------------------- |
|
564 // |
|
565 void CCAConversationsContainer::CheckBlockedL() |
|
566 { |
|
567 |
|
568 MCABlockingPC* blockinInterface = iAppUi->GetProcessManager().GetBlockingInterface(); |
|
569 |
|
570 TPtrC wvid( iConversationPC->GetReadInterfaceId() ); |
|
571 |
|
572 // Check if target id is blocked |
|
573 if ( blockinInterface->IsContactBlocked( wvid, ETrue ) ) |
|
574 { |
|
575 iAppUi->ShowWaitDialogL( R_CHAT_BLOCK_REMOVING ); |
|
576 TInt errorCode = KErrNone; |
|
577 TRAPD( err, errorCode = blockinInterface->SetTemporaryGrantL( |
|
578 wvid, ETrue ) ); |
|
579 iAppUi->DismissWaitDialogL( err ); |
|
580 if ( errorCode == KErrNone ) |
|
581 { |
|
582 IMDialogUtils::DisplayNoteDialogL( R_CHATCLIENT_CNOTE_UNBLOCK ); |
|
583 } |
|
584 else |
|
585 { |
|
586 IMNoteMapper::ShowNoteL( errorCode ); |
|
587 } |
|
588 } |
|
589 } |
|
590 |
|
591 |
|
592 // --------------------------------------------------------- |
|
593 // CCAConversationsContainer::SendMessageL() |
|
594 // This method handles message sending to engine |
|
595 // --------------------------------------------------------- |
|
596 // |
|
597 void CCAConversationsContainer::SendMessageL() |
|
598 { |
|
599 if ( iAppUi->UISessionManager().IsLoggedIn() ) |
|
600 { |
|
601 TInt textLength( iEditor->TextLength() ); |
|
602 if ( textLength == 0 ) |
|
603 { |
|
604 return; |
|
605 } |
|
606 |
|
607 // Check status, and change status to "online" if it's "away" |
|
608 MCAPresence::TPresenceStatus curStatus = |
|
609 CAPresenceManager::InstanceL()->StatusL(); |
|
610 |
|
611 TBool statusChangeNeeded = |
|
612 ( curStatus == MCAPresence::EAway || |
|
613 curStatus == MCAPresence::EBusy ); |
|
614 |
|
615 if ( statusChangeNeeded && |
|
616 IMUtils::IntResourceValueL( |
|
617 RSC_CHAT_VARIATION_AUTOMATIC_STATUS_CHANGE ) ) |
|
618 { |
|
619 CCAWaitNote* note = CCAWaitNote::ShowWaitNoteLC( |
|
620 R_QTN_CHAT_CHANGE_STATUS_CHANGING ); |
|
621 |
|
622 TInt error = CAPresenceManager::InstanceL()->ChangeStatusL( |
|
623 MCAPresence::EOnline, KNullDesC ); |
|
624 |
|
625 CleanupStack::PopAndDestroy(); // waitnote |
|
626 |
|
627 if ( error == KErrNone ) |
|
628 { |
|
629 // Change status pane icon |
|
630 iAppUi->UISessionManager().SetStatusPaneIconsL(); |
|
631 // show information note |
|
632 IMDialogUtils::DisplayInformationNoteL( |
|
633 R_CHAT_STATUS_CHANGED_AUTOMATIC ); |
|
634 } |
|
635 else |
|
636 { |
|
637 // change status failed |
|
638 IMDialogUtils::DisplayErrorNoteL( |
|
639 R_QTN_CHAT_CHANGE_STATUS_FAILED ); |
|
640 } |
|
641 } |
|
642 |
|
643 CheckReplyL(); |
|
644 |
|
645 HBufC* msgBuf = iMessageExtensionsHandler.ProcessMessageLC( *iEditor ); |
|
646 TPtr msgPtr( msgBuf->Des() ); |
|
647 |
|
648 // Check message if there is other than empty chars |
|
649 TInt len( msgPtr.Length() ); |
|
650 TBool contaisOnlyEmptyChars( ETrue ); |
|
651 |
|
652 for ( TInt i( 0 ); ( i < len ) && contaisOnlyEmptyChars; ++i ) |
|
653 { |
|
654 TPtrC c = msgPtr.Mid( i, 1 ); // next character |
|
655 TInt position = ( KEmptyCharacters() ).FindC( c ); |
|
656 |
|
657 if ( position == KErrNotFound ) |
|
658 { |
|
659 // c not found from empty characters --> c is not empty char |
|
660 contaisOnlyEmptyChars = EFalse; |
|
661 } |
|
662 } |
|
663 |
|
664 if ( contaisOnlyEmptyChars ) |
|
665 { |
|
666 // message contains only empty character |
|
667 // don't send message and setting focus back to editor window |
|
668 iEditor->SetFocus( ETrue ); |
|
669 iChatView->SetFocus( EFalse ); |
|
670 CleanupStack::PopAndDestroy( msgBuf ); |
|
671 return; |
|
672 } |
|
673 |
|
674 |
|
675 // Check grant list |
|
676 CheckBlockedL(); |
|
677 |
|
678 iConversationPC->SendMessageL( msgBuf->Des() ); |
|
679 |
|
680 TInt editorFlags = ( iEditor->AknEdwinFlags() | EAknEditorFlagNoEditIndicators ); |
|
681 iEditor->SetAknEditorFlags( editorFlags ); |
|
682 |
|
683 ResetAfterSendL(); |
|
684 CleanupStack::PopAndDestroy( msgBuf ); // msgBuf |
|
685 } |
|
686 else |
|
687 { |
|
688 // Not logged in |
|
689 // 1. Start login procedure |
|
690 // 2. Wait for contact list fetching to complete |
|
691 // before proceeding with sending (unless bgfetch is enabled) |
|
692 if ( !iLogingFlag ) |
|
693 { |
|
694 iLogingFlag = ETrue; |
|
695 MCALoginPC *loginPC = iAppUi->GetProcessManager().GetLogInInterface(); |
|
696 loginPC->AddObserver( this ); |
|
697 |
|
698 TBool isloggedIn = iAppUi->UISessionManager().LoginL( MCAUiLoginCmdCB::EQueryLogin ); |
|
699 |
|
700 if ( isloggedIn ) |
|
701 { |
|
702 iWvId.Copy( iConversationPC->GetReadInterfaceId().Left( |
|
703 iWvId.MaxLength() ) ); |
|
704 iSending = ETrue; // set the sending flag, so we don't get deleted |
|
705 // Login |
|
706 } |
|
707 else |
|
708 { // Login failed, return |
|
709 ResetSending(); |
|
710 loginPC->RemoveObserver(); |
|
711 } |
|
712 iLogingFlag = EFalse; |
|
713 } |
|
714 } |
|
715 } |
|
716 |
|
717 // --------------------------------------------------------- |
|
718 // CCAConversationsContainer::AddToFriendsL() |
|
719 // Adds to friend |
|
720 // (other items were commented in a header). |
|
721 // --------------------------------------------------------- |
|
722 // |
|
723 void CCAConversationsContainer::AddToFriendsL() |
|
724 { |
|
725 |
|
726 CCAStatusPaneHandler& statusPane = *iViewSwitcher.CAStatusPane(); |
|
727 |
|
728 HBufC* titleText = statusPane.Title()->AllocLC(); |
|
729 |
|
730 // creating a new contact |
|
731 TBool contactSaved( EFalse ); |
|
732 |
|
733 CCAContactEditor* contactEditor = |
|
734 CCAContactEditor::NewL( -1, contactSaved ); |
|
735 TPtrC wvid( iConversationPC->GetReadInterfaceId() ); |
|
736 |
|
737 contactEditor->EditContactLD( TEnumsPC::EAddToContact, KNullDesC, wvid, KNullDesC ); |
|
738 |
|
739 statusPane.SetTitleL( *titleText ); |
|
740 CleanupStack::PopAndDestroy( titleText ); |
|
741 |
|
742 iTitleUpdater.UpdateTitleL(); |
|
743 |
|
744 statusPane.RestoreNaviPane(); |
|
745 |
|
746 } |
|
747 |
|
748 |
|
749 // --------------------------------------------------------- |
|
750 // CCAConversationsContainer::BlockUserL() |
|
751 // --------------------------------------------------------- |
|
752 // |
|
753 void CCAConversationsContainer::BlockUserL() |
|
754 { |
|
755 TPtrC wvid( iConversationPC->GetReadInterfaceId() ); |
|
756 |
|
757 iBlockingUI->BlockUserL( wvid ); |
|
758 } |
|
759 |
|
760 // --------------------------------------------------------- |
|
761 // CCAConversationsContainer::IsBlocked() |
|
762 // (other items were commented in a header). |
|
763 // --------------------------------------------------------- |
|
764 // |
|
765 TBool CCAConversationsContainer::IsBlocked() const |
|
766 { |
|
767 TPtrC wvid( iConversationPC->GetReadInterfaceId() ); |
|
768 return iAppUi->GetProcessManager().GetBlockingInterface()->IsContactBlocked( wvid ); |
|
769 } |
|
770 |
|
771 // --------------------------------------------------------- |
|
772 // CCAConversationsContainer::BlockUserWVIdL() |
|
773 // --------------------------------------------------------- |
|
774 void CCAConversationsContainer::BlockUserWVIdL() |
|
775 { |
|
776 iBlockingUI->DisplayBlockTextQueryL(); |
|
777 } |
|
778 // --------------------------------------------------------- |
|
779 // CCAConversationsContainer::UnBlockL() |
|
780 // --------------------------------------------------------- |
|
781 void CCAConversationsContainer::UnBlockL() |
|
782 { |
|
783 iBlockingUI->DisplayUnblockListQueryL(); |
|
784 } |
|
785 // --------------------------------------------------------- |
|
786 // CCAConversationsContainer::DisplayBlockedListL() |
|
787 // --------------------------------------------------------- |
|
788 // |
|
789 void CCAConversationsContainer::DisplayBlockedListL() |
|
790 { |
|
791 iBlockingUI->DisplayBlockedListL(); |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------- |
|
795 // CCAConversationsContainer::ApplicationUserSentThis() |
|
796 // (other items were commented in a header). |
|
797 // --------------------------------------------------------- |
|
798 // |
|
799 TBool CCAConversationsContainer::ApplicationUserSentThis() const |
|
800 { |
|
801 TBool ret( EFalse ); |
|
802 MCAConversationMessage* message = iChatView->SelectedMessage(); |
|
803 if ( message ) |
|
804 { |
|
805 ret = ( message->MessagerType() == TEnumsPC::EMessageSent ); |
|
806 } |
|
807 return ret; |
|
808 } |
|
809 |
|
810 // --------------------------------------------------------- |
|
811 // CCAChatViewContainer::SetLoggingOnL() |
|
812 // (other items were commented in a header). |
|
813 // --------------------------------------------------------- |
|
814 // |
|
815 void CCAConversationsContainer::RecordChatL() |
|
816 { |
|
817 TBool isMemorySelected = ETrue; |
|
818 #ifdef RD_MULTIPLE_DRIVE // show note |
|
819 isMemorySelected = ShowMemorySelectionDialogL(); |
|
820 #endif |
|
821 // if the location has not been set, don't do record |
|
822 if ( !isMemorySelected ) |
|
823 { |
|
824 return; |
|
825 } |
|
826 |
|
827 HBufC* logFileName = HBufC::NewLC( KMaxLogFileName ); |
|
828 TPtr logFileNamePtr( logFileName->Des() ); |
|
829 |
|
830 iConversationPC->GetLogFileName( logFileNamePtr ) ; |
|
831 |
|
832 TInt result( IMDialogUtils::DisplayTextQueryDialogL( logFileNamePtr, |
|
833 RSC_CHATNG_LOGDIALOG_PROMPT, R_CHATCLIENT_LOG_NAME_QUERY, |
|
834 ETrue // T9 |
|
835 ) ); |
|
836 |
|
837 if ( result == EAknSoftkeyOk || result == EAknSoftkeyDone ) |
|
838 { |
|
839 //CR ID : 10139730 Show warning when saving a chat |
|
840 ShowRecordSavingWarningL() ; |
|
841 #ifdef RD_MULTIPLE_DRIVE // show note |
|
842 TInt error = KErrNone; |
|
843 TRAP( error , iConversationPC->RecordChatL( *logFileName ) ); |
|
844 |
|
845 if ( error != KErrNotSaved && error != KErrDiskFull ) |
|
846 #else |
|
847 iConversationPC->RecordChatL( *logFileName ); |
|
848 #endif |
|
849 { |
|
850 IMDialogUtils::DisplayConfirmationNoteL( R_QTN_CHAT_SAVING_SAVED ); |
|
851 } |
|
852 #ifdef RD_MULTIPLE_DRIVE |
|
853 else if ( error == KErrDiskFull ) |
|
854 { |
|
855 TBuf< KMaxPath > defaultDrive; |
|
856 |
|
857 CRepository* cenrep = CRepository::NewL( KWVSettingsCenRepUid ); |
|
858 |
|
859 TInt err = cenrep->Get( KIMPSCRIMDefaultMemoryDrive, defaultDrive ); |
|
860 |
|
861 delete cenrep; |
|
862 cenrep = NULL; |
|
863 |
|
864 if ( err != KErrNone ) |
|
865 { |
|
866 User::Leave( err ); |
|
867 } |
|
868 TInt driveNo = 0; |
|
869 err = RFs::CharToDrive( defaultDrive[0], driveNo ); |
|
870 if ( err != KErrNone ) |
|
871 { |
|
872 User::Leave( err ); |
|
873 } |
|
874 TDriveNumber driveNumber = TDriveNumber( driveNo ); |
|
875 |
|
876 RFs& fs = CCoeEnv::Static()->FsSession(); |
|
877 |
|
878 TDriveInfo driveInfo; |
|
879 err = fs.Drive( driveInfo, driveNumber ); |
|
880 if ( err != KErrNone ) |
|
881 { |
|
882 User::Leave( err ); |
|
883 } |
|
884 if ( driveInfo.iDriveAtt & KDriveAttRemovable ) |
|
885 { |
|
886 HBufC* prompt = iEikonEnv->AllocReadResourceLC( R_CHAT_MEMLO_MMC_NOT_ENOUGH_MEMORY ); |
|
887 IMDialogUtils::DisplayErrorNoteL( *prompt, ETrue ); |
|
888 CleanupStack::PopAndDestroy( prompt ); |
|
889 } |
|
890 else |
|
891 { |
|
892 HBufC* prompt = iEikonEnv->AllocReadResourceLC( R_CHAT_MEMLO_NOT_ENOUGH_MEMORY ); |
|
893 IMDialogUtils::DisplayErrorNoteL( *prompt, ETrue ); |
|
894 CleanupStack::PopAndDestroy( prompt ); |
|
895 } |
|
896 |
|
897 } |
|
898 #endif |
|
899 } |
|
900 CleanupStack::PopAndDestroy( logFileName ); |
|
901 } |
|
902 |
|
903 |
|
904 |
|
905 // --------------------------------------------------------- |
|
906 // CCAConversationsContainer::ExtensionFits() |
|
907 // (other items were commented in a header). |
|
908 // --------------------------------------------------------- |
|
909 // |
|
910 TBool CCAConversationsContainer::ExtensionFits( TInt aLength ) |
|
911 { |
|
912 TBool retVal( ETrue ); |
|
913 if ( iEditor->MaxLength() - iEditor->TextLength() < aLength ) |
|
914 { |
|
915 retVal = EFalse; |
|
916 } |
|
917 return retVal; |
|
918 } |
|
919 |
|
920 // --------------------------------------------------------- |
|
921 // CCAConversationsContainer::ResetAfterSendL() |
|
922 // Resets arrays, lines and nick length after send |
|
923 // (other items were commented in a header). |
|
924 // --------------------------------------------------------- |
|
925 // |
|
926 void CCAConversationsContainer::ResetAfterSendL( TBool aActivateFromTabSwitch/*=EFalse*/ ) |
|
927 { |
|
928 iEditor->ResetL(); |
|
929 iEditor->SetTextLimit( IMUtils::MaxMsgLength() ); |
|
930 iEditor->SetAknEditorCurrentCase( EAknEditorTextCase ); |
|
931 StartScrollingL( aActivateFromTabSwitch ); // Call to update CBA |
|
932 } |
|
933 |
|
934 // --------------------------------------------------------- |
|
935 // CCAConversationsContainer::DisplayInfoNoteL() |
|
936 // Displays info note for corresponding resource id |
|
937 // (other items were commented in a header). |
|
938 // --------------------------------------------------------- |
|
939 // |
|
940 void CCAConversationsContainer::DisplayInfoNoteL( const TInt aResourceId ) |
|
941 { |
|
942 CAknNoteDialog* infoNote = new ( ELeave ) CAknNoteDialog( CAknNoteDialog:: |
|
943 EConfirmationTone, CAknNoteDialog::EShortTimeout ); |
|
944 |
|
945 infoNote->ExecuteLD( aResourceId ); |
|
946 } |
|
947 |
|
948 |
|
949 // --------------------------------------------------------- |
|
950 // CCAConversationsContainer::LayoutChangedL |
|
951 // (other items were commented in a header). |
|
952 // --------------------------------------------------------- |
|
953 // |
|
954 void CCAConversationsContainer::LayoutChangedL( TInt aType ) |
|
955 { |
|
956 LoadBitmapsL(); |
|
957 TRect mainPaneRect; |
|
958 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
959 SetRect( mainPaneRect ); |
|
960 |
|
961 // Update skin context of editor |
|
962 if ( iEditor ) |
|
963 { |
|
964 iEditor->SetupSkinContextL( ETrue ); |
|
965 } |
|
966 |
|
967 CCoeControl::HandleResourceChange( aType ); |
|
968 } |
|
969 |
|
970 |
|
971 // --------------------------------------------------------- |
|
972 // CCAConversationsContainer::HandleEdwinSizeEventL( CEikEdwin* aEdwin, |
|
973 // TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize ) |
|
974 // This method is called when editor is extended to two lines |
|
975 // --------------------------------------------------------- |
|
976 // |
|
977 TBool CCAConversationsContainer::HandleEdwinSizeEventL( CEikEdwin* /*aEdwin*/, |
|
978 TEdwinSizeEvent aEventType, TSize /*aDesirableEdwinSize*/ ) |
|
979 { |
|
980 if ( aEventType == EEventSizeChanging ) |
|
981 { |
|
982 SizeChanged(); |
|
983 |
|
984 DrawNow(); |
|
985 return ETrue; |
|
986 } |
|
987 return EFalse; |
|
988 } |
|
989 |
|
990 // --------------------------------------------------------- |
|
991 // CCAConversationsContainer::HandleTapEventL() |
|
992 // (other items were commented in a header). |
|
993 // --------------------------------------------------------- |
|
994 // |
|
995 void CCAConversationsContainer::HandleTapEventL( TTapEvent aEvent, |
|
996 TUint aControlId ) |
|
997 { |
|
998 // Handle the tap events which occur in our child controls: |
|
999 // Message list and Message editor. |
|
1000 switch ( aControlId ) |
|
1001 { |
|
1002 case EMessageList: |
|
1003 { |
|
1004 // Focused message was double tapped |
|
1005 if ( aEvent == MCATapEventObserver::EDoubleTap ) |
|
1006 { |
|
1007 // Activate tapped item |
|
1008 TBool ignore; |
|
1009 TBool dummyArgument; |
|
1010 if ( IsObjectSelected( ignore , dummyArgument ) ) |
|
1011 { |
|
1012 iAppUi->ProcessCommandL( EChatClientOpenObject ); |
|
1013 } |
|
1014 |
|
1015 } |
|
1016 // Message or item was tapped |
|
1017 else if ( aEvent == MCATapEventObserver::ESingleTap ) |
|
1018 { |
|
1019 // Find objects activate with single tap |
|
1020 iRecipientObserver.ShowPopUpMenuL(); |
|
1021 } |
|
1022 break; |
|
1023 } |
|
1024 case EMessageEditor: |
|
1025 { |
|
1026 // Nothing to do here ATM. |
|
1027 // Focus transition is handled in HandleControlEventL |
|
1028 break; |
|
1029 } |
|
1030 default: |
|
1031 { |
|
1032 // There is an unhandled object or the object returned wrong |
|
1033 // controlId. Check the implementation |
|
1034 __CHAT_ASSERT_DEBUG( EFalse ); |
|
1035 break; |
|
1036 } |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 // --------------------------------------------------------- |
|
1041 // CCAConversationsContainer::HandleControlEventL |
|
1042 // --------------------------------------------------------- |
|
1043 // |
|
1044 void CCAConversationsContainer::HandleControlEventL( CCoeControl* aControl, |
|
1045 TCoeEvent aEventType ) |
|
1046 { |
|
1047 if ( EEventRequestFocus == aEventType ) |
|
1048 { |
|
1049 if ( aControl == ( CCoeControl* )iEditor ) |
|
1050 { |
|
1051 // Focus to editor |
|
1052 StartScrollingL(); |
|
1053 iAppUi->SetFocusFlag( ETrue ); |
|
1054 } |
|
1055 else // aControl == iChatView |
|
1056 { |
|
1057 // Focus to messagelist |
|
1058 StopScrollingL(); |
|
1059 iAppUi->SetFocusFlag( EFalse ); |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 if ( CATouchUtils::PenEnabled() ) |
|
1064 { |
|
1065 |
|
1066 if ( EEventStateChanged == aEventType ) |
|
1067 { |
|
1068 if ( aControl == ( CCoeControl* )iEditor ) |
|
1069 { |
|
1070 // Update MSK - When using virtual keyboard |
|
1071 // on touch enabled devices, one is bound to receive |
|
1072 // EEventStateChanged. Hence handle the same |
|
1073 UpdateCbaL(); |
|
1074 } |
|
1075 } |
|
1076 |
|
1077 } |
|
1078 |
|
1079 } |
|
1080 |
|
1081 // --------------------------------------------------------- |
|
1082 // CCAConversationsContainer::SizeChanged() |
|
1083 // Called by framework when the view size is changed |
|
1084 // --------------------------------------------------------- |
|
1085 // |
|
1086 void CCAConversationsContainer::SizeChanged() |
|
1087 { |
|
1088 TInt lines( iEditor->NumberOfLines() ); |
|
1089 |
|
1090 if ( lines > 2 ) // ignore events for more than 2 lines |
|
1091 { |
|
1092 lines = 2; |
|
1093 } |
|
1094 lines--; // convert to index |
|
1095 |
|
1096 TAknLayoutRect rp; |
|
1097 if ( lines == 1 ) |
|
1098 { |
|
1099 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( |
|
1100 TChatListBoxLayout::EWithEditor2Lines ) ); |
|
1101 } |
|
1102 else |
|
1103 { |
|
1104 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( |
|
1105 TChatListBoxLayout::EWithEditor ) ); |
|
1106 } |
|
1107 |
|
1108 // Set icon sizes, do this before setting the rect for |
|
1109 // chat view to prevent icon sizes from changing after chat |
|
1110 // view rect is set. |
|
1111 ResizeIcons( TextRect() ); |
|
1112 |
|
1113 // set rect for chat view |
|
1114 iChatView->SetRect( rp.Rect() ); |
|
1115 |
|
1116 // and editor |
|
1117 TAknLayoutRect wpl; |
|
1118 wpl.LayoutRect( Rect(), AknLayoutScalable_Apps::im_writing_pane( 1 - lines ) ); |
|
1119 |
|
1120 TAknWindowLineLayout myWPLayout( AknLayoutScalable_Apps::im_writing_pane( 1 - lines ) ); |
|
1121 |
|
1122 iOutLine.LayoutRect( iAppUi->LayoutInfo()->MainPaneRect(), myWPLayout ); |
|
1123 |
|
1124 iVertLine.LayoutRect( wpl.Rect(), |
|
1125 iAppUi->LayoutInfo()->IM_writing_field_elements_Line_1( lines ) ); |
|
1126 |
|
1127 iHoriline.LayoutRect( wpl.Rect(), |
|
1128 iAppUi->LayoutInfo()->IM_writing_field_elements_Line_2() ); |
|
1129 |
|
1130 TAknMultiLineTextLayout mlwpt = |
|
1131 iAppUi->LayoutInfo()->Multiline_IM_writing_pane_texts_Line_1( lines + 1 ); |
|
1132 |
|
1133 AknLayoutUtils::LayoutEdwin( iEditor, wpl.Rect(), mlwpt, EAknsCIQsnTextColorsCG25 ); |
|
1134 |
|
1135 FocusChanged( EDrawNow ); |
|
1136 |
|
1137 DrawNow(); |
|
1138 } |
|
1139 |
|
1140 // --------------------------------------------------------- |
|
1141 // CCAConversationsContainer::CountComponentControls() const |
|
1142 // --------------------------------------------------------- |
|
1143 // |
|
1144 TInt CCAConversationsContainer::CountComponentControls() const |
|
1145 { |
|
1146 // We have 2 controls |
|
1147 return 2; |
|
1148 } |
|
1149 |
|
1150 // --------------------------------------------------------- |
|
1151 // CCAChatViewContainer::ComponentControl(TInt aIndex) const |
|
1152 // --------------------------------------------------------- |
|
1153 // |
|
1154 CCoeControl* CCAConversationsContainer::ComponentControl( TInt aIndex ) const |
|
1155 { |
|
1156 //returns control with aIndex |
|
1157 switch ( aIndex ) |
|
1158 { |
|
1159 case 0: |
|
1160 { |
|
1161 return iChatView; |
|
1162 } |
|
1163 case 1: |
|
1164 { |
|
1165 return iEditor; |
|
1166 } |
|
1167 default: |
|
1168 { |
|
1169 return NULL; |
|
1170 } |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 // --------------------------------------------------------- |
|
1175 // CCAConversationsContainer::Draw(const TRect& aRect) const |
|
1176 // --------------------------------------------------------- |
|
1177 // |
|
1178 void CCAConversationsContainer::Draw( const TRect& aRect ) const |
|
1179 { |
|
1180 CWindowGc& gc = SystemGc(); |
|
1181 |
|
1182 // Draw skinned background |
|
1183 iSkinVar->ClearChatListBoxBackGround( |
|
1184 gc, aRect, |
|
1185 iSkinVar->MainPaneBackgroundContext() ); |
|
1186 |
|
1187 TRect editorRect( iEditor->Rect() ); |
|
1188 TRect outlineRect( iOutLine.Rect() ); |
|
1189 TRect parent( Rect() ); |
|
1190 |
|
1191 TBool skinnedDraw = iSkinVar->DrawSkinnedEditor( |
|
1192 this, gc, parent, editorRect, outlineRect ); |
|
1193 |
|
1194 if ( ! skinnedDraw ) |
|
1195 { |
|
1196 DrawUtils::ClearBetweenRects( gc, Rect(), iEditor->Rect() ); |
|
1197 |
|
1198 iOutLine.DrawOutLineRect( gc ); |
|
1199 iHoriline.DrawRect( gc ); |
|
1200 iVertLine.DrawRect( gc ); |
|
1201 } |
|
1202 |
|
1203 } |
|
1204 |
|
1205 // --------------------------------------------------------- |
|
1206 // CCAConversationsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
1207 // TEventCode aType ) |
|
1208 // Handles keyevents |
|
1209 // --------------------------------------------------------- |
|
1210 // |
|
1211 TKeyResponse CCAConversationsContainer::OfferKeyEventL( |
|
1212 const TKeyEvent& aKeyEvent, |
|
1213 TEventCode aType ) |
|
1214 { |
|
1215 CHAT_DP( D_CHAT_LIT( "CCAConversationsContainer::OfferKeyEventL key %d" ), |
|
1216 aKeyEvent.iCode ); |
|
1217 |
|
1218 if ( aKeyEvent.iScanCode == EStdKeyYes && aType != EEventKey ) |
|
1219 { |
|
1220 return EKeyWasConsumed; |
|
1221 } |
|
1222 |
|
1223 if ( ( IsStopped() || !iEditor->IsFocused() ) ) |
|
1224 { |
|
1225 if ( aKeyEvent.iScanCode >= '0' && aKeyEvent.iScanCode <= '9' ) |
|
1226 { |
|
1227 // stop the automatic scrolling and start manual |
|
1228 // if user presses any of the number keys (0-9) |
|
1229 StartScrollingL(); |
|
1230 // Key event gets passed to editor after this |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 if ( aType == EEventKeyDown ) |
|
1235 { |
|
1236 if ( ( aKeyEvent.iScanCode == KHashKey ) && |
|
1237 ( iEditor->TextLength() == 0 ) ) |
|
1238 { |
|
1239 |
|
1240 if ( !iEditIndicator->IsIndicatorActive() ) |
|
1241 { |
|
1242 iEditIndicator->StartTimer(); |
|
1243 } |
|
1244 |
|
1245 } |
|
1246 } |
|
1247 switch ( aKeyEvent.iCode ) |
|
1248 { |
|
1249 // flowthrough |
|
1250 case EKeyEnter: |
|
1251 case EKeyOK: |
|
1252 case EKeyPhoneSend: |
|
1253 { |
|
1254 if ( iEditor->IsFocused() ) |
|
1255 { |
|
1256 // trapping error so that focus can be returned to editor |
|
1257 TRAPD( err, SendMessageL() ); |
|
1258 if ( err ) |
|
1259 { |
|
1260 CActiveScheduler::Current()->Error( err ); |
|
1261 } |
|
1262 iEditor->SetFocus( ETrue ); |
|
1263 iChatView->SetFocus( EFalse ); |
|
1264 } |
|
1265 else if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyOK |
|
1266 && iChatView->Highlighted() ) |
|
1267 { |
|
1268 TBool ignore; |
|
1269 TBool dummyArgument; |
|
1270 if ( IsObjectSelected( ignore , dummyArgument ) ) |
|
1271 { |
|
1272 iAppUi->ProcessCommandL( EChatClientOpenObject ); |
|
1273 } |
|
1274 else |
|
1275 { |
|
1276 iRecipientObserver.ShowPopUpMenuL(); |
|
1277 } |
|
1278 } |
|
1279 else if ( iSendkeyInMsgList ) |
|
1280 { |
|
1281 if ( aKeyEvent.iCode == EKeyPhoneSend |
|
1282 && iChatView->Highlighted() |
|
1283 && iChatView->SelectedItemType() |
|
1284 == CFindItemEngine::EFindItemSearchPhoneNumberBin ) |
|
1285 { |
|
1286 // Phone number highlighted, send key pressed -> call |
|
1287 iAppUi->ProcessCommandL( EChatClientCall ); |
|
1288 } |
|
1289 } |
|
1290 return EKeyWasConsumed; |
|
1291 } |
|
1292 |
|
1293 case EKeyBackspace: |
|
1294 { |
|
1295 // if bitmap is selected, it is deleted "normally" in |
|
1296 // iEditor's OfferKeyEvent |
|
1297 if ( iEditor->SelectionLength() > 0 ) |
|
1298 { |
|
1299 break; |
|
1300 } |
|
1301 |
|
1302 TInt cursorPos( iEditor->CursorPos() ); |
|
1303 if ( cursorPos > 0 ) // at least one char in editor |
|
1304 { |
|
1305 TPtrC ptr = iEditor->RichText()->Read( ( cursorPos - 1 ), 1 ); |
|
1306 // if a char to be "backspaced" is a picture |
|
1307 if ( ptr[ 0 ] == CEditableText::EPictureCharacter ) |
|
1308 { |
|
1309 iMessageExtensionsHandler.DeleteExtensionL( *iEditor, |
|
1310 EMessageExtensionSmiley, cursorPos - 1 ); |
|
1311 return EKeyWasConsumed; |
|
1312 } |
|
1313 } |
|
1314 |
|
1315 if ( cursorPos < 2 ) |
|
1316 { |
|
1317 cursorPos = 2; |
|
1318 } |
|
1319 |
|
1320 CHAT_DP( D_CHAT_LIT( "CursorPos(): %d" ), cursorPos ); |
|
1321 break; |
|
1322 } |
|
1323 |
|
1324 // flowthrough |
|
1325 case EKeyLeftArrow: |
|
1326 case EKeyRightArrow: |
|
1327 { |
|
1328 if ( !iEditor->IsFocused() ) |
|
1329 { |
|
1330 //return EKeyWasConsumed; |
|
1331 TKeyResponse res = iAppUi->OfferTabEventL( aKeyEvent, aType ); |
|
1332 if ( ifocusFlag ) |
|
1333 { |
|
1334 StartScrollingL(); |
|
1335 ifocusFlag = EFalse; |
|
1336 } |
|
1337 else |
|
1338 { |
|
1339 iAppUi->SetFocusFlag( EFalse ); |
|
1340 } |
|
1341 return res; |
|
1342 } |
|
1343 break; |
|
1344 } |
|
1345 |
|
1346 case EKeyDownArrow: // flowthrough |
|
1347 case EKeyUpArrow: |
|
1348 { |
|
1349 if ( iEditor->IsFocused() ) |
|
1350 { |
|
1351 // editor is focused, try to offer the key |
|
1352 if ( iEditor->OfferKeyEventL( aKeyEvent, aType ) |
|
1353 == EKeyWasConsumed ) |
|
1354 { |
|
1355 // editor took it |
|
1356 return EKeyWasConsumed; |
|
1357 } |
|
1358 } |
|
1359 TInt inputLang = iAvkonEnv->SettingCache().InputLanguage(); // when the editor is empty and language has candidate pane |
|
1360 if ( !iChatView->GetMessageCount() && ( ( inputLang == ELangPrcChinese )// focus should move to messagelistpane, helps in tab swithching. |
|
1361 || ( inputLang == ELangHongKongChinese ) |
|
1362 || ( inputLang == ELangTaiwanChinese ) |
|
1363 || ( inputLang == ELangJapanese ) ) ) |
|
1364 { |
|
1365 //when message list is empty |
|
1366 if ( iEditor->IsFocused() ) |
|
1367 { |
|
1368 //if editor in focus, then remove the focus from |
|
1369 // editor and move the focus to message list |
|
1370 StopScrollingL(); |
|
1371 iAppUi->SetFocusFlag( EFalse ); |
|
1372 } |
|
1373 else |
|
1374 { |
|
1375 //if editor not in focus, then remove the focus from |
|
1376 //msg list and move the focus to editor |
|
1377 StartScrollingL(); |
|
1378 iAppUi->SetFocusFlag( ETrue ); |
|
1379 } |
|
1380 |
|
1381 |
|
1382 return EKeyWasConsumed; |
|
1383 } |
|
1384 // offer the key to our chat control |
|
1385 TKeyResponse res = static_cast<CCoeControl*>( iChatView ) |
|
1386 ->OfferKeyEventL( aKeyEvent, aType ); |
|
1387 |
|
1388 if ( iChatView->Highlighted() ) |
|
1389 { |
|
1390 // change the cba |
|
1391 StopScrollingL(); |
|
1392 iAppUi->SetFocusFlag( EFalse ); |
|
1393 } |
|
1394 else |
|
1395 { |
|
1396 // change the cba |
|
1397 StartScrollingL(); |
|
1398 iAppUi->SetFocusFlag( ETrue ); |
|
1399 } |
|
1400 return res; |
|
1401 } |
|
1402 |
|
1403 default: |
|
1404 { |
|
1405 break; |
|
1406 } |
|
1407 } |
|
1408 |
|
1409 |
|
1410 if ( iEditor->IsFocused() ) |
|
1411 { |
|
1412 TKeyResponse res = iEditor->OfferKeyEventL( aKeyEvent, aType ); |
|
1413 |
|
1414 // Update CBA only when there is not a shift held down |
|
1415 if ( !( aKeyEvent.iModifiers & EModifierShift ) ) |
|
1416 { |
|
1417 UpdateCbaL(); |
|
1418 } |
|
1419 TInt inputLang = iAvkonEnv->SettingCache().InputLanguage(); // when the language has candidate |
|
1420 if ( ( inputLang != ELangPrcChinese ) && ( inputLang != ELangHongKongChinese )//pane then switching between tabs shouldnot |
|
1421 && ( inputLang != ELangTaiwanChinese ) && ( inputLang != ELangJapanese ) ) // happen,when editor is empty. |
|
1422 { |
|
1423 |
|
1424 if ( res == EKeyWasNotConsumed && iEditor->TextLength() == 0 |
|
1425 && aType == EEventKeyDown |
|
1426 && ( aKeyEvent.iScanCode == EStdKeyLeftArrow |
|
1427 || aKeyEvent.iScanCode == EStdKeyRightArrow ) |
|
1428 ) |
|
1429 { |
|
1430 StopScrollingL(); |
|
1431 ifocusFlag = ETrue; |
|
1432 iAppUi->SetFocusFlag( ETrue ); |
|
1433 } |
|
1434 } |
|
1435 return res; |
|
1436 } |
|
1437 |
|
1438 return EKeyWasNotConsumed; |
|
1439 } |
|
1440 |
|
1441 // --------------------------------------------------------- |
|
1442 // CCAConversationsContainer::GetHelpContext |
|
1443 // This function is called when Help application is launched |
|
1444 // (other items were commented in a header). |
|
1445 // --------------------------------------------------------- |
|
1446 // |
|
1447 void CCAConversationsContainer::GetHelpContext( |
|
1448 TCoeHelpContext& aContext ) const |
|
1449 { |
|
1450 aContext.iMajor = KUidChatClient; |
|
1451 aContext.iContext = KIMNG_HLP_CONVERSATIONS ; |
|
1452 } |
|
1453 |
|
1454 // --------------------------------------------------------- |
|
1455 // CCAConversationsContainer::FocusChanged |
|
1456 // This function is called when focus has been changed |
|
1457 // (other items were commented in a header). |
|
1458 // --------------------------------------------------------- |
|
1459 // |
|
1460 void CCAConversationsContainer::FocusChanged(TDrawNow aDrawNow) |
|
1461 { |
|
1462 if ( iEditor && iAppUi->FocusFlag() ) |
|
1463 { |
|
1464 iEditor->SetFocus( IsFocused() ); |
|
1465 } |
|
1466 |
|
1467 CCoeControl::FocusChanged( aDrawNow ); |
|
1468 } |
|
1469 |
|
1470 // logic: |
|
1471 // 1. no groups/groups not supported --> hide "to group" |
|
1472 // 2. no contacts --> hide "to contact" |
|
1473 // 3. 1 and 2 --> hide forward menu completely |
|
1474 // 4. contacts, but no online contacts, show All contacts are Offline |
|
1475 // 5. skip always the current contact we're conversing with |
|
1476 |
|
1477 // --------------------------------------------------------- |
|
1478 // CCAConversationsContainer::FwdContactVisible |
|
1479 // --------------------------------------------------------- |
|
1480 // |
|
1481 TBool CCAConversationsContainer::FwdContactVisible() |
|
1482 { |
|
1483 // contacts |
|
1484 TInt numContacts( iConversationPC->ContactCount() ); |
|
1485 TBool showFwdToContact = numContacts > 0; |
|
1486 |
|
1487 // but check if the only contact is OTHER than the contact |
|
1488 // we are having a conversation with |
|
1489 if ( numContacts == 1 ) |
|
1490 { |
|
1491 TPtrC wvid( iConversationPC->GetReadInterfaceId() ); |
|
1492 if ( iConversationPC->FindAnyContact( wvid ) ) |
|
1493 { |
|
1494 // found it, skip the current contact |
|
1495 // in list hiding logic |
|
1496 showFwdToContact = numContacts == 1 ? EFalse : ETrue; |
|
1497 } |
|
1498 } |
|
1499 |
|
1500 CHAT_DP( D_CHAT_LIT( "CCAConversationsContainer::FwdContactVisible\ |
|
1501 - contacts %d, show %d" ), |
|
1502 numContacts, showFwdToContact ); |
|
1503 |
|
1504 return showFwdToContact; |
|
1505 } |
|
1506 |
|
1507 // --------------------------------------------------------- |
|
1508 // CCAConversationsContainer::FwdGroupVisible |
|
1509 // --------------------------------------------------------- |
|
1510 // |
|
1511 TBool CCAConversationsContainer::FwdGroupVisible() |
|
1512 { |
|
1513 // groups |
|
1514 TBool groupsSupported = iAppUi->UISessionManager().IsSupported( |
|
1515 CCAUISessionManager::EGroup ); |
|
1516 TInt numGroups( 0 ); |
|
1517 |
|
1518 numGroups = iConversationPC->GroupCount( ETrue ) ; |
|
1519 |
|
1520 // we have to have groups supported and visible to show the forward-menu |
|
1521 TBool showFwdToGroup = groupsSupported && ( numGroups > 0 ); |
|
1522 |
|
1523 CHAT_DP( D_CHAT_LIT( "CCAConversationsContainer::\ |
|
1524 FwdGroupVisible - fwd show group: %d" ), |
|
1525 ( TInt ) showFwdToGroup ); |
|
1526 |
|
1527 return showFwdToGroup; |
|
1528 } |
|
1529 |
|
1530 |
|
1531 |
|
1532 // --------------------------------------------------------- |
|
1533 // CCAConversationsContainer::CheckReplyL |
|
1534 // --------------------------------------------------------- |
|
1535 // |
|
1536 void CCAConversationsContainer::CheckReplyL() |
|
1537 { |
|
1538 |
|
1539 TPtrC wvid; |
|
1540 TBool contactInlist = ETrue; |
|
1541 |
|
1542 iConversationPC->CheckReply( wvid, contactInlist ); |
|
1543 if ( !contactInlist ) |
|
1544 { |
|
1545 //To Remove wv and domain part from "WV User Id" |
|
1546 //if RSC_CHAT_VARIATION_HIDE_WV flag is enabled |
|
1547 HBufC* text = StringLoader::LoadLC( R_QTN_CHAT_FRIEND_ADD_UNKNOWN, |
|
1548 CCAPCUtils::DisplayId( wvid ) ); |
|
1549 TInt ret = IMDialogUtils::DisplayYesNoConfirmationDialogL( *text ); |
|
1550 CleanupStack::PopAndDestroy( text ); |
|
1551 if ( ret == EAknSoftkeyOk || ret == EAknSoftkeyYes ) |
|
1552 { |
|
1553 // Launch add contact. |
|
1554 AddToFriendsL(); |
|
1555 } |
|
1556 } |
|
1557 } |
|
1558 |
|
1559 // --------------------------------------------------------- |
|
1560 // CCAChatViewContainer::ResizeIcons |
|
1561 // --------------------------------------------------------- |
|
1562 // |
|
1563 void CCAConversationsContainer::ResizeIcons( TRect aParentRect ) |
|
1564 { |
|
1565 TSize size( aParentRect.Height(), aParentRect.Height() ); |
|
1566 AknIconUtils::SetSize( iFromMe->Bitmap(), size ); |
|
1567 AknIconUtils::SetSize( iToMe->Bitmap(), size ); |
|
1568 |
|
1569 iMessageExtensionsHandler.SizeChanged( size ); |
|
1570 } |
|
1571 |
|
1572 |
|
1573 // --------------------------------------------------------- |
|
1574 // CCAConversationsContainer::HandleMessageEditorEventL |
|
1575 // --------------------------------------------------------- |
|
1576 // |
|
1577 void CCAConversationsContainer::HandleMessageEditorEventL( TEditorEvent aEvent ) |
|
1578 { |
|
1579 switch ( aEvent ) |
|
1580 { |
|
1581 case EEditorContentCleared: |
|
1582 { |
|
1583 // Call StartScrollingL to update CBA if needed |
|
1584 StartScrollingL(); |
|
1585 break; |
|
1586 } |
|
1587 |
|
1588 |
|
1589 case EEditorFirstContentAdded: |
|
1590 { |
|
1591 // Call StartScrollingL to update CBA if needed |
|
1592 if ( !iEditor->IsFocused() ) |
|
1593 { |
|
1594 StartScrollingL(); |
|
1595 } |
|
1596 break; |
|
1597 } |
|
1598 default: |
|
1599 { |
|
1600 break; |
|
1601 } |
|
1602 } |
|
1603 } |
|
1604 |
|
1605 |
|
1606 // --------------------------------------------------------- |
|
1607 // CCAConversationsContainer::LoadBitmapsL |
|
1608 // --------------------------------------------------------- |
|
1609 // |
|
1610 void CCAConversationsContainer::LoadBitmapsL() |
|
1611 { |
|
1612 //Removed the ownership of iConnUI from this file and made it a reference |
|
1613 //APPUI owns this connection UI instance and shares the same with this component. |
|
1614 // get user-defined colors from SAP settings |
|
1615 CCAAppSettingsSAPExt* SAPExtension = CCAAppSettingsSAPExt::NewLC( iAppUi->ConnectionUI() ); |
|
1616 TInt ownCol( SAPExtension->IntValueL( KIMOwnMessageColourKey ) ); |
|
1617 TInt otherCol( SAPExtension->IntValueL( KIMOthersMessageColourKey ) ); |
|
1618 CleanupStack::PopAndDestroy( SAPExtension ); |
|
1619 |
|
1620 // These are pointers, because it has to be given as a pointer parameter |
|
1621 // to skin variant when loading icons |
|
1622 TRgb* ownRgbCol = NULL; |
|
1623 TRgb* otherRgbCol = NULL; |
|
1624 |
|
1625 // check if custom color is defined for incoming messages arrow |
|
1626 TBool useCustomOtherMsgColor = EFalse; |
|
1627 if ( otherCol != KErrNotFound ) |
|
1628 { |
|
1629 otherRgbCol = new ( ELeave ) TRgb( otherCol ); |
|
1630 CleanupStack::PushL( otherRgbCol ); |
|
1631 useCustomOtherMsgColor = ETrue; |
|
1632 } |
|
1633 |
|
1634 // check if custom color is defined for outgoing messages arrow |
|
1635 TBool useCustomOwnMsgColor = EFalse; |
|
1636 if ( ownCol != KErrNotFound ) |
|
1637 { |
|
1638 ownRgbCol = new ( ELeave ) TRgb( ownCol ); |
|
1639 CleanupStack::PushL( ownRgbCol ); |
|
1640 useCustomOwnMsgColor = ETrue; |
|
1641 } |
|
1642 |
|
1643 // check resource colours |
|
1644 // The color settings is fetched directly from the REsource file, and its not part of Cenrep, that is the reason for using IntResourceValueFromRssL |
|
1645 TBool defaultColors = IMUtils::IntResourceValueFromRssL( |
|
1646 RSC_CHAT_DEFAULT_MESSAGE_COLORS ); |
|
1647 |
|
1648 if ( !useCustomOwnMsgColor && !defaultColors ) |
|
1649 { |
|
1650 // user-defined color not defined and resource colour in use |
|
1651 TResourceReader reader; |
|
1652 CCoeEnv::Static()->CreateResourceReaderLC( reader, |
|
1653 RSC_CHAT_MESSAGE_COLOR ); |
|
1654 TUint8 red( reader.ReadUint8() ); |
|
1655 TUint8 green( reader.ReadUint8() ); |
|
1656 TUint8 blue( reader.ReadUint8() ); |
|
1657 |
|
1658 CleanupStack::PopAndDestroy(); // reader |
|
1659 |
|
1660 if ( !ownRgbCol ) |
|
1661 { |
|
1662 ownRgbCol = new ( ELeave ) TRgb( red, green, blue ); |
|
1663 CleanupStack::PushL( ownRgbCol ); |
|
1664 } |
|
1665 else |
|
1666 { |
|
1667 *ownRgbCol = TRgb( red, green, blue ); |
|
1668 } |
|
1669 |
|
1670 useCustomOwnMsgColor = ETrue; |
|
1671 } |
|
1672 |
|
1673 if ( !useCustomOtherMsgColor && !defaultColors ) |
|
1674 { |
|
1675 // user-defined color not defined and resource colour in use |
|
1676 TResourceReader reader; |
|
1677 CCoeEnv::Static()->CreateResourceReaderLC( reader, |
|
1678 RSC_CHAT_OWN_MESSAGE_COLOR ); |
|
1679 TUint8 red( reader.ReadUint8() ); |
|
1680 TUint8 green( reader.ReadUint8() ); |
|
1681 TUint8 blue( reader.ReadUint8() ); |
|
1682 |
|
1683 CleanupStack::PopAndDestroy(); // reader |
|
1684 |
|
1685 if ( !otherRgbCol ) |
|
1686 { |
|
1687 otherRgbCol = new ( ELeave ) TRgb( red, green, blue ); |
|
1688 CleanupStack::PushL( otherRgbCol ); |
|
1689 } |
|
1690 else |
|
1691 { |
|
1692 *otherRgbCol = TRgb( red, green, blue ); |
|
1693 } |
|
1694 |
|
1695 useCustomOwnMsgColor = ETrue; |
|
1696 } |
|
1697 |
|
1698 TBool overrideBrand( AknLayoutUtils::LayoutMirrored() ); |
|
1699 |
|
1700 CGulIcon* temp; |
|
1701 |
|
1702 // if custom colors are defined, use them |
|
1703 if ( useCustomOwnMsgColor ) |
|
1704 { |
|
1705 temp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_from, |
|
1706 EMbmChatngQgn_prop_im_from_mask, |
|
1707 iAppUi->MbmFullPath(), |
|
1708 overrideBrand, ownRgbCol ); |
|
1709 } |
|
1710 else |
|
1711 { |
|
1712 temp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_from, |
|
1713 EMbmChatngQgn_prop_im_from_mask, |
|
1714 iAppUi->MbmFullPath() ); |
|
1715 } |
|
1716 |
|
1717 CleanupStack::PushL( temp ); |
|
1718 IMUtils::UpdateIcon( iFromMe, temp ); |
|
1719 //iconTemp is removed from CleanupStack and does not have valid value |
|
1720 |
|
1721 //it can be safely reused |
|
1722 // if custom colors are defined, use them |
|
1723 if ( useCustomOtherMsgColor ) |
|
1724 { |
|
1725 temp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_tome, |
|
1726 EMbmChatngQgn_prop_im_tome_mask, |
|
1727 iAppUi->MbmFullPath(), |
|
1728 overrideBrand, otherRgbCol ); |
|
1729 } |
|
1730 else |
|
1731 { |
|
1732 temp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_im_tome, |
|
1733 EMbmChatngQgn_prop_im_tome_mask, |
|
1734 iAppUi->MbmFullPath() ); |
|
1735 } |
|
1736 |
|
1737 CleanupStack::PushL( temp ); |
|
1738 IMUtils::UpdateIcon( iToMe, temp ); |
|
1739 //iconTemp is removed from CleanupStack and does not have valid value |
|
1740 |
|
1741 |
|
1742 //it can be safely reused |
|
1743 temp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_image_corrupted, |
|
1744 EMbmChatngQgn_prop_image_corrupted_mask, |
|
1745 iAppUi->MbmFullPath() ); |
|
1746 CleanupStack::PushL( temp ); |
|
1747 IMUtils::UpdateIcon( iCorrupted, temp ); |
|
1748 //iconTemp is removed from CleanupStack and does not have valid value |
|
1749 |
|
1750 //it can be safely reused |
|
1751 temp = iSkinVar->LoadBitmapL( EMbmChatngQgn_prop_unknown, |
|
1752 EMbmChatngQgn_prop_unknown_mask, |
|
1753 iAppUi->MbmFullPath() ); |
|
1754 CleanupStack::PushL( temp ); |
|
1755 IMUtils::UpdateIcon( iUnsupported, temp ); |
|
1756 //iconTemp is removed from CleanupStack and does not have valid value |
|
1757 |
|
1758 if ( useCustomOwnMsgColor ) |
|
1759 { |
|
1760 CleanupStack::PopAndDestroy(); // ownRgbCol |
|
1761 } |
|
1762 |
|
1763 if ( useCustomOtherMsgColor ) |
|
1764 { |
|
1765 CleanupStack::PopAndDestroy(); // otherRgbCol |
|
1766 } |
|
1767 |
|
1768 } |
|
1769 |
|
1770 // --------------------------------------------------------- |
|
1771 // CCAConversationsContainer::RefreshEditorL |
|
1772 // --------------------------------------------------------- |
|
1773 // |
|
1774 void CCAConversationsContainer::RefreshEditorL() |
|
1775 { |
|
1776 iEditor->RefreshEditorL(); |
|
1777 } |
|
1778 |
|
1779 // --------------------------------------------------------- |
|
1780 // CCAConversationsContainer::IsItemHighlight |
|
1781 // --------------------------------------------------------- |
|
1782 // |
|
1783 TBool CCAConversationsContainer::IsItemHighlight() const |
|
1784 { |
|
1785 return iItemHighlight; |
|
1786 } |
|
1787 |
|
1788 // --------------------------------------------------------- |
|
1789 // CCAConversationsContainer::TextRect |
|
1790 // --------------------------------------------------------- |
|
1791 // |
|
1792 const TRect CCAConversationsContainer::TextRect() const |
|
1793 { |
|
1794 TInt lines( iEditor->NumberOfLines() ); |
|
1795 |
|
1796 if ( lines > 2 ) // ignore events for more than 2 lines |
|
1797 { |
|
1798 lines = 2; |
|
1799 } |
|
1800 lines--; // convert to index |
|
1801 |
|
1802 TAknLayoutRect rp; |
|
1803 if ( lines == 1 ) |
|
1804 { |
|
1805 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( 0 |
|
1806 /*TChatListBoxLayout::EWithEditor2Lines*/ ) ); |
|
1807 } |
|
1808 else |
|
1809 { |
|
1810 rp.LayoutRect( Rect(), AknLayoutScalable_Apps::im_reading_pane( 1 |
|
1811 /*TChatListBoxLayout::EWithEditor*/ ) ); |
|
1812 } |
|
1813 |
|
1814 TAknLayoutText text; |
|
1815 text.LayoutText( rp.Rect(), |
|
1816 AknLayoutScalable_Apps::im_reading_pane_t1( 1 ).LayoutLine() ); |
|
1817 |
|
1818 return text.TextRect(); |
|
1819 } |
|
1820 |
|
1821 |
|
1822 //added for multitab support |
|
1823 |
|
1824 // --------------------------------------------------------- |
|
1825 // CCAConversationsContainer::SwitchViewL |
|
1826 // --------------------------------------------------------- |
|
1827 // |
|
1828 void CCAConversationsContainer::SwitchViewL( ) |
|
1829 { |
|
1830 delete iChatView; |
|
1831 //iChatView is assigned NULL as NewL may leave |
|
1832 iChatView = NULL; |
|
1833 |
|
1834 //when user navigate among tab. |
|
1835 MCAMsgAddedToRichTxtCtrlObserver* observer = NULL; |
|
1836 |
|
1837 if ( !iAppUi->FocusFlag() ) |
|
1838 { |
|
1839 observer = this; |
|
1840 } |
|
1841 |
|
1842 iChatView = CCAChatViewControl::NewL( Rect(), *this, |
|
1843 *iConversationPC, |
|
1844 *iAppUi->GetProcessManager().GetSettingsInterface(), |
|
1845 iMessageExtensionsHandler, |
|
1846 iFromMe, |
|
1847 iToMe, |
|
1848 iUnsupported, |
|
1849 iCorrupted, |
|
1850 ETrue, |
|
1851 observer ); |
|
1852 |
|
1853 iChatView->SetObserver( this ); |
|
1854 |
|
1855 UpdateCbaL(); |
|
1856 |
|
1857 SizeChanged(); |
|
1858 |
|
1859 // Observe tap events |
|
1860 iChatView->SetTapObserver( this, EMessageList ); |
|
1861 |
|
1862 iAppUi->LayoutInfo()->SetLayoutID( TChatListBoxLayout::EWithEditor ); |
|
1863 iAppUi->LayoutInfo()->SetEditorVisibility( ETrue ); |
|
1864 |
|
1865 if ( iAppUi->FocusFlag() ) |
|
1866 { |
|
1867 StartScrollingL(); |
|
1868 } |
|
1869 } |
|
1870 |
|
1871 // --------------------------------------------------------- |
|
1872 // CCAConversationsContainer::HandleLoginRefreshCompleteL |
|
1873 // --------------------------------------------------------- |
|
1874 // |
|
1875 void CCAConversationsContainer::HandleLoginRefreshCompleteL( ) |
|
1876 { |
|
1877 // Check if chat is deleted, happens when user |
|
1878 // selected to login to different server. |
|
1879 // Use case: |
|
1880 // - user was logged in to server 1 |
|
1881 // - user had on going conversation with another user in server 1 |
|
1882 // - user logged out from server 1 |
|
1883 // - user opens the conversation and tries to send a message to the another user |
|
1884 // - user selects server 2 to login |
|
1885 // ==> all open conversations are deleted during login procedure |
|
1886 if ( iChatView->IsDeleted() ) |
|
1887 { |
|
1888 iConversationPC->SetActiveConversationL( iWvId ); |
|
1889 |
|
1890 HBufC* msgBuf = iMessageExtensionsHandler.ProcessMessageLC( *iEditor ); |
|
1891 iEditorContentStorage.StoreContent( msgBuf ); // Ownership changed |
|
1892 CleanupStack::Pop( msgBuf ); |
|
1893 |
|
1894 iTabId = iAppUi->CAStatusPane()->ResetAndShowCurrentTabL( TEnumsPC::EConversationItem, |
|
1895 iWvId ) ; |
|
1896 ResetSending(); |
|
1897 |
|
1898 SwitchViewL(); |
|
1899 |
|
1900 SendMessageL(); |
|
1901 |
|
1902 } |
|
1903 else |
|
1904 { |
|
1905 // Contacts are now available, update titlebar |
|
1906 iTitleUpdater.UpdateTitleL(); |
|
1907 // Proceed with message sending |
|
1908 SendMessageL(); |
|
1909 ResetSending(); |
|
1910 } |
|
1911 MCALoginPC *loginPC = iAppUi->GetProcessManager().GetLogInInterface(); |
|
1912 loginPC->RemoveObserver(); |
|
1913 } |
|
1914 |
|
1915 // --------------------------------------------------------- |
|
1916 // CCAConversationsContainer::ShowRecordSavingWarningL() |
|
1917 // (other items were commented in a header). |
|
1918 // --------------------------------------------------------- |
|
1919 // |
|
1920 void CCAConversationsContainer::ShowRecordSavingWarningL() const |
|
1921 { |
|
1922 if ( IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_RECORD_WARNING ) ) |
|
1923 { |
|
1924 HBufC* warningText = CCoeEnv::Static()->AllocReadResourceLC( |
|
1925 R_CHAT_RECORD_WARNING ); |
|
1926 |
|
1927 HBufC* warningHeading = CCoeEnv::Static()->AllocReadResourceLC( |
|
1928 R_CHAT_RECORD_WARNING_HEADING ); |
|
1929 |
|
1930 IMDialogUtils::DisplayMessageQueryDialogL( |
|
1931 R_CHATCLIENT_MESSAGE_QUERY_DIALOG, |
|
1932 *warningText, |
|
1933 *warningHeading |
|
1934 ); |
|
1935 |
|
1936 CleanupStack::PopAndDestroy( 2, warningText ); |
|
1937 } |
|
1938 |
|
1939 } |
|
1940 |
|
1941 // --------------------------------------------------------- |
|
1942 // CCAConversationsContainer::HandleMessageAddedL |
|
1943 // --------------------------------------------------------- |
|
1944 // |
|
1945 void CCAConversationsContainer::HandleMessageAddedL( const TInt aMessageCount ) |
|
1946 { |
|
1947 //called by tabswitch. hence set the foxus to the last message |
|
1948 if ( iConversationPC->MessageCount() == aMessageCount ) |
|
1949 { |
|
1950 iChatView->MoveHighlightL( CCARichTextContainer::EPrevious ); |
|
1951 |
|
1952 iChatView->UnRegisterRichTxtCtrlObserver(); |
|
1953 |
|
1954 UpdateCbaL(); |
|
1955 } |
|
1956 |
|
1957 } |
|
1958 |
|
1959 #ifdef RD_MULTIPLE_DRIVE |
|
1960 // ----------------------------------------------------------------------------- |
|
1961 // CCAConversationsContainer::ShowMemorySelectionDialogL |
|
1962 // New actual filename for new history file. |
|
1963 // ----------------------------------------------------------------------------- |
|
1964 // |
|
1965 TBool CCAConversationsContainer::ShowMemorySelectionDialogL() |
|
1966 { |
|
1967 CHAT_DP_TXT( "CCALoggerManager::ShowMemorySelectionDialogL" ); |
|
1968 |
|
1969 ///////// read settings from cenrep /////////////// |
|
1970 |
|
1971 TBuf< KMaxPath > defaultDrive; |
|
1972 TBuf< KMaxPath > pathTempWithoutDrive; |
|
1973 TBuf< KMaxPath > driveAndPath; |
|
1974 |
|
1975 CRepository* cenrep = NULL; |
|
1976 TRAPD( err, cenrep = CRepository::NewL( KWVSettingsCenRepUid ) ); |
|
1977 |
|
1978 if ( err == KErrNone ) |
|
1979 { |
|
1980 // creation of cenrep OK |
|
1981 CleanupStack::PushL( cenrep ); |
|
1982 err = cenrep->Get( KIMPSCRIMDefaultMemoryDrive, defaultDrive ); |
|
1983 if ( err != KErrNone ) |
|
1984 { |
|
1985 CleanupStack::PopAndDestroy( cenrep ); |
|
1986 cenrep = NULL; |
|
1987 User::Leave( err ); |
|
1988 } |
|
1989 // end of reading from cenrep |
|
1990 |
|
1991 TInt driveNo = 0; |
|
1992 err = RFs::CharToDrive( defaultDrive[0], driveNo ); |
|
1993 TDriveNumber driveNumber = TDriveNumber( driveNo ); |
|
1994 |
|
1995 // Check drive's media status |
|
1996 TBool isDriveOk = iAppUi->GetDriveStatusL( driveNumber ); |
|
1997 if ( !isDriveOk ) |
|
1998 { |
|
1999 |
|
2000 // prompt the user to save into a different drive....... |
|
2001 CAknMemorySelectionDialogMultiDrive* dlg = CAknMemorySelectionDialogMultiDrive::NewL( |
|
2002 ECFDDialogTypeSave, |
|
2003 EFalse ); |
|
2004 |
|
2005 HBufC* rootBuffer = HBufC::NewLC( KMaxPath ); |
|
2006 TPtr rootBufferPtr ( rootBuffer->Des() ); |
|
2007 |
|
2008 HBufC* defaultFolderBuffer = HBufC::NewLC( KMaxPath ); |
|
2009 TPtr defaultFolderBufferPtr ( defaultFolderBuffer->Des() ); |
|
2010 |
|
2011 CleanupStack::PushL( dlg ); |
|
2012 TBool ret( dlg->ExecuteL( driveNumber, &rootBufferPtr, &defaultFolderBufferPtr ) ); |
|
2013 CleanupStack::PopAndDestroy( dlg ); |
|
2014 |
|
2015 CleanupStack::PopAndDestroy( defaultFolderBuffer ); |
|
2016 |
|
2017 if ( ret ) |
|
2018 { |
|
2019 // update the centrep sheet also..as user changed the default folder... |
|
2020 cenrep->Set( KIMPSCRIMDefaultMemoryDrive, rootBufferPtr.Left( 3 ) ); |
|
2021 driveAndPath.Append( rootBufferPtr.Left( 2 ) ); // append the drive root here with user selected drive... |
|
2022 CleanupStack::PopAndDestroy( rootBuffer ); |
|
2023 CleanupStack::PopAndDestroy( cenrep ); |
|
2024 cenrep = NULL; |
|
2025 } |
|
2026 else |
|
2027 { |
|
2028 CleanupStack::PopAndDestroy( rootBuffer ); |
|
2029 CleanupStack::PopAndDestroy( cenrep ); |
|
2030 cenrep = NULL; |
|
2031 } |
|
2032 |
|
2033 // use selected memory |
|
2034 return ret; |
|
2035 } |
|
2036 else |
|
2037 |
|
2038 { |
|
2039 |
|
2040 CleanupStack::PopAndDestroy( cenrep ); |
|
2041 |
|
2042 cenrep = NULL; |
|
2043 |
|
2044 // use the default memory |
|
2045 return ETrue; |
|
2046 } |
|
2047 |
|
2048 }// end of cenrep error |
|
2049 |
|
2050 // cenrep create error |
|
2051 return EFalse; |
|
2052 } |
|
2053 |
|
2054 #endif |
|
2055 |
|
2056 // End of File |