|
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: This is container class for conversation view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCACONVERSATIONSCONTAINER_H |
|
21 #define CCACONVERSATIONSCONTAINER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "MCALayoutChangeObserver.h" |
|
25 #include "mcatapeventobserver.h" |
|
26 #include "CCAMessageEditor.h" // MCAMessageEditorObserver |
|
27 |
|
28 #include <aknview.h> |
|
29 #include <eikedwob.h> |
|
30 #include <bamdesca.h> //For the MDesCArray |
|
31 #include <badesca.h> //For the CDesCArray |
|
32 #include <eikbtgpc.h> |
|
33 #include <eikrted.h> |
|
34 #include <aknutils.h> |
|
35 #include <aknEditStateIndicator.h> |
|
36 #include <AknIndicatorContainer.h> |
|
37 #include "ChatDefinitions.h" |
|
38 #include "MCALoginRefreshObserverPC.h" |
|
39 #include "MCAMsgAddedToRichTxtCtrlObserver.h" |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class MCAViewSwitcher; |
|
43 class MCARecipientObserver; |
|
44 class MCASkinVariant; |
|
45 class CCAChatListBox; |
|
46 class CCAMessageEditor; |
|
47 class CCAEngine; |
|
48 class CCABlockingUI; |
|
49 class CCAAppUi; |
|
50 class CCAMessageExtensionsHandler; |
|
51 class CCAChatViewControl; |
|
52 class MCAMessagesReadInterface; |
|
53 class MCAMessagesWriteInterface; |
|
54 class CGulIcon; |
|
55 class MCAConversationMessage; |
|
56 class MCAConversationPC; |
|
57 class CCAEditIndicator; |
|
58 |
|
59 /** |
|
60 * Helper class for updating title when needed. |
|
61 */ |
|
62 class MCATitleUpdater |
|
63 { |
|
64 public: |
|
65 |
|
66 /** |
|
67 * Update title. |
|
68 */ |
|
69 virtual void UpdateTitleL() = 0; |
|
70 |
|
71 protected: |
|
72 |
|
73 /** |
|
74 * Destructor for protection. |
|
75 */ |
|
76 virtual ~MCATitleUpdater() {}; |
|
77 }; |
|
78 |
|
79 /** |
|
80 * Helper class for stroring editor content. |
|
81 */ |
|
82 class MCAEditorContentStorage |
|
83 { |
|
84 public: |
|
85 /** |
|
86 * Stores editor content. |
|
87 * @param aContent Pointer to content data, |
|
88 * takes ownership. |
|
89 */ |
|
90 virtual void StoreContent( const HBufC* aContent ) = 0; |
|
91 |
|
92 protected: |
|
93 |
|
94 /** |
|
95 * Destructor for protection. |
|
96 */ |
|
97 virtual ~MCAEditorContentStorage() {}; |
|
98 }; |
|
99 |
|
100 // CLASS DECLARATION |
|
101 |
|
102 /** |
|
103 * This is container class for conversation view |
|
104 * |
|
105 * @lib chat.app |
|
106 * @since 3.2s |
|
107 */ |
|
108 class CCAConversationsContainer : public CCoeControl, |
|
109 public MEikEdwinSizeObserver, |
|
110 public MCALayoutChangeObserver, |
|
111 public MCATapEventObserver, |
|
112 public MCoeControlObserver, |
|
113 public MCAMessageEditorObserver, |
|
114 public MCALoginRefreshObserverPC, |
|
115 public MCAMsgAddedToRichTxtCtrlObserver |
|
116 { |
|
117 public: // Enumerations |
|
118 |
|
119 /** |
|
120 * Observed controls (MCATapEventObserver) |
|
121 */ |
|
122 enum TTouchableControls |
|
123 { |
|
124 EMessageList = 1, |
|
125 EMessageEditor |
|
126 }; |
|
127 |
|
128 public: // Constructors and destructor |
|
129 |
|
130 /** |
|
131 * Symbian OS default constructor. |
|
132 * @param aRect Frame rectangle for container. |
|
133 * @param aViewSwitcher Handle to view switcher. |
|
134 * @param aRecipientObserver Recipient observer |
|
135 * @param aParent Context access mechanism. |
|
136 * @param aMessageHandler Handling messages |
|
137 * @param aTitleUpdater for updating title of chat. |
|
138 * @param aTabId |
|
139 */ |
|
140 static CCAConversationsContainer* NewL( const TRect& aRect, |
|
141 MCAViewSwitcher& aViewSwitcher, |
|
142 MCAConversationPC* aCCAConversationManagerPC, |
|
143 MCARecipientObserver& aRecipientObserver, |
|
144 MObjectProvider* aParent, |
|
145 CCAMessageExtensionsHandler& aMessageHandler, |
|
146 MCATitleUpdater& aTitleUpdater, |
|
147 MCAEditorContentStorage& aEditorContentStorage, |
|
148 CEikButtonGroupContainer* aCba, |
|
149 const TBool aActivateFromTabSwitch , TInt& aTabId ); |
|
150 |
|
151 /* |
|
152 * Constructor |
|
153 */ |
|
154 CCAConversationsContainer( |
|
155 MCAViewSwitcher& aViewSwitcher, |
|
156 MCAConversationPC* aCCAConversationManagerPC, |
|
157 MCARecipientObserver& aRecipientObserver, |
|
158 CCAMessageExtensionsHandler& aMessageHandler, |
|
159 MCATitleUpdater& aTitleUpdater, |
|
160 MCAEditorContentStorage& aEditorContentStorage, |
|
161 CEikButtonGroupContainer* aCba, TInt& aTabId ); |
|
162 |
|
163 /** |
|
164 * Destructor. |
|
165 */ |
|
166 virtual ~CCAConversationsContainer(); |
|
167 |
|
168 |
|
169 private: |
|
170 |
|
171 /** |
|
172 * Symbian OS default constructor. |
|
173 * @param aRect Frame rectangle for container. |
|
174 * @param aParent Context access mechanism. |
|
175 */ |
|
176 void ConstructL( const TRect& aRect, MObjectProvider* aParent, |
|
177 const TBool aActivateFromTabSwitch ); |
|
178 |
|
179 |
|
180 public: // New functions |
|
181 |
|
182 /** |
|
183 * Check if selected item is object |
|
184 * @param aIsOpenable method sets this ETrue if selected item |
|
185 * is openable object else set to EFalse |
|
186 * @return ETrue if selected item is object |
|
187 */ |
|
188 TBool IsObjectSelected( TBool& aIsOpenable , TBool& aIsSaved ); |
|
189 |
|
190 /** |
|
191 * @return Selected message or NULL if nothing selected |
|
192 */ |
|
193 MCAConversationMessage* SelectedMessage(); |
|
194 |
|
195 /** |
|
196 * Sets item highlighting on or off (automatic find) |
|
197 * @param aHihghlight ETrue to set finder on |
|
198 */ |
|
199 void SetItemHighlightL( TBool aHighlight ); |
|
200 |
|
201 /** |
|
202 * Should we fetch new messages or not |
|
203 * @param aFetch ETrue if this chat is in foreground and should receive |
|
204 * messages, EFalse otherwise. |
|
205 */ |
|
206 void FetchMessages( TBool aFetch ); |
|
207 |
|
208 /** |
|
209 * Returns buffer containing the currently selected text |
|
210 * (or empty buffer if nothing selected) |
|
211 */ |
|
212 HBufC* SelectedItemL(); |
|
213 |
|
214 /** |
|
215 * @return Type of selected item |
|
216 */ |
|
217 TInt SelectedItemType(); |
|
218 |
|
219 /** |
|
220 * This checks if scroll mode is on or off |
|
221 * @since 3.2 |
|
222 * @return Returns if scrolling is stopped or not (TBool) |
|
223 */ |
|
224 TBool IsStopped() const; |
|
225 |
|
226 /** |
|
227 * This method starts scrolling |
|
228 * @since 3.2 |
|
229 */ |
|
230 void StartScrollingL( const TBool aActivateFromTabSwitch = EFalse ); |
|
231 |
|
232 /** |
|
233 * This method stops scrolling |
|
234 * @since 3.2 |
|
235 */ |
|
236 void StopScrollingL(); |
|
237 |
|
238 /** |
|
239 * This method returns pointer to msg editor |
|
240 * @since 3.2 |
|
241 * @return Handle to editor |
|
242 */ |
|
243 CCAMessageEditor& Editor() const; |
|
244 |
|
245 /** |
|
246 * This method handles message sending |
|
247 * @since 3.2 |
|
248 */ |
|
249 void SendMessageL(); |
|
250 |
|
251 /** |
|
252 * This function allows friend adding to friends list |
|
253 * @since 3.2 |
|
254 */ |
|
255 void AddToFriendsL(); |
|
256 |
|
257 |
|
258 /** |
|
259 * Blocks user |
|
260 * @since 3.2 |
|
261 */ |
|
262 void BlockUserL(); |
|
263 |
|
264 /** |
|
265 * Checks if user is blocked |
|
266 * @since 3.2 |
|
267 * @return ETrue if blocked |
|
268 */ |
|
269 TBool IsBlocked() const; |
|
270 |
|
271 |
|
272 /** |
|
273 *Block user by wv id |
|
274 * @since 3.2 |
|
275 */ |
|
276 void BlockUserWVIdL(); |
|
277 |
|
278 /** |
|
279 *Unblock users |
|
280 * @since 3.2 |
|
281 */ |
|
282 void UnBlockL(); |
|
283 |
|
284 /** |
|
285 * Show blocked contacts |
|
286 * @since 3.2 |
|
287 */ |
|
288 void DisplayBlockedListL(); |
|
289 |
|
290 /** |
|
291 * Checks if application user has sent a message |
|
292 * @since 3.2 |
|
293 * @return ETrue if did |
|
294 */ |
|
295 TBool ApplicationUserSentThis() const; |
|
296 |
|
297 /** |
|
298 * Sets the Logging/recording on |
|
299 * @since 3.2 |
|
300 */ |
|
301 void RecordChatL(); |
|
302 #ifdef RD_MULTIPLE_DRIVE |
|
303 |
|
304 /** |
|
305 * show memorey selection dialog and updatesthe same to the cenrep. |
|
306 * Leaves if HBufC::NewL fails. |
|
307 * @return ETrue if ok |
|
308 * @since 2.1 |
|
309 */ |
|
310 TBool ShowMemorySelectionDialogL(); |
|
311 |
|
312 #endif |
|
313 |
|
314 /** |
|
315 * Tests if extension (in chars) fits to editor |
|
316 * @return ETrue if fits |
|
317 * @param aLength Extensions length in chars |
|
318 * @since 3.2 |
|
319 */ |
|
320 TBool ExtensionFits( TInt aLength ); |
|
321 |
|
322 // some oracles for the view class |
|
323 |
|
324 /** |
|
325 * @return Forward to contact-menu visible (ETrue) |
|
326 * @since 3.2 |
|
327 */ |
|
328 TBool FwdContactVisible(); |
|
329 |
|
330 /** |
|
331 * @return Forward to group-menu visible (ETrue) |
|
332 * @since 3.2 |
|
333 */ |
|
334 TBool FwdGroupVisible(); |
|
335 |
|
336 |
|
337 /** |
|
338 * CheckReplyL. Check if there is reply situation |
|
339 */ |
|
340 void CheckReplyL(); |
|
341 |
|
342 /** |
|
343 * Sets the size of all icons; smileys etc. |
|
344 * @param aParentRect Size of the parent object (view) |
|
345 */ |
|
346 void ResizeIcons( TRect aParentRect ); |
|
347 |
|
348 /** |
|
349 * Method to force refresh in the rich text editor, |
|
350 * called from view when adding a smiley. |
|
351 * @since 3.0 |
|
352 */ |
|
353 void RefreshEditorL(); |
|
354 |
|
355 /** |
|
356 * Is item highlight on or off. |
|
357 * @since S60 v3.2 |
|
358 * @return ETrue if find activated, EFalse otherwise |
|
359 */ |
|
360 TBool IsItemHighlight() const; |
|
361 |
|
362 /** |
|
363 * Returns TRect for reading pane text line element. |
|
364 * Used to determine icon sizes. |
|
365 * @since S60 v3. |
|
366 * @return TRect for reading pane text line element. |
|
367 */ |
|
368 const TRect TextRect() const; |
|
369 |
|
370 /** |
|
371 * ETrue if message sending is ongoing |
|
372 */ |
|
373 TBool Sending() const; |
|
374 |
|
375 /** |
|
376 * Resets the sending state |
|
377 */ |
|
378 void ResetSending(); |
|
379 |
|
380 /** |
|
381 * Checks if conversation partner is blocked |
|
382 * and unblocks if partner is blocked. Shows needed |
|
383 * notes. Used in message sending. |
|
384 * @since S60 v3.2 |
|
385 */ |
|
386 void CheckBlockedL(); |
|
387 |
|
388 |
|
389 public: |
|
390 //added for multitab support |
|
391 /** |
|
392 * SwitchViewL |
|
393 * Switches between the conversation |
|
394 * @since S60 v3.2 |
|
395 */ |
|
396 void SwitchViewL( ); |
|
397 |
|
398 /** |
|
399 * GetEditorFlag |
|
400 * get the current editor flag |
|
401 * @since S60 v3.2 |
|
402 */ |
|
403 TInt GetEditorFlag( ); |
|
404 |
|
405 /** |
|
406 * Handle editor event. |
|
407 * from MCALoginRefreshObserverPC |
|
408 */ |
|
409 void HandleLoginRefreshCompleteL(); |
|
410 |
|
411 private: |
|
412 /** |
|
413 * This function does basic clearing after the message is sent |
|
414 */ |
|
415 void ResetAfterSendL( const TBool aActivateFromTabSwitch = EFalse ); |
|
416 |
|
417 /** |
|
418 * Update the CBA labels |
|
419 */ |
|
420 void UpdateCbaL(); |
|
421 |
|
422 /** |
|
423 * This function displays information notes |
|
424 * @param aResourceId Resource ID of note |
|
425 */ |
|
426 void DisplayInfoNoteL( const TInt aResourceId ); |
|
427 |
|
428 /** |
|
429 * Display warning note before recording |
|
430 */ |
|
431 void ShowRecordSavingWarningL() const; |
|
432 |
|
433 |
|
434 private: // Functions from base classes |
|
435 |
|
436 /** |
|
437 * From MCALayoutChangeObserver, for layout change observing |
|
438 */ |
|
439 void LayoutChangedL( TInt aType ); |
|
440 |
|
441 /** |
|
442 * From MEikEdwinSizeObserver, This method handles edwin's size change |
|
443 * @param aEdwin The edwin for which the size event is being handled |
|
444 * @param aEventType The event type |
|
445 * @param aDesirableEdwinSize The desired size for the edwin identified |
|
446 * by aEdwin |
|
447 * @return The return value depends on your implementation. |
|
448 * Return ETrue if you wish to redraw the edwin. |
|
449 * EFalse otherwise |
|
450 */ |
|
451 TBool HandleEdwinSizeEventL( CEikEdwin* aEdwin, |
|
452 TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize ); |
|
453 |
|
454 private: // From MCATapEventObserver |
|
455 |
|
456 /** |
|
457 * @see MCATapEventObserver |
|
458 */ |
|
459 void HandleTapEventL( TTapEvent aEvent, TUint aControlId ); |
|
460 |
|
461 private: // From MCoeControlObserver |
|
462 |
|
463 /** |
|
464 * @see MCoeControlObserver |
|
465 */ |
|
466 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
467 |
|
468 private: //from MCAMsgAddedToRichTxtCtrlObserver |
|
469 |
|
470 /** |
|
471 * @see MCAMsgAddedToRichTxtCtrlObserver |
|
472 */ |
|
473 void HandleMessageAddedL( const TInt aMessageCount ); |
|
474 |
|
475 private: // Functions CCoeControl |
|
476 |
|
477 /** |
|
478 * From CoeControl, Handles "size changed"-events.. |
|
479 */ |
|
480 void SizeChanged(); |
|
481 |
|
482 /** |
|
483 * From CoeControl, |
|
484 * Returns the number of control contained by this class. |
|
485 * @return Number of controls contained |
|
486 */ |
|
487 TInt CountComponentControls() const; |
|
488 |
|
489 /** |
|
490 * From CCoeControl, Returns handle to control pointed by aIndex |
|
491 * @param aIndex Wanted control's index [0..n] |
|
492 * @return Handle to wanted control |
|
493 */ |
|
494 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
495 |
|
496 /** |
|
497 * From CCoeControl, Gets called when drawing is needed (by framework) |
|
498 * @param aRect Rect that needs to be drawed |
|
499 */ |
|
500 void Draw( const TRect& aRect ) const; |
|
501 |
|
502 /** |
|
503 * From CCoeControl, Handles key-events |
|
504 * @param aKeyEvent Event that occured |
|
505 * @param aType Type of key-event |
|
506 * (EEventKey, EEventKeyUp or EEventKeyDown) |
|
507 * @return Containers response to event |
|
508 * (EKeyWasNotConsumed/ EKeyWasConsumed) |
|
509 */ |
|
510 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
511 TEventCode aType ); |
|
512 |
|
513 /* |
|
514 * From CCoeControl. |
|
515 * @param aContext Help context |
|
516 */ |
|
517 void GetHelpContext( TCoeHelpContext& aContext ) const; |
|
518 |
|
519 /* |
|
520 * From CCoeControl. |
|
521 * @param aDrawNow Draw param |
|
522 */ |
|
523 void FocusChanged(TDrawNow aDrawNow); |
|
524 |
|
525 private: // From MCAMessageEditorObserver |
|
526 |
|
527 /** |
|
528 * Handle editor event. |
|
529 */ |
|
530 void HandleMessageEditorEventL( TEditorEvent aEvent ); |
|
531 |
|
532 private: // new functions |
|
533 |
|
534 /** |
|
535 * Loads bitmaps |
|
536 */ |
|
537 void LoadBitmapsL(); |
|
538 |
|
539 |
|
540 private: // Data |
|
541 |
|
542 // Owns. Chat view control |
|
543 CCAChatViewControl* iChatView; |
|
544 |
|
545 // Doesn't own. Handle to view switcher |
|
546 MCAViewSwitcher& iViewSwitcher; |
|
547 |
|
548 //Doesn't own. Handle to recipient observer |
|
549 MCARecipientObserver& iRecipientObserver; |
|
550 |
|
551 // Owns. Editor used for chat input |
|
552 CCAMessageEditor* iEditor; |
|
553 |
|
554 //Owns. UI side blocker |
|
555 CCABlockingUI* iBlockingUI; |
|
556 |
|
557 //Owns. "From me" icon |
|
558 CGulIcon* iFromMe; |
|
559 |
|
560 //Owns. "To me" icon |
|
561 CGulIcon* iToMe; |
|
562 |
|
563 //Owns. "Unsupported" icon |
|
564 CGulIcon* iUnsupported; |
|
565 |
|
566 //Owns. "Corrupted" icon |
|
567 CGulIcon* iCorrupted; |
|
568 |
|
569 TBool iIsChangeToOnlineAskedOnce; |
|
570 TBool iSending; |
|
571 |
|
572 TInt iCurrentItemIndex; |
|
573 |
|
574 TAknLayoutRect iOutLine; |
|
575 TAknLayoutRect iHoriline; |
|
576 TAknLayoutRect iVertLine; |
|
577 |
|
578 |
|
579 TPtrC iCurrentRecipient; |
|
580 |
|
581 MCASkinVariant* iSkinVar; |
|
582 CCAAppUi* iAppUi; |
|
583 |
|
584 CCAMessageExtensionsHandler& iMessageExtensionsHandler; |
|
585 |
|
586 // If add contact is asked. ETrue if not EFalse. |
|
587 TBool iIsAddToContactAskedOnce; |
|
588 |
|
589 /// For updating title when needed. |
|
590 MCATitleUpdater& iTitleUpdater; |
|
591 |
|
592 TBool iItemHighlight; |
|
593 |
|
594 // For storing editor content. Not owned. |
|
595 MCAEditorContentStorage& iEditorContentStorage; |
|
596 |
|
597 // Does not own. Pointer to cba of view. |
|
598 CEikButtonGroupContainer* iCba; |
|
599 |
|
600 // See IMVariant.hrh. |
|
601 // Flag depends on EIMFeatSendkeyInMsgList. |
|
602 TBool iSendkeyInMsgList; |
|
603 |
|
604 //ptr to the conversation's process component |
|
605 MCAConversationPC* iConversationPC; |
|
606 |
|
607 //owns |
|
608 CCAEditIndicator* iEditIndicator; |
|
609 |
|
610 TInt& iTabId; |
|
611 |
|
612 TBuf<KMaxWVIDLength> iWvId; |
|
613 |
|
614 // Used in switching tabs |
|
615 TBool ifocusFlag; |
|
616 |
|
617 // Flag to indicate whether login is running |
|
618 TBool iLogingFlag; |
|
619 }; |
|
620 |
|
621 #endif // CCACONVERSATIONSCONTAINER_H |
|
622 |
|
623 // End of File |