|
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: Flow controller for messages |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCAMESSAGEFLOWHANDLERPC_H |
|
21 #define CCAMESSAGEFLOWHANDLERPC_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "MCAMessageObserver.h" |
|
26 #include "MCASettingsObserver.h" |
|
27 #include "MCAMessageFlowHandlerPC.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class MCAMessagesReadInterface; |
|
31 class MCASettings; |
|
32 class MCAConversationManagerPC; |
|
33 class MCARecordedChatsPC; |
|
34 |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Flow controller for messages |
|
40 * |
|
41 * @lib wvuiprocessng.dll |
|
42 * @since Series 60 3 dot 2 |
|
43 */ |
|
44 class CCAMessageFlowHandlerPC : public CTimer, public MCAMessageObserver, |
|
45 public MCASettingsObserver, public MCAMessageFlowHandlerPC |
|
46 { |
|
47 |
|
48 |
|
49 |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Should we fetch new messages or not |
|
54 * @param aFetch ETrue if this chat is in foreground and should |
|
55 * receive messages, EFalse otherwise. |
|
56 */ |
|
57 void FetchMessages( TBool aFetch ); |
|
58 |
|
59 |
|
60 |
|
61 protected: // Functions from MCAMessageObserver |
|
62 |
|
63 /** |
|
64 * Handle events. |
|
65 * @param aEvent Event to handle. |
|
66 * @param aIndex, Index of message which is affected by event. |
|
67 */ |
|
68 void HandleMessageEvent( TMessageEventType aEvent, TInt aIndex ); |
|
69 |
|
70 protected: // Functions from CTimer |
|
71 |
|
72 /** |
|
73 * @see CTimer |
|
74 */ |
|
75 void RunL(); |
|
76 |
|
77 /** |
|
78 * @see CActive |
|
79 */ |
|
80 TInt RunError( TInt aError ); |
|
81 |
|
82 protected: // Functions from MCASettingsObserver |
|
83 |
|
84 /** |
|
85 * Handles setting changes. |
|
86 * @param aChangedSettingEnum specifies the changed setting. |
|
87 */ |
|
88 void HandleSettingsChangeL( TInt aChangedSettingEnum ); |
|
89 |
|
90 |
|
91 private: // New functions |
|
92 |
|
93 /** |
|
94 * Get flow control value from settings |
|
95 */ |
|
96 void UpdateTimeIntervalL(); |
|
97 |
|
98 /** |
|
99 * Is opening on going or not. |
|
100 * @since Series 60 v3.2 |
|
101 * @return ETrue if opening on going, EFalse otherwise. |
|
102 */ |
|
103 TBool IsOpening() const; |
|
104 |
|
105 /** |
|
106 * Corrects the real index to current index of messages. |
|
107 * This is needed when opening a chat, because messages |
|
108 * are not added to container in additional order. |
|
109 * @param aIndex Real index of message in container |
|
110 * @return current index of message in container. |
|
111 */ |
|
112 TInt MessageIndexCorrection( TInt aIndex ) const; |
|
113 |
|
114 private: |
|
115 |
|
116 /** |
|
117 * C++ default constructor. |
|
118 */ |
|
119 CCAMessageFlowHandlerPC( MCAMessageContainer& aMessageContainer, |
|
120 MCAMessagesReadInterface& aReadInterface, |
|
121 MCASettings& aSettings ); |
|
122 |
|
123 /** |
|
124 * By default Symbian 2nd phase constructor is private. |
|
125 */ |
|
126 void ConstructL( TBool aRecordedChatHandler ); |
|
127 |
|
128 public: // Constructors and destructor |
|
129 |
|
130 /** |
|
131 * Two-phased constructor. |
|
132 * @param aMessageContainer Interface to UI side message container |
|
133 * @param aReadInterface Message read interface |
|
134 * @param aSettings Interface to settings manager |
|
135 * @param aRecordedChatHandler Is this handler for recorded chat |
|
136 * or not. |
|
137 */ |
|
138 static CCAMessageFlowHandlerPC* NewL( |
|
139 MCAMessageContainer& aMessageContainer, |
|
140 MCAMessagesReadInterface& aReadInterface, |
|
141 MCASettings& aSettings, |
|
142 TBool aRecordedChatHandler ); |
|
143 |
|
144 /** |
|
145 * Destructor. |
|
146 */ |
|
147 virtual ~CCAMessageFlowHandlerPC(); |
|
148 |
|
149 |
|
150 private: // Data |
|
151 |
|
152 // Interface for UI side message container |
|
153 // Not owned |
|
154 MCAMessageContainer& iMessages; |
|
155 |
|
156 // Interface for fetching messages |
|
157 // Not owned |
|
158 MCAMessagesReadInterface& iReadInterface; |
|
159 |
|
160 // interface for settings manager |
|
161 MCASettings& iSettings; |
|
162 |
|
163 // time interval for receiving messages |
|
164 TTimeIntervalMicroSeconds32 iTimeInterval; |
|
165 |
|
166 // Is chat deleted already |
|
167 TBool iChatDeleted; |
|
168 |
|
169 // Should we fetch new messages |
|
170 TBool iFetchMessages; |
|
171 |
|
172 // Index for fetching messages |
|
173 TInt iMsgIndex; |
|
174 |
|
175 // Initial count for messages |
|
176 TInt iInitialMsgCount; |
|
177 |
|
178 // Is new message received while opening the chat |
|
179 TBool iNewMsgWhileOpening; |
|
180 |
|
181 // Flag is read from CR variation in class construction |
|
182 // ETrue in releases >= 3.2 |
|
183 // EFalse in releases < 3.2 |
|
184 // Set to EFalse if this handler is used to handle |
|
185 // recorded chat |
|
186 TBool iBgOpeningMode; |
|
187 |
|
188 TInt iAddedUnreadMsgs; |
|
189 |
|
190 // allow unit tests to access protected member functions |
|
191 friend class UT_CCAMessageFlowHandler; // CSI: 36 # see above |
|
192 |
|
193 }; |
|
194 |
|
195 #endif // CCAMESSAGEFLOWHANDLERPC_H |
|
196 |
|
197 // End of File |