|
1 /* |
|
2 * Copyright (c) 2008 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: cache session class declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CIMCACHESESSION_H__ |
|
19 #define __CIMCACHESESSION_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <s32mem.h> |
|
23 #include <imcachedefs.h> |
|
24 |
|
25 // FARWORD DECLARATION |
|
26 class CIMCacheServer; |
|
27 class CCacheServerActiveHelper; |
|
28 class MIMCacheMessageHeader ; |
|
29 class CIMCacheMessageBase; |
|
30 class CIMCacheBufferArray; |
|
31 |
|
32 /** |
|
33 * Service side session. |
|
34 */ |
|
35 class CIMCacheSession : public CSession2 |
|
36 { |
|
37 |
|
38 |
|
39 public: |
|
40 |
|
41 /** |
|
42 * NewL. |
|
43 * Constructors |
|
44 */ |
|
45 static CIMCacheSession* NewL(); |
|
46 /** |
|
47 * ~CIMCacheSession |
|
48 * destructors |
|
49 */ |
|
50 virtual ~CIMCacheSession(); |
|
51 |
|
52 |
|
53 protected: // C++ constructors |
|
54 /** |
|
55 * C++ default constructor. |
|
56 */ |
|
57 CIMCacheSession(); |
|
58 |
|
59 /** |
|
60 * Symbian OS constructor |
|
61 */ |
|
62 void ConstructL(); |
|
63 |
|
64 public: // Methods derived from CSession2 |
|
65 /** |
|
66 * From CSession2 |
|
67 */ |
|
68 void CreateL(); |
|
69 /** |
|
70 * From CSession2 |
|
71 */ |
|
72 void ServiceL( const RMessage2 &aMessage ); |
|
73 /** |
|
74 * From CSession2 |
|
75 */ |
|
76 void ServiceError( const RMessage2& aMessage, |
|
77 TInt aError ); |
|
78 |
|
79 |
|
80 |
|
81 public: // New methods |
|
82 |
|
83 /** |
|
84 * Server , |
|
85 * @return server reference |
|
86 */ |
|
87 CIMCacheServer* Server() |
|
88 { |
|
89 return (CIMCacheServer*) CSession2::Server(); |
|
90 } |
|
91 |
|
92 /** |
|
93 * pack and notify msg notification |
|
94 * @param aChangeType , notification type |
|
95 * @param aMsgHeader, chat header |
|
96 * @param aMessage , a message |
|
97 * @param aServiceId ,service id |
|
98 */ |
|
99 void PackAndNotifyEventL( TIMCacheOperationsCode aChangeType , |
|
100 MIMCacheMessageHeader* aMsgHeader = NULL , |
|
101 CIMCacheMessageBase* aMessage = NULL ); |
|
102 |
|
103 /* |
|
104 * return the service Id of session |
|
105 */ |
|
106 TInt ServiceId() const ; |
|
107 |
|
108 private: // New methods |
|
109 |
|
110 |
|
111 /** |
|
112 * Dispatch clients message |
|
113 * @since |
|
114 * @param aMessage client's message |
|
115 */ |
|
116 TBool DispatchMessageL( const RMessage2 &aMessage ); |
|
117 |
|
118 |
|
119 /** |
|
120 * Initializes the server |
|
121 * @param aMessage client's message |
|
122 */ |
|
123 void InitSessionL( const RMessage2& aMessage ); |
|
124 |
|
125 |
|
126 |
|
127 /** |
|
128 * reset all conversation, start flag to EFalse |
|
129 */ |
|
130 void ResetHeaderInoformation(); |
|
131 |
|
132 |
|
133 /** |
|
134 * Externalizes all chat data |
|
135 * @param aArray, array of buffered headers.. |
|
136 * @param aSize total size of buffered messages. |
|
137 * @param aMore , still data is pending to be send |
|
138 */ |
|
139 void ExternalizeBufferedDataL(TIMCacheOperationsCode aOperationCode, |
|
140 RPointerArray<HBufC8>& aArray , |
|
141 TInt aTotalSize , |
|
142 TBool aMore = EFalse ); |
|
143 |
|
144 /** |
|
145 * Externalizes chat headers |
|
146 * @param aChangeType, event type |
|
147 * @param aMsgHeader, chat header |
|
148 * @param aMessage , chat message |
|
149 * @param aServiceId , serviceid |
|
150 */ |
|
151 void ExternalizeChatItemL( TIMCacheOperationsCode aChangeType , |
|
152 TInt aServiceId = KErrNotFound ); |
|
153 |
|
154 /** |
|
155 * Externalizes all chat header messages. |
|
156 * @param aChangeType, event type |
|
157 * @param aMsgHeader, chat header |
|
158 */ |
|
159 void SendChatListDataL( TIMCacheOperationsCode aChangeType , |
|
160 MIMCacheMessageHeader* aMsgHeader ); |
|
161 |
|
162 /** |
|
163 * send unread change notification |
|
164 * @param aMsgHeader, chat header |
|
165 * @param aMessage , chat message |
|
166 */ |
|
167 void SendUnreadChangeNotificationL(MIMCacheMessageHeader* aMsgHeader, |
|
168 CIMCacheMessageBase* aMessage ); |
|
169 |
|
170 /** |
|
171 * Externalizes single chat item. |
|
172 * @param aMsgHeader, chat header |
|
173 */ |
|
174 void ExternalizeSingleChatItemL( TIMCacheOperationsCode aChangeType, MIMCacheMessageHeader* aMsgHeader ); |
|
175 |
|
176 |
|
177 /** |
|
178 * Externalizes single chat messages. |
|
179 * @param aMsgHeader, chat header |
|
180 * @param aMessage , chat message |
|
181 */ |
|
182 void ExternalizeSingleChatDataL(TIMCacheOperationsCode aChangeType, |
|
183 MIMCacheMessageHeader* aChatHeader, |
|
184 CIMCacheMessageBase* aMessage ); |
|
185 |
|
186 /** |
|
187 * Externalizes all chat messages in a message header |
|
188 * @param aChangeType, event type |
|
189 * @param aMsgHeader, chat header |
|
190 */ |
|
191 void ExternalizeChatDataL(TIMCacheOperationsCode aChangeType ,MIMCacheMessageHeader* aChatHeader ); |
|
192 |
|
193 /** |
|
194 * write data to stream |
|
195 * @param aChatHeader, chat header |
|
196 * @param aSize total size of buffered messages. |
|
197 * @return a HBufC8 stream buffer pointer |
|
198 */ |
|
199 HBufC8* GetPackedChatItemBufferL(MIMCacheMessageHeader* aChatHeader, TInt& aSize); |
|
200 |
|
201 /** |
|
202 * write data to stream |
|
203 * @param aMsg, message |
|
204 * @param aMsgHeader, chat header |
|
205 * @param aSize total size of buffered messages. |
|
206 * @return a HBufC8 stream buffer pointer |
|
207 */ |
|
208 HBufC8* GetPackedChatDataBufferL(CIMCacheMessageBase* aMsg , |
|
209 MIMCacheMessageHeader* aActiveHeader , |
|
210 const TInt aSize); |
|
211 /** |
|
212 * do request complete |
|
213 * @param aChangeType, type of request |
|
214 */ |
|
215 // void DoRequestComplete( TIMCacheOperationsCode aChangeType ); |
|
216 private: // Data |
|
217 //owned, message completed state |
|
218 TBool iMessageCompleted; |
|
219 |
|
220 //does observer is active |
|
221 TBool iObserverActive; |
|
222 |
|
223 //msg observer |
|
224 RMessage2 iObserverMessage; |
|
225 |
|
226 // not owned, active helper |
|
227 CCacheServerActiveHelper* iHelper; |
|
228 |
|
229 // owns, pending packets to be sent to ui client |
|
230 RPointerArray<CIMCacheBufferArray> iPacketsArray; |
|
231 |
|
232 // read only right initialized |
|
233 TBool iAccessorInitialized; |
|
234 // conversation r/w initialized |
|
235 TBool iConvesationInitialized; |
|
236 |
|
237 // owns : add request fetch completed or not |
|
238 TBool iOpenChatFetchCompleted; |
|
239 |
|
240 // service id for this session |
|
241 TInt iServiceId; |
|
242 |
|
243 }; |
|
244 |
|
245 #endif // __CIMCACHESESSION_H__ |
|
246 |
|
247 |
|
248 // END OF FILE |
|
249 |