author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 09:45:25 +0300 | |
changeset 52 | 12db4185673b |
parent 44 | 36f374c67aa8 |
child 72 | 6f657153cbc5 |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2007 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: CS Session class |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// INCLUDE FILES |
|
19 |
#include <ccsconversationentry.h> |
|
20 |
#include <ccsclientconversation.h> |
|
21 |
||
22 |
#include "ccsconversationevent.h" |
|
23 |
#include "ccsdebug.h" |
|
24 |
#include "ccsserver.h" |
|
25 |
#include "ccssession.h" |
|
26 |
#include "ccsplugininterface.h" |
|
27 |
#include "ccsconversationcache.h" |
|
28 |
#include "ccscontactsresolver.h" |
|
29 |
#include "ccsconversationdeletehandler.h" |
|
30 |
#include "ccsconversationmarkreadhandler.h" |
|
31 |
||
32 |
// CONSTANTS |
|
33 |
const TInt KTinyBuffer = 256; // 256 bytes |
|
34 |
const TInt KBigBuffer = 2048; // 2K |
|
35 |
||
36 |
// ============================== MEMBER FUNCTIONS ============================ |
|
37 |
||
38 |
// ---------------------------------------------------------------------------- |
|
39 |
// CCsSession::NewL |
|
40 |
// Two Phase Construction |
|
41 |
// ---------------------------------------------------------------------------- |
|
42 |
CCsSession* CCsSession::NewL(CCsServer* aServer) |
|
43 |
{ |
|
44 |
PRINT ( _L("Enter CCsSession::NewL") ); |
|
45 |
||
46 |
CCsSession* self = new (ELeave) CCsSession(aServer); |
|
47 |
CleanupStack::PushL(self); |
|
48 |
self->ConstructL(); |
|
49 |
CleanupStack::Pop(self); // self |
|
50 |
||
51 |
PRINT ( _L("End CCsSession::NewL") ); |
|
52 |
||
53 |
return self; |
|
54 |
} |
|
55 |
||
56 |
// ---------------------------------------------------------------------------- |
|
57 |
// CCsSession::CCsSession |
|
58 |
// Construtor |
|
59 |
// ---------------------------------------------------------------------------- |
|
60 |
CCsSession::CCsSession(CCsServer* aServer) : |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
61 |
iServer(aServer), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
62 |
iDes(NULL), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
63 |
iMonitoredConversation(NULL), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
64 |
iBufferOverflow(EFalse), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
65 |
iGetConversationBufferOverflow( EFalse), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
66 |
iNotifyHandling(EFalse), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
67 |
iConversationListChangeObserver(EFalse), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
68 |
iConversationChangeObserver(EFalse), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
69 |
iCachingChangeObserver(EFalse), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
70 |
iReqCnt(1) //Let's start the event ID from 1 |
31 | 71 |
{ |
72 |
} |
|
73 |
||
74 |
// ---------------------------------------------------------------------------- |
|
75 |
// CCsSession::ConstructL |
|
76 |
// Second phase constructor |
|
77 |
// ---------------------------------------------------------------------------- |
|
78 |
void CCsSession::ConstructL() |
|
79 |
{ |
|
80 |
PRINT ( _L("Enter CCsSession::ConstructL") ); |
|
81 |
||
82 |
||
83 |
// initialize the event List |
|
84 |
iEventList = new (ELeave) RPointerArray<CCsConversationEvent> (); |
|
85 |
||
86 |
PRINT ( _L("End CCsSession::ConstructL") ); |
|
87 |
} |
|
88 |
||
89 |
// ---------------------------------------------------------------------------- |
|
90 |
// CCsSession::CCsSession |
|
91 |
// Destructor |
|
92 |
// ---------------------------------------------------------------------------- |
|
93 |
CCsSession::~CCsSession() |
|
94 |
{ |
|
95 |
PRINT ( _L("Enter CCsSession::~CCsSession") ); |
|
96 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
97 |
if ( iDes ) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
98 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
99 |
delete iDes; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
100 |
iDes = NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
101 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
102 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
103 |
if ( iEventList ) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
104 |
{ |
31 | 105 |
iEventList->ResetAndDestroy(); |
106 |
iEventList->Close(); |
|
107 |
delete iEventList; |
|
108 |
iEventList = NULL; |
|
109 |
} |
|
110 |
||
111 |
if (iMonitoredConversation) |
|
112 |
{ |
|
113 |
delete iMonitoredConversation; |
|
114 |
iMonitoredConversation = NULL; |
|
115 |
} |
|
116 |
||
117 |
PRINT ( _L("End CCsSession::~CCsSession") ); |
|
118 |
} |
|
119 |
||
120 |
// ---------------------------------------------------------------------------- |
|
121 |
// CCsSession::ServiceL |
|
122 |
// |
|
123 |
// ---------------------------------------------------------------------------- |
|
124 |
void CCsSession::ServiceL(const RMessage2& aMessage) |
|
125 |
{ |
|
126 |
TInt errStatus = KErrNone; |
|
127 |
||
128 |
// Do the service |
|
129 |
TRAP ( errStatus, DoServiceL(aMessage) ); |
|
130 |
||
131 |
// Check the error status returned |
|
132 |
if (errStatus != KErrNone) |
|
133 |
{ |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
134 |
// Free memory. |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
135 |
if(iDes) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
136 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
137 |
delete iDes; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
138 |
iDes=NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
139 |
} |
31 | 140 |
aMessage.Complete(errStatus); |
141 |
} |
|
142 |
} |
|
143 |
||
144 |
// ---------------------------------------------------------------------------- |
|
145 |
// CCsSession::DoServiceL |
|
146 |
// |
|
147 |
// ---------------------------------------------------------------------------- |
|
148 |
void CCsSession::DoServiceL(const RMessage2& aMessage) |
|
149 |
{ |
|
150 |
switch (aMessage.Function()) |
|
151 |
{ |
|
152 |
case EGetConversationList: |
|
153 |
PRINT ( _L("Received function EGetConversationList") ) |
|
154 |
GetConversationListL(aMessage); |
|
155 |
break; |
|
156 |
||
157 |
case EGetConversationUnreadList: |
|
158 |
PRINT ( _L("Received function EGetConversationUnreadList") ) |
|
159 |
GetConversationUnreadListL(aMessage); |
|
160 |
break; |
|
161 |
||
162 |
case EGetConversations: |
|
163 |
PRINT ( _L("Received function EGetConversations") ) |
|
164 |
GetConversationsL(aMessage); |
|
165 |
break; |
|
166 |
||
167 |
case EGetTotalUnreadCount: |
|
168 |
PRINT ( _L("Received function EGetTotalUnreadCount") ) |
|
169 |
GetTotalUnreadCountL(aMessage); |
|
170 |
break; |
|
171 |
||
172 |
case ERequestChangeEvent: |
|
173 |
PRINT ( _L("Received function ERequestChangeEvent") ) |
|
174 |
RequestChangeEventL(aMessage); |
|
175 |
break; |
|
176 |
||
177 |
case ERemoveChangeEvent: |
|
178 |
PRINT ( _L("Received function ERemoveChangeEvent") ) |
|
179 |
RemoveChangeEventL(aMessage); |
|
180 |
break; |
|
181 |
||
182 |
case ESetConversationListChangeObserver: |
|
183 |
PRINT ( _L("Received function ESetConversationListChangeObserver") ) |
|
184 |
SetConversationListChangeObserverL(aMessage); |
|
185 |
break; |
|
186 |
||
187 |
case EResetConversationListChangeObserver: |
|
188 |
PRINT ( _L("Received function EResetConversationListChangeObserver") ) |
|
189 |
ResetConversationListChangeObserverL(aMessage); |
|
190 |
break; |
|
191 |
||
192 |
case ESetConversationChangeObserver: |
|
193 |
PRINT ( _L("Received function ESetConversationChangeObserver") ) |
|
194 |
SetConversationChangeObserverL(aMessage); |
|
195 |
break; |
|
196 |
||
197 |
case EResetConversationChangeObserver: |
|
198 |
PRINT ( _L("Received function EResetConversationChangeObserver") ) |
|
199 |
ResetConversationChangeObserverL(aMessage); |
|
200 |
break; |
|
201 |
||
202 |
case ESetCachingStatusObserver: |
|
203 |
PRINT ( _L("Received function ESetCachingStatusObserver") ) |
|
204 |
SetCachingStatusObserverL(aMessage); |
|
205 |
break; |
|
206 |
||
207 |
case EResetCachingStatusObserver: |
|
208 |
PRINT ( _L("Received function EResetCachingStatusObserver") ) |
|
209 |
ResetCachingStatusObserverL(aMessage); |
|
210 |
break; |
|
211 |
||
212 |
case EGetCachingStatus: |
|
213 |
GetCachingStatusL(aMessage); |
|
214 |
break; |
|
215 |
||
216 |
case EShutdown: |
|
217 |
PRINT ( _L("Received function EShutdown") ) |
|
218 |
ShutdownServerL(aMessage); |
|
219 |
break; |
|
220 |
||
221 |
case EUserDeleteConversation: |
|
222 |
PRINT ( _L("Received function EDeleteConversation") ) |
|
223 |
DeleteConversationL(aMessage); |
|
224 |
break; |
|
225 |
||
226 |
case EGetConversationId: |
|
227 |
PRINT ( _L("Received function EGetConversationId") ) |
|
228 |
GetConversationIdL(aMessage); |
|
229 |
break; |
|
230 |
||
231 |
case EGetConversationIdFromAddress: |
|
232 |
PRINT ( _L("Received function EGetConversationIdFromAddress") ) |
|
233 |
GetConversationIdfromAddressL(aMessage); |
|
234 |
break; |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
235 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
236 |
case EGetConversationFromConversationId: |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
237 |
PRINT ( _L("Received function EGetConversationFromConversationId") ) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
238 |
GetConversationFromConversationIdL(aMessage); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
239 |
break; |
31 | 240 |
|
241 |
case EGetConversationFromMessageId: |
|
242 |
PRINT ( _L("Received function EGetConversationFromMessageId") ) |
|
243 |
GetConversationFromMessageIdL(aMessage); |
|
244 |
break; |
|
245 |
||
246 |
case EUserMarkReadConversation: |
|
247 |
PRINT ( _L("Received function EUserMarkReadConversation") ) |
|
248 |
MarkConversationReadL(aMessage); |
|
249 |
break; |
|
250 |
} |
|
251 |
||
252 |
return; |
|
253 |
} |
|
254 |
||
255 |
// ---------------------------------------------------------------------------- |
|
256 |
// CCsSession::ServiceError |
|
257 |
// |
|
258 |
// ---------------------------------------------------------------------------- |
|
259 |
void CCsSession::ServiceError(const RMessage2& aMessage, TInt aError) |
|
260 |
{ |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
261 |
if(iDes) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
262 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
263 |
delete iDes; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
264 |
iDes=NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
265 |
} |
31 | 266 |
aMessage.Complete(aError); |
267 |
} |
|
268 |
||
269 |
// ---------------------------------------------------------------------------- |
|
270 |
// CCsSession::GetConversationEntryListL |
|
271 |
// the function to handle the request of Listing |
|
272 |
// of recent(latest) conversation entry and |
|
273 |
// list of dispalyname for all stored conversation entry ID |
|
274 |
// ---------------------------------------------------------------------------- |
|
275 |
void CCsSession::GetConversationListL(const RMessage2& aMessage) |
|
276 |
{ |
|
277 |
PRINT ( _L("Enter CCsSession::GetConversationListL") ); |
|
278 |
PRINT_TIMESTAMP ("Enter CCsSession::GetConversationListL"); |
|
279 |
||
280 |
if (iBufferOverflow == EFalse) |
|
281 |
{ |
|
282 |
RPointerArray<CCsClientConversation>* ClientConversationList = |
|
283 |
new (ELeave) RPointerArray<CCsClientConversation> (); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
284 |
CleanupResetAndDestroyPushL(ClientConversationList); |
31 | 285 |
// get cache pointer |
286 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
287 |
||
288 |
// Call cache function to get recent conversation entry list |
|
289 |
// with dispaly name for all stored conversation entry ID |
|
290 |
cache->GetConversationListL(ClientConversationList); |
|
291 |
||
292 |
//write all list data into stream |
|
293 |
// create a new buffer for writing into stream |
|
294 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
295 |
CleanupStack::PushL(buf); |
|
296 |
||
297 |
RBufWriteStream writeStream(*buf); |
|
298 |
writeStream.PushL(); |
|
299 |
||
300 |
TInt listCount = ClientConversationList->Count(); |
|
301 |
||
302 |
if (listCount == 0) |
|
303 |
{ |
|
304 |
iConversationListChangeObserver = ETrue; |
|
305 |
} |
|
306 |
||
307 |
// write the count first |
|
308 |
writeStream.WriteUint16L(listCount); |
|
309 |
||
310 |
// now go through the list and do externalize |
|
311 |
for (int iloop = 0; iloop < listCount; iloop++) |
|
312 |
{ |
|
313 |
CCsClientConversation |
|
314 |
* ClientConversation = |
|
315 |
static_cast<CCsClientConversation*> ( (*ClientConversationList)[iloop]); |
|
316 |
//write list of ClientConversation |
|
317 |
ClientConversation->ExternalizeL(writeStream); |
|
318 |
} |
|
319 |
||
320 |
// Results are already packed in the stream |
|
321 |
writeStream.CommitL(); |
|
322 |
||
323 |
// -------------------------------------------------------------- |
|
324 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
325 |
iDes = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
326 |
TPtr8 ptr(iDes->Des()); |
31 | 327 |
buf->Read(0, ptr, buf->Size()); |
328 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
329 |
// Cleanup |
31 | 330 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
331 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
332 |
// Cleanup ClientConversationList |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
333 |
CleanupStack::PopAndDestroy(ClientConversationList); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
334 |
} |
31 | 335 |
|
336 |
TInt rcevdBufferSize = aMessage.GetDesMaxLength(1); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
337 |
TInt reqdBufferSize = iDes->Size(); |
31 | 338 |
|
339 |
PRINT1 ( _L("Received buffer size = %d"), rcevdBufferSize ); |
|
340 |
PRINT1 ( _L("Required buffer size = %d"), reqdBufferSize ); |
|
341 |
||
342 |
// If the received buffer size from Client API is less than |
|
343 |
// the required buffer size write the required buffer size |
|
344 |
// and return. |
|
345 |
if (rcevdBufferSize < reqdBufferSize) |
|
346 |
{ |
|
347 |
PRINT ( _L("In-adequate buffer received") ); |
|
348 |
PRINT ( _L("Packing the required buffer size in response") ); |
|
349 |
||
350 |
TPckgC<TInt> bufferSizePackage(reqdBufferSize); |
|
351 |
aMessage.WriteL(1, bufferSizePackage); |
|
352 |
aMessage.Complete(EGetConversationListBufferOverflow); |
|
353 |
iBufferOverflow = ETrue; |
|
354 |
} |
|
355 |
else |
|
356 |
{ |
|
357 |
PRINT ( _L("Adequate buffer received") ); |
|
358 |
PRINT ( _L("Packing the results in response") ) |
|
359 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
360 |
aMessage.Write(1, *iDes); |
31 | 361 |
aMessage.Complete(EGetConversationListOperationComplete); |
362 |
iBufferOverflow = EFalse; |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
363 |
delete iDes; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
364 |
iDes = NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
365 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
366 |
|
31 | 367 |
PRINT_TIMESTAMP ("End CCsSession::GetConversationListL"); |
368 |
PRINT ( _L("End CCsSession::GetConversationListL") ); |
|
369 |
} |
|
370 |
||
371 |
// ---------------------------------------------------------------------------- |
|
372 |
// CCsSession::GetConversationUnreadListL |
|
373 |
// the function to handle the request of Listing |
|
374 |
// of recent(latest) unread conversation entry and |
|
375 |
// list of dispalyname for all stored conversation entry ID |
|
376 |
// ---------------------------------------------------------------------------- |
|
377 |
void CCsSession::GetConversationUnreadListL(const RMessage2& aMessage) |
|
378 |
{ |
|
379 |
PRINT ( _L("Enter CCsSession::GetConversationUnreadListL") ); |
|
380 |
PRINT_TIMESTAMP ("Enter CCsSession::GetConversationUnreadListL"); |
|
381 |
||
382 |
if (iBufferOverflow == EFalse) |
|
383 |
{ |
|
384 |
RPointerArray<CCsClientConversation>* ClientConversationList = |
|
385 |
new (ELeave) RPointerArray<CCsClientConversation> (); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
386 |
CleanupResetAndDestroyPushL(ClientConversationList); |
31 | 387 |
// get cache pointer |
388 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
389 |
||
390 |
// Call cache function to get recent conversation entry list |
|
391 |
// with dispaly name for all stored conversation entry ID |
|
392 |
cache->GetConversationUnreadListL(ClientConversationList); |
|
393 |
||
394 |
//write all list data into stream |
|
395 |
// create a new buffer for writing into stream |
|
396 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
397 |
CleanupStack::PushL(buf); |
|
398 |
||
399 |
RBufWriteStream writeStream(*buf); |
|
400 |
writeStream.PushL(); |
|
401 |
||
402 |
TInt listCount = ClientConversationList->Count(); |
|
403 |
||
404 |
if (listCount == 0) |
|
405 |
{ |
|
406 |
iConversationListChangeObserver = ETrue; |
|
407 |
} |
|
408 |
||
409 |
// write the count first |
|
410 |
writeStream.WriteUint16L(listCount); |
|
411 |
||
412 |
// now go through the list and do externalize |
|
413 |
for (int iloop=0 ; iloop < listCount ; iloop++) |
|
414 |
{ |
|
415 |
CCsClientConversation* ClientConversation = |
|
416 |
static_cast<CCsClientConversation*>((*ClientConversationList)[iloop]); |
|
417 |
//write list of ClientConversation |
|
418 |
ClientConversation->ExternalizeL(writeStream); |
|
419 |
} |
|
420 |
||
421 |
// Results are already packed in the stream |
|
422 |
writeStream.CommitL(); |
|
423 |
||
424 |
// -------------------------------------------------------------- |
|
425 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
426 |
iDes = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
427 |
TPtr8 ptr(iDes->Des()); |
31 | 428 |
buf->Read(0, ptr, buf->Size()); |
429 |
||
430 |
// cleanup |
|
431 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
432 |
CleanupStack::PopAndDestroy(ClientConversationList); |
31 | 433 |
|
434 |
} |
|
435 |
||
436 |
TInt rcevdBufferSize = aMessage.GetDesMaxLength(1); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
437 |
TInt reqdBufferSize = iDes->Size(); |
31 | 438 |
|
439 |
PRINT1 ( _L("Received buffer size = %d"), rcevdBufferSize ); |
|
440 |
PRINT1 ( _L("Required buffer size = %d"), reqdBufferSize ); |
|
441 |
||
442 |
if ( rcevdBufferSize < reqdBufferSize ) |
|
443 |
{ |
|
444 |
PRINT ( _L("In-adequate buffer received") ); |
|
445 |
PRINT ( _L("Packing the required buffer size in response") ); |
|
446 |
||
447 |
TPckgC<TInt> overflowPackage(ETrue); |
|
448 |
aMessage.WriteL(0, overflowPackage); |
|
449 |
TPckgC<TInt> bufferSizePackage(reqdBufferSize); |
|
450 |
aMessage.WriteL(1, bufferSizePackage); |
|
451 |
aMessage.Complete(KErrNone); |
|
452 |
iBufferOverflow = ETrue; |
|
453 |
} |
|
454 |
else |
|
455 |
{ |
|
456 |
PRINT ( _L("Adequate buffer received") ); |
|
457 |
PRINT ( _L("Packing the results in response") ) |
|
458 |
||
459 |
TPckgC<TInt> overflowPackage(EFalse); |
|
460 |
aMessage.WriteL(0, overflowPackage); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
461 |
aMessage.Write(1, *iDes); |
31 | 462 |
aMessage.Complete(KErrNone); |
463 |
iBufferOverflow = EFalse; |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
464 |
delete iDes; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
465 |
iDes = NULL; |
31 | 466 |
} |
467 |
||
468 |
PRINT_TIMESTAMP ("End CCsSession::GetConversationUnreadListL"); |
|
469 |
PRINT ( _L("End CCsSession::GetConversationUnreadListL") ); |
|
470 |
} |
|
471 |
||
472 |
// ---------------------------------------------------------------------------- |
|
473 |
// CCsSession::GetConversationsL |
|
474 |
// the function to handle the request |
|
475 |
// of conversation entry list for one conversation entry ID |
|
476 |
// ---------------------------------------------------------------------------- |
|
477 |
void CCsSession::GetConversationsL(const RMessage2& aMessage) |
|
478 |
{ |
|
479 |
PRINT ( _L("Enter CCsSession::GetConversationsL") ); |
|
480 |
||
481 |
if (iGetConversationBufferOverflow == EFalse) |
|
482 |
{ |
|
483 |
// Read Contact from the message |
|
484 |
HBufC8* buffer = HBufC8::NewLC(KBigBuffer); |
|
485 |
||
486 |
TPtr8 bufferPtr(buffer->Des()); |
|
487 |
aMessage.ReadL(0, bufferPtr); |
|
488 |
||
489 |
// Stream over the buffer |
|
490 |
RDesReadStream stream(bufferPtr); |
|
491 |
stream.PushL(); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
492 |
|
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
493 |
//Read known index and page size |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
494 |
TInt knownIndex = stream.ReadInt32L(); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
495 |
TInt pageSize = stream.ReadInt32L(); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
496 |
|
31 | 497 |
// get cache pointer |
498 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
499 |
||
500 |
// read the Client Conversation consist of Entry Id |
|
501 |
CCsClientConversation* ClientConversation = |
|
502 |
CCsClientConversation::NewL(); |
|
503 |
CleanupStack::PushL(ClientConversation); |
|
504 |
ClientConversation->InternalizeL(stream); |
|
505 |
CleanupStack::Pop(ClientConversation); |
|
506 |
CleanupStack::PopAndDestroy(2, buffer);//stream, buffer |
|
507 |
||
508 |
CleanupStack::PushL(ClientConversation); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
509 |
RPointerArray<CCsConversationEntry>* conversationEntryList= |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
510 |
new (ELeave) RPointerArray<CCsConversationEntry>(10); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
511 |
CleanupResetAndDestroyPushL(conversationEntryList); |
31 | 512 |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
513 |
// get conversation entry list for given ClientConversation |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
514 |
TInt totalCount(0); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
515 |
cache->GetConversationsL (ClientConversation, |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
516 |
conversationEntryList, |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
517 |
knownIndex, |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
518 |
pageSize, |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
519 |
totalCount); |
31 | 520 |
|
521 |
// create a new buffer for writing into stream |
|
522 |
// write all list data into stream |
|
523 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
524 |
CleanupStack::PushL(buf); |
|
525 |
||
526 |
RBufWriteStream writeStream(*buf); |
|
527 |
writeStream.PushL(); |
|
528 |
||
529 |
TInt ItemCount = conversationEntryList->Count(); |
|
530 |
//write recent conversation entry list |
|
531 |
writeStream.WriteInt32L(ItemCount); |
|
52
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
532 |
|
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
533 |
//Write total count in the stream to update UI |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
534 |
writeStream.WriteInt32L(totalCount); |
12db4185673b
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
535 |
|
31 | 536 |
// Write the conversation entry |
537 |
for (TInt iloop = 0; iloop < ItemCount; iloop++) |
|
538 |
{ |
|
539 |
CCsConversationEntry |
|
540 |
* entry = |
|
541 |
static_cast<CCsConversationEntry*> ( (*conversationEntryList)[iloop]); |
|
542 |
entry->ExternalizeL(writeStream); |
|
543 |
} |
|
544 |
||
545 |
// Results are already packed in the stream |
|
546 |
writeStream.CommitL(); |
|
547 |
||
548 |
// -------------------------------------------------------------- |
|
549 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
550 |
iDes = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
551 |
TPtr8 ptr(iDes->Des()); |
31 | 552 |
buf->Read(0, ptr, buf->Size()); |
553 |
||
554 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
555 |
|
31 | 556 |
// Cleanup |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
557 |
CleanupStack::PopAndDestroy(conversationEntryList); |
31 | 558 |
CleanupStack::PopAndDestroy(ClientConversation); |
559 |
} |
|
560 |
||
561 |
TInt rcevdBufferSize = aMessage.GetDesMaxLength(1); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
562 |
TInt reqdBufferSize = iDes->Size(); |
31 | 563 |
|
564 |
PRINT1 ( _L("Received buffer size = %d"), rcevdBufferSize ); |
|
565 |
PRINT1 ( _L("Required buffer size = %d"), reqdBufferSize ); |
|
566 |
||
567 |
// If the received buffer size from Client API is less than |
|
568 |
// the required buffer size write the required buffer size |
|
569 |
if (rcevdBufferSize < reqdBufferSize) |
|
570 |
{ |
|
571 |
PRINT ( _L("In-adequate buffer received") ); |
|
572 |
PRINT ( _L("Packing the required buffer size in response") ); |
|
573 |
||
574 |
TPckgC<TInt> bufferSizePackage(reqdBufferSize); |
|
575 |
aMessage.WriteL(1, bufferSizePackage); |
|
576 |
aMessage.Complete(EGetConversationBufferOverflow); |
|
577 |
iGetConversationBufferOverflow = ETrue; |
|
578 |
} |
|
579 |
else |
|
580 |
{ |
|
581 |
PRINT ( _L("Adequate buffer received") ); |
|
582 |
PRINT ( _L("Packing the results in response") ) |
|
583 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
584 |
aMessage.Write(1, *iDes); |
31 | 585 |
aMessage.Complete(EGetConversationOperationComplete); |
586 |
iGetConversationBufferOverflow = EFalse; |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
587 |
delete iDes; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
588 |
iDes = NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
589 |
} |
31 | 590 |
|
591 |
PRINT ( _L("End CCsSession::GetConversationsL") ); |
|
592 |
} |
|
593 |
||
594 |
// ---------------------------------------------------------------------------- |
|
595 |
// CCsSession::ShutdownServerL |
|
596 |
// Stops the scheduler |
|
597 |
// ---------------------------------------------------------------------------- |
|
598 |
void CCsSession::ShutdownServerL(const RMessage2& aMessage) |
|
599 |
{ |
|
600 |
aMessage.Complete(KErrNone); |
|
601 |
CActiveScheduler::Stop(); |
|
602 |
||
603 |
PRINT ( _L("CCsSession::ShutdownServerL - Server ShutDown") ); |
|
604 |
} |
|
605 |
||
606 |
// ---------------------------------------------------------------------------- |
|
607 |
// CCsSession::HandleNewConversationListEventL |
|
608 |
// Notify client about new conversation event |
|
609 |
// ---------------------------------------------------------------------------- |
|
610 |
void CCsSession::HandleNewConversationListEventL( |
|
611 |
CCsClientConversation* aClientConversation) |
|
612 |
{ |
|
613 |
PRINT ( _L("Enter CCsSession::HandleNewConversationListEventL") ); |
|
614 |
||
615 |
if (!iConversationListChangeObserver) |
|
616 |
return; |
|
617 |
||
618 |
if (! (iNotifyHandling)) |
|
619 |
{ |
|
620 |
//append in notify list |
|
621 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
622 |
CleanupStack::PushL(conversationEvent); |
|
623 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
624 |
conversationEvent->SetEvent(KConversationListEventNew); |
|
625 |
iEventList->AppendL(conversationEvent); |
|
626 |
CleanupStack::Pop(conversationEvent); |
|
627 |
} |
|
628 |
else |
|
629 |
{ |
|
630 |
// create a new buffer for writing into stream |
|
631 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
632 |
CleanupStack::PushL(buf); |
|
633 |
||
634 |
RBufWriteStream writeStream(*buf); |
|
635 |
writeStream.PushL(); |
|
636 |
||
637 |
//externalize ClientConversation |
|
638 |
aClientConversation->ExternalizeL(writeStream); |
|
639 |
||
640 |
// Results are already packed in the stream |
|
641 |
writeStream.CommitL(); |
|
642 |
||
643 |
// -------------------------------------------------------------- |
|
644 |
// Create a heap descriptor from the buffer |
|
645 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
646 |
TPtr8 ptr(notifyDes->Des()); |
|
647 |
buf->Read(0, ptr, buf->Size()); |
|
648 |
||
649 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
650 |
iAsyncReqRMessage.Complete(EAddConversationListEvent); |
|
651 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
|
652 |
iNotifyHandling = EFalse; |
|
653 |
} |
|
654 |
||
655 |
PRINT ( _L("End CCsSession::HandleNewConversationListEventL") ); |
|
656 |
} |
|
657 |
||
658 |
// ---------------------------------------------------------------------------- |
|
659 |
// CCsSession::HandleDeleteConversationListEventL |
|
660 |
// Notify client about delete conversation event |
|
661 |
// ---------------------------------------------------------------------------- |
|
662 |
void CCsSession::HandleDeleteConversationListEventL( |
|
663 |
CCsClientConversation* aClientConversation) |
|
664 |
{ |
|
665 |
PRINT ( _L("Enter CCsSession::HandleDeleteConversationListEventL") ); |
|
666 |
||
667 |
if (!iConversationListChangeObserver) |
|
668 |
return; |
|
669 |
||
670 |
if (! (iNotifyHandling)) |
|
671 |
{ |
|
672 |
//append in notify list |
|
673 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
674 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
675 |
CleanupStack::PushL(conversationEvent); |
|
676 |
conversationEvent->SetEvent(KConversationListEventDelete); |
|
677 |
iEventList->AppendL(conversationEvent); |
|
678 |
CleanupStack::Pop(conversationEvent); |
|
679 |
} |
|
680 |
else |
|
681 |
{ |
|
682 |
// create a new buffer for writing into stream |
|
683 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
684 |
CleanupStack::PushL(buf); |
|
685 |
||
686 |
RBufWriteStream writeStream(*buf); |
|
687 |
writeStream.PushL(); |
|
688 |
||
689 |
//externalize ClientConversation |
|
690 |
aClientConversation->ExternalizeL(writeStream); |
|
691 |
||
692 |
// Results are already packed in the stream |
|
693 |
writeStream.CommitL(); |
|
694 |
||
695 |
// -------------------------------------------------------------- |
|
696 |
// Create a heap descriptor from the buffer |
|
697 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
698 |
TPtr8 ptr(notifyDes->Des()); |
|
699 |
buf->Read(0, ptr, buf->Size()); |
|
700 |
||
701 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
702 |
iAsyncReqRMessage.Complete(EDeleteConversationListEvent); |
|
703 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
|
704 |
iNotifyHandling = EFalse; |
|
705 |
} |
|
706 |
||
707 |
PRINT ( _L("End CCsSession::HandleDeleteConversationListEventL") ); |
|
708 |
} |
|
709 |
||
710 |
// ---------------------------------------------------------------------------- |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
711 |
// CCsSession::HandlePartialDeleteConversationListEventL |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
712 |
// Notify client about partial delete conversation event |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
713 |
// ---------------------------------------------------------------------------- |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
714 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
715 |
void CCsSession::HandlePartialDeleteConversationListEvent( |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
716 |
CCsClientConversation* aClientConversation) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
717 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
718 |
PRINT ( _L("Enter CCsSession::HandlePartialDeleteConversationListEvent") ); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
719 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
720 |
if (!iConversationListChangeObserver) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
721 |
return; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
722 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
723 |
if (! (iNotifyHandling)) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
724 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
725 |
//append in notify list |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
726 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
727 |
conversationEvent->SetClientConversationL(*aClientConversation); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
728 |
CleanupStack::PushL(conversationEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
729 |
conversationEvent->SetEvent(KConversationListEventPartialDelete); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
730 |
iEventList->AppendL(conversationEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
731 |
CleanupStack::Pop(conversationEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
732 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
733 |
else |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
734 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
735 |
// create a new buffer for writing into stream |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
736 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
737 |
CleanupStack::PushL(buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
738 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
739 |
RBufWriteStream writeStream(*buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
740 |
writeStream.PushL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
741 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
742 |
//externalize ClientConversation |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
743 |
aClientConversation->ExternalizeL(writeStream); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
744 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
745 |
// Results are already packed in the stream |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
746 |
writeStream.CommitL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
747 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
748 |
// -------------------------------------------------------------- |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
749 |
// Create a heap descriptor from the buffer |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
750 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
751 |
TPtr8 ptr(notifyDes->Des()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
752 |
buf->Read(0, ptr, buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
753 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
754 |
iAsyncReqRMessage.Write(1, *notifyDes); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
755 |
iAsyncReqRMessage.Complete(EPartialDeleteConversationListEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
756 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
757 |
iNotifyHandling = EFalse; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
758 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
759 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
760 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
761 |
// ---------------------------------------------------------------------------- |
31 | 762 |
// CCsSession::HandleModifyConversationListEventL |
763 |
// Notify client about update conversation event |
|
764 |
// ---------------------------------------------------------------------------- |
|
765 |
void CCsSession::HandleModifyConversationListEventL( |
|
766 |
CCsClientConversation* aClientConversation) |
|
767 |
{ |
|
768 |
PRINT ( _L("Enter CCsSession::HandleModifyConversationListEventL") ); |
|
769 |
||
770 |
if (!iConversationListChangeObserver) |
|
771 |
return; |
|
772 |
||
773 |
if (! (iNotifyHandling)) |
|
774 |
{ |
|
775 |
//append in notify list |
|
776 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
777 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
778 |
CleanupStack::PushL(conversationEvent); |
|
779 |
conversationEvent->SetEvent(KConversationListEventUpdate); |
|
780 |
iEventList->AppendL(conversationEvent); |
|
781 |
CleanupStack::Pop(conversationEvent); |
|
782 |
} |
|
783 |
else |
|
784 |
{ |
|
785 |
// create a new buffer for writing into stream |
|
786 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
787 |
CleanupStack::PushL(buf); |
|
788 |
||
789 |
RBufWriteStream writeStream(*buf); |
|
790 |
writeStream.PushL(); |
|
791 |
||
792 |
//externalize ClientConversation |
|
793 |
aClientConversation->ExternalizeL(writeStream); |
|
794 |
||
795 |
// Results are already packed in the stream |
|
796 |
writeStream.CommitL(); |
|
797 |
// -------------------------------------------------------------- |
|
798 |
||
799 |
// Create a heap descriptor from the buffer |
|
800 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
801 |
TPtr8 ptr(notifyDes->Des()); |
|
802 |
buf->Read(0, ptr, buf->Size()); |
|
803 |
||
804 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
805 |
iAsyncReqRMessage.Complete(EModifyConversationListEvent); |
|
806 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
|
807 |
iNotifyHandling = EFalse; |
|
808 |
} |
|
809 |
||
810 |
PRINT ( _L("End CCsSession::HandleModifyConversationListEventL") ); |
|
811 |
} |
|
812 |
||
813 |
// ---------------------------------------------------------------------------- |
|
814 |
// CCsSession::RequestChangeEventL |
|
815 |
// the function to register for cache change event notification |
|
816 |
// ---------------------------------------------------------------------------- |
|
817 |
void CCsSession::RequestChangeEventL(const RMessage2& aMessage) |
|
818 |
{ |
|
819 |
iAsyncReqRMessage = aMessage; |
|
820 |
iNotifyHandling = ETrue; |
|
821 |
||
822 |
if (iEventList->Count() > 0) |
|
823 |
{ |
|
824 |
CCsConversationEvent* conversationEvent = (*iEventList)[0]; |
|
825 |
||
826 |
// check if the reqCnt matches with the latest arrived count |
|
827 |
// then its not a duplicate, delete the top event |
|
828 |
if (iReqCnt == aMessage.Int2()) |
|
829 |
{ |
|
830 |
iEventList->Remove(0); |
|
831 |
delete conversationEvent; |
|
832 |
||
833 |
if (iEventList->Count() > 0) |
|
834 |
{ |
|
835 |
// increment the count |
|
836 |
iReqCnt++; |
|
837 |
conversationEvent = (*iEventList)[0]; |
|
838 |
} |
|
839 |
else |
|
840 |
{ |
|
841 |
// no more pending events, simply return |
|
842 |
return; |
|
843 |
} |
|
844 |
} |
|
845 |
||
846 |
HBufC8* buffer = HBufC8::NewLC(4); |
|
847 |
TPtr8 cntPtr(buffer->Des()); |
|
848 |
_LIT8(KFormat,"%d"); |
|
849 |
cntPtr.Format(KFormat, iReqCnt); |
|
850 |
iAsyncReqRMessage.Write(0, *buffer); |
|
851 |
||
852 |
// create a new buffer for writing into stream |
|
853 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
854 |
CleanupStack::PushL(buf); |
|
855 |
||
856 |
RBufWriteStream writeStream(*buf); |
|
857 |
writeStream.PushL(); |
|
858 |
||
859 |
// Externalize ClientConversation |
|
860 |
if (conversationEvent->ClientConversation()) |
|
861 |
conversationEvent->ClientConversation()->ExternalizeL(writeStream); |
|
862 |
||
863 |
// Results are already packed in the stream |
|
864 |
writeStream.CommitL(); |
|
865 |
||
866 |
// -------------------------------------------------------------- |
|
867 |
// Create a heap descriptor from the buffer |
|
868 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
869 |
TPtr8 ptr(notifyDes->Des()); |
|
870 |
buf->Read(0, ptr, buf->Size()); |
|
871 |
||
872 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
873 |
||
874 |
NotifyClient(conversationEvent); |
|
875 |
||
876 |
CleanupStack::PopAndDestroy(4, buffer); |
|
877 |
// notifyDes, writestream, buf, buffer |
|
878 |
iNotifyHandling = EFalse; |
|
879 |
} |
|
880 |
} |
|
881 |
||
882 |
// ---------------------------------------------------------------------------- |
|
883 |
// CCsSession::RemoveChangeEventL |
|
884 |
// Deregister the cache change event notification |
|
885 |
// ---------------------------------------------------------------------------- |
|
886 |
void CCsSession::RemoveChangeEventL(const RMessage2& aMessage) |
|
887 |
{ |
|
888 |
if (! (iNotifyHandling)) |
|
889 |
{ |
|
890 |
// complete message with aMessage |
|
891 |
aMessage.Complete(KErrNone); |
|
892 |
} |
|
893 |
else |
|
894 |
{ |
|
895 |
iAsyncReqRMessage.Complete(KErrCancel); |
|
896 |
iNotifyHandling = EFalse; |
|
897 |
// complete message with aMessage |
|
898 |
aMessage.Complete(KErrNone); |
|
899 |
} |
|
900 |
} |
|
901 |
||
902 |
// ---------------------------------------------------------------------------- |
|
903 |
// CCsSession::GetCachingStatusL |
|
904 |
// the function to request conversation server |
|
905 |
// to get caching status. |
|
906 |
// ---------------------------------------------------------------------------- |
|
907 |
void CCsSession::GetCachingStatusL(const RMessage2& aMessage) |
|
908 |
{ |
|
909 |
PRINT ( _L("Enter CCsSession::GetCachingStatusL") ); |
|
910 |
||
911 |
// create a new buffer for writing into stream |
|
912 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
913 |
||
914 |
CleanupStack::PushL(buf); |
|
915 |
RBufWriteStream writeStream(*buf); |
|
916 |
writeStream.PushL(); |
|
917 |
||
918 |
// Externalize caching status |
|
919 |
writeStream.WriteUint8L(iServer->GetCachingStatus()); |
|
920 |
||
921 |
// Results are already packed in the stream |
|
922 |
writeStream.CommitL(); |
|
923 |
// -------------------------------------------------------------- |
|
924 |
||
925 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
926 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 927 |
TPtr8 ptr(des->Des()); |
928 |
buf->Read(0, ptr, buf->Size()); |
|
929 |
||
930 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
931 |
||
932 |
aMessage.Write(1, *des); |
|
933 |
aMessage.Complete(KErrNone); |
|
934 |
delete des; |
|
935 |
||
936 |
PRINT ( _L("End CCsSession::GetCachingStatusL") ); |
|
937 |
} |
|
938 |
||
939 |
// ---------------------------------------------------------------------------- |
|
940 |
// CCsSession::GetTotalUnreadCountL |
|
941 |
// Gets total unread conversation entries. |
|
942 |
// ---------------------------------------------------------------------------- |
|
943 |
void CCsSession::GetTotalUnreadCountL(const RMessage2& aMessage) |
|
944 |
{ |
|
945 |
PRINT ( _L("Enter CCsSession::GetTotalUnreadCountL") ); |
|
946 |
||
947 |
// create a new buffer for writing into stream |
|
948 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
949 |
||
950 |
CleanupStack::PushL(buf); |
|
951 |
RBufWriteStream writeStream(*buf); |
|
952 |
writeStream.PushL(); |
|
953 |
||
954 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
955 |
||
956 |
// Externalize caching status |
|
957 |
writeStream.WriteUint32L(cache->GetTotalUnreadCount()); |
|
958 |
||
959 |
// Results are already packed in the stream |
|
960 |
writeStream.CommitL(); |
|
961 |
// -------------------------------------------------------------- |
|
962 |
||
963 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
964 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 965 |
TPtr8 ptr(des->Des()); |
966 |
buf->Read(0, ptr, buf->Size()); |
|
967 |
||
968 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
969 |
||
970 |
aMessage.Write(1, *des); |
|
971 |
aMessage.Complete(KErrNone); |
|
972 |
delete des; |
|
973 |
||
974 |
PRINT ( _L("End CCsSession::GetTotalUnreadCountL") ); |
|
975 |
} |
|
976 |
||
977 |
// ---------------------------------------------------------------------------- |
|
978 |
// CCsSession::SetConversationListChangeObserverL |
|
979 |
// the function to request conversation server |
|
980 |
// to set ConversationListChangeObserver. |
|
981 |
// ---------------------------------------------------------------------------- |
|
982 |
void CCsSession::SetConversationListChangeObserverL(const RMessage2& aMessage) |
|
983 |
{ |
|
984 |
iConversationListChangeObserver = ETrue; |
|
985 |
aMessage.Complete(KErrNone); |
|
986 |
} |
|
987 |
||
988 |
// ---------------------------------------------------------------------------- |
|
989 |
// CCsSession::ResetConversationListChangeObserverL |
|
990 |
// the function to request conversation server |
|
991 |
// to reset ConversationListChangeObserver. |
|
992 |
// ---------------------------------------------------------------------------- |
|
993 |
void CCsSession::ResetConversationListChangeObserverL(const RMessage2& aMessage) |
|
994 |
{ |
|
995 |
iConversationListChangeObserver = EFalse; |
|
996 |
aMessage.Complete(KErrNone); |
|
997 |
} |
|
998 |
||
999 |
// ---------------------------------------------------------------------------- |
|
1000 |
// CCsSession::SetConversationChangeObserverL |
|
1001 |
// the function to request conversation server |
|
1002 |
// to set ConversationChangeObserver. |
|
1003 |
// ---------------------------------------------------------------------------- |
|
1004 |
void CCsSession::SetConversationChangeObserverL(const RMessage2& aMessage) |
|
1005 |
{ |
|
1006 |
// Read Contact from the message |
|
1007 |
HBufC8* buffer = HBufC8::NewLC(KBigBuffer); |
|
1008 |
||
1009 |
TPtr8 bufferPtr(buffer->Des()); |
|
1010 |
aMessage.ReadL(0, bufferPtr); |
|
1011 |
||
1012 |
// Stream over the buffer |
|
1013 |
RDesReadStream stream(bufferPtr); |
|
1014 |
stream.PushL(); |
|
1015 |
||
1016 |
// Get the client conversation |
|
1017 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
|
1018 |
CleanupStack::PushL(clientConversation); |
|
1019 |
clientConversation->InternalizeL(stream); |
|
1020 |
CleanupStack::Pop(clientConversation); |
|
1021 |
||
1022 |
CleanupStack::PopAndDestroy(2, buffer);//stream, buffer |
|
1023 |
||
1024 |
iMonitoredConversation = clientConversation; |
|
1025 |
iConversationChangeObserver = ETrue; |
|
1026 |
||
1027 |
aMessage.Complete(KErrNone); |
|
1028 |
} |
|
1029 |
||
1030 |
// ---------------------------------------------------------------------------- |
|
1031 |
// CCsSession::ResetConversationChangeObserverL |
|
1032 |
// the function to request conversation server |
|
1033 |
// to reset ConversationChangeObserver. |
|
1034 |
// ---------------------------------------------------------------------------- |
|
1035 |
void CCsSession::ResetConversationChangeObserverL(const RMessage2& aMessage) |
|
1036 |
{ |
|
1037 |
// Read Contact from the message |
|
1038 |
HBufC8* buffer = HBufC8::NewLC(KBigBuffer); |
|
1039 |
||
1040 |
TPtr8 bufferPtr(buffer->Des()); |
|
1041 |
aMessage.ReadL(0, bufferPtr); |
|
1042 |
||
1043 |
// Stream over the buffer |
|
1044 |
RDesReadStream stream(bufferPtr); |
|
1045 |
stream.PushL(); |
|
1046 |
||
1047 |
// Read the client conversation |
|
1048 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
|
1049 |
CleanupStack::PushL(clientConversation); |
|
1050 |
clientConversation->InternalizeL(stream); |
|
1051 |
CleanupStack::Pop(clientConversation); |
|
1052 |
||
1053 |
CleanupStack::PopAndDestroy(2, buffer); //stream, buffer |
|
1054 |
||
1055 |
if (iMonitoredConversation) |
|
1056 |
{ |
|
1057 |
delete iMonitoredConversation; |
|
1058 |
iMonitoredConversation = NULL; |
|
1059 |
iConversationChangeObserver = EFalse; |
|
1060 |
} |
|
1061 |
||
1062 |
delete clientConversation; |
|
1063 |
||
1064 |
aMessage.Complete(KErrNone); |
|
1065 |
} |
|
1066 |
||
1067 |
// ---------------------------------------------------------------------------- |
|
1068 |
// CCsSession::SetCachingStatusObserverL |
|
1069 |
// the function to request conversation server |
|
1070 |
// to set caching status observer flag. |
|
1071 |
// ---------------------------------------------------------------------------- |
|
1072 |
void CCsSession::SetCachingStatusObserverL(const RMessage2& aMessage) |
|
1073 |
{ |
|
1074 |
iCachingChangeObserver = ETrue; |
|
1075 |
aMessage.Complete(KErrNone); |
|
1076 |
} |
|
1077 |
||
1078 |
// ---------------------------------------------------------------------------- |
|
1079 |
// CCsSession::ResetCachingStatusObserverL |
|
1080 |
// the function to request conversation server |
|
1081 |
// to reset caching status observer flag. |
|
1082 |
// ---------------------------------------------------------------------------- |
|
1083 |
void CCsSession::ResetCachingStatusObserverL(const RMessage2& aMessage) |
|
1084 |
{ |
|
1085 |
iCachingChangeObserver = EFalse; |
|
1086 |
aMessage.Complete(KErrNone); |
|
1087 |
} |
|
1088 |
||
1089 |
// ---------------------------------------------------------------------------- |
|
1090 |
// CCsSession::HandleNewConversationEventL |
|
1091 |
// the function to handles the new conversation event received from cache |
|
1092 |
// asynchronously |
|
1093 |
// ---------------------------------------------------------------------------- |
|
1094 |
void CCsSession::HandleNewConversationEventL( |
|
1095 |
CCsClientConversation* aClientConversation) |
|
1096 |
{ |
|
1097 |
PRINT ( _L("Enter CCsSession::HandleNewConversationEventL") ); |
|
1098 |
||
1099 |
if (!iConversationChangeObserver) |
|
1100 |
return; |
|
1101 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1102 |
//this is check to send notif to clients for a new message |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1103 |
//1. if the client is subscribed with contact id ==> then send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1104 |
//2. if the client is subscribed with conv id ---> then send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1105 |
// else dont send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1106 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1107 |
if ((aClientConversation->GetContactId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1108 |
iMonitoredConversation->GetContactId() && |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1109 |
aClientConversation->GetContactId() != -1) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1110 |
||(aClientConversation->GetConversationEntryId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1111 |
iMonitoredConversation->GetConversationEntryId())) |
31 | 1112 |
{ |
1113 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1114 |
if (! (iNotifyHandling)) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1115 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1116 |
//append in notify list |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1117 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1118 |
CleanupStack::PushL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1119 |
conversationEvent->SetClientConversationL(*aClientConversation); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1120 |
conversationEvent->SetEvent(KConversationEventNew); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1121 |
iEventList->AppendL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1122 |
CleanupStack::Pop(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1123 |
} |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1124 |
else |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1125 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1126 |
// create a new buffer for writing into stream |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1127 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1128 |
CleanupStack::PushL(buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1129 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1130 |
RBufWriteStream writeStream(*buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1131 |
writeStream.PushL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1132 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1133 |
//externalize ClientConversation |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1134 |
aClientConversation->ExternalizeL(writeStream); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1135 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1136 |
// Results are already packed in the stream |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1137 |
writeStream.CommitL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1138 |
// -------------------------------------------------------------- |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1139 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1140 |
// Create a heap descriptor from the buffer |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1141 |
HBufC8* des = HBufC8::NewLC(buf->Size()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1142 |
CleanupStack::Pop(des); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1143 |
TPtr8 ptr(des->Des()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1144 |
buf->Read(0, ptr, buf->Size()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1145 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1146 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1147 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1148 |
iAsyncReqRMessage.Write(1, *des); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1149 |
iAsyncReqRMessage.Complete(EAddConversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1150 |
delete des; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1151 |
iNotifyHandling = EFalse; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1152 |
} |
31 | 1153 |
} |
1154 |
PRINT ( _L("End CCsSession::HandleNewConversationEventL") ); |
|
1155 |
} |
|
1156 |
||
1157 |
// ---------------------------------------------------------------------------- |
|
1158 |
// CCsSession::HandleDeleteConversationEventL |
|
1159 |
// the function to handles the delete conversation event received from cache |
|
1160 |
// asynchronously |
|
1161 |
// ---------------------------------------------------------------------------- |
|
1162 |
void CCsSession::HandleDeleteConversationEventL( |
|
1163 |
CCsClientConversation* aClientConversation) |
|
1164 |
{ |
|
1165 |
PRINT ( _L("Enter CCsSession::HandleDeleteConversationEventL") ); |
|
1166 |
||
1167 |
if (!iConversationChangeObserver) |
|
1168 |
return; |
|
1169 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1170 |
if ((aClientConversation->GetContactId() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1171 |
!= iMonitoredConversation->GetContactId()) && |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1172 |
(aClientConversation->GetConversationEntryId() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1173 |
!= iMonitoredConversation->GetConversationEntryId()) |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1174 |
) |
31 | 1175 |
return; |
1176 |
||
1177 |
if (! (iNotifyHandling)) |
|
1178 |
{ |
|
1179 |
//append in notify list |
|
1180 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
1181 |
CleanupStack::PushL(conversationEvent); |
|
1182 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
1183 |
conversationEvent->SetEvent(KConversationEventDelete); |
|
1184 |
iEventList->AppendL(conversationEvent); |
|
1185 |
CleanupStack::Pop(conversationEvent); |
|
1186 |
} |
|
1187 |
else |
|
1188 |
{ |
|
1189 |
// create a new buffer for writing into stream |
|
1190 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
1191 |
CleanupStack::PushL(buf); |
|
1192 |
||
1193 |
RBufWriteStream writeStream(*buf); |
|
1194 |
writeStream.PushL(); |
|
1195 |
||
1196 |
//externalize ClientConversation |
|
1197 |
aClientConversation->ExternalizeL(writeStream); |
|
1198 |
||
1199 |
// Results are already packed in the stream |
|
1200 |
writeStream.CommitL(); |
|
1201 |
// -------------------------------------------------------------- |
|
1202 |
||
1203 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1204 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1205 |
|
31 | 1206 |
TPtr8 ptr(des->Des()); |
1207 |
buf->Read(0, ptr, buf->Size()); |
|
1208 |
||
1209 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
1210 |
||
1211 |
iAsyncReqRMessage.Write(1, *des); |
|
1212 |
iAsyncReqRMessage.Complete(EDeleteConversationEvent); |
|
1213 |
delete des; |
|
1214 |
iNotifyHandling = EFalse; |
|
1215 |
} |
|
1216 |
||
1217 |
PRINT ( _L("End CCsSession::HandleDeleteConversationEventL") ); |
|
1218 |
} |
|
1219 |
||
1220 |
// ---------------------------------------------------------------------------- |
|
1221 |
// CCsSession::HandleModifyConversationEventL |
|
1222 |
// the function to handles the modify conversation event received from cache |
|
1223 |
// asynchronously |
|
1224 |
// ---------------------------------------------------------------------------- |
|
1225 |
void CCsSession::HandleModifyConversationEventL( |
|
1226 |
CCsClientConversation* aClientConversation) |
|
1227 |
{ |
|
1228 |
PRINT ( _L("Enter CCsSession::HandleModifyConversationEventL") ); |
|
1229 |
||
1230 |
if (!iConversationChangeObserver) |
|
1231 |
return; |
|
1232 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1233 |
//this is check to send notif to clients for a new message |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1234 |
//1. if the client is subscribed with contact id ==> then send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1235 |
//2. if the client is subscribed with conv id ---> then send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1236 |
// else dont send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1237 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1238 |
if ((aClientConversation->GetContactId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1239 |
iMonitoredConversation->GetContactId() && |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1240 |
aClientConversation->GetContactId() != -1) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1241 |
||(aClientConversation->GetConversationEntryId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1242 |
iMonitoredConversation->GetConversationEntryId())) |
31 | 1243 |
{ |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1244 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1245 |
if (! (iNotifyHandling)) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1246 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1247 |
//append in notify list |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1248 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1249 |
CleanupStack::PushL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1250 |
conversationEvent->SetClientConversationL(*aClientConversation); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1251 |
conversationEvent->SetEvent(KConversationEventUpdate); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1252 |
iEventList->AppendL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1253 |
CleanupStack::Pop(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1254 |
} |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1255 |
else |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1256 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1257 |
// create a new buffer for writing into stream |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1258 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1259 |
CleanupStack::PushL(buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1260 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1261 |
RBufWriteStream writeStream(*buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1262 |
writeStream.PushL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1263 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1264 |
//externalize ClientConversation |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1265 |
aClientConversation->ExternalizeL(writeStream); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1266 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1267 |
// Results are already packed in the stream |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1268 |
writeStream.CommitL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1269 |
// -------------------------------------------------------------- |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1270 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1271 |
// Create a heap descriptor from the buffer |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1272 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1273 |
TPtr8 ptr(des->Des()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1274 |
buf->Read(0, ptr, buf->Size()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1275 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1276 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1277 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1278 |
iAsyncReqRMessage.Write(1, *des); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1279 |
iAsyncReqRMessage.Complete(EModifyConversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1280 |
delete des; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1281 |
iNotifyHandling = EFalse; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1282 |
} |
31 | 1283 |
} |
1284 |
PRINT ( _L("End CCsSession::HandleModifyConversationEventL") ); |
|
1285 |
} |
|
1286 |
||
1287 |
// ---------------------------------------------------------------------------- |
|
1288 |
// CCsSession::NotifyClient |
|
1289 |
// The function to notify client for cache change event |
|
1290 |
// ---------------------------------------------------------------------------- |
|
1291 |
void CCsSession::NotifyClient(CCsConversationEvent* aConversationEvent) |
|
1292 |
{ |
|
1293 |
if (aConversationEvent->IsNewConversationListEventSet()) |
|
1294 |
{ |
|
1295 |
iAsyncReqRMessage.Complete(EAddConversationListEvent); |
|
1296 |
} |
|
1297 |
else if (aConversationEvent->IsDeleteConversationListEventSet()) |
|
1298 |
{ |
|
1299 |
iAsyncReqRMessage.Complete(EDeleteConversationListEvent); |
|
1300 |
} |
|
1301 |
else if (aConversationEvent->IsUpdateConversationListEventSet()) |
|
1302 |
{ |
|
1303 |
iAsyncReqRMessage.Complete(EModifyConversationListEvent); |
|
1304 |
} |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1305 |
else if(aConversationEvent->IsPartialDeleteConversationListEventSet()) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1306 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1307 |
iAsyncReqRMessage.Complete(EPartialDeleteConversationListEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1308 |
} |
31 | 1309 |
else if (aConversationEvent->IsNewConversationEventSet()) |
1310 |
{ |
|
1311 |
iAsyncReqRMessage.Complete(EAddConversationEvent); |
|
1312 |
} |
|
1313 |
else if (aConversationEvent->IsDeleteConversationEventSet()) |
|
1314 |
{ |
|
1315 |
iAsyncReqRMessage.Complete(EDeleteConversationEvent); |
|
1316 |
} |
|
1317 |
else if (aConversationEvent->IsUpdateConversationEventSet()) |
|
1318 |
{ |
|
1319 |
iAsyncReqRMessage.Complete(EModifyConversationEvent); |
|
1320 |
} |
|
1321 |
else if (aConversationEvent->IsRefreshConversationListEventSet()) |
|
1322 |
{ |
|
1323 |
iAsyncReqRMessage.Complete(KConversationEventListRefresh); |
|
1324 |
} |
|
1325 |
else if (aConversationEvent->IsRefreshConversationEventSet()) |
|
1326 |
{ |
|
1327 |
iAsyncReqRMessage.Complete(KConversationEventRefresh); |
|
1328 |
} |
|
1329 |
} |
|
1330 |
||
1331 |
// ---------------------------------------------------------------------------- |
|
1332 |
// CCsSession::HandleChangeEventL |
|
1333 |
// The function handles cache change events |
|
1334 |
// ---------------------------------------------------------------------------- |
|
1335 |
void CCsSession::HandleChangeEventL(CCsClientConversation* aConversation, |
|
1336 |
TUint32 aEvent) |
|
1337 |
{ |
|
1338 |
if (aEvent & KConversationListEventNew) |
|
1339 |
{ |
|
1340 |
HandleNewConversationListEventL(aConversation); |
|
1341 |
} |
|
1342 |
else if (aEvent & KConversationListEventUpdate) |
|
1343 |
{ |
|
1344 |
HandleModifyConversationListEventL(aConversation); |
|
1345 |
} |
|
1346 |
else if (aEvent & KConversationListEventDelete) |
|
1347 |
{ |
|
1348 |
HandleDeleteConversationListEventL(aConversation); |
|
1349 |
} |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1350 |
else if(aEvent & KConversationListEventPartialDelete) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1351 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1352 |
HandlePartialDeleteConversationListEvent(aConversation); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1353 |
} |
31 | 1354 |
else if (aEvent & KConversationEventNew) |
1355 |
{ |
|
1356 |
HandleNewConversationEventL(aConversation); |
|
1357 |
} |
|
1358 |
else if (aEvent & KConversationEventUpdate) |
|
1359 |
{ |
|
1360 |
HandleModifyConversationEventL(aConversation); |
|
1361 |
} |
|
1362 |
else if (aEvent & KConversationEventDelete) |
|
1363 |
{ |
|
1364 |
HandleDeleteConversationEventL(aConversation); |
|
1365 |
} |
|
1366 |
else if (aEvent & KConversationEventListRefresh) |
|
1367 |
{ |
|
1368 |
HandleRefreshConversationListL(); |
|
1369 |
} |
|
1370 |
else if (aEvent & KConversationEventRefresh) |
|
1371 |
{ |
|
1372 |
HandleRefreshConversationL(); |
|
1373 |
} |
|
1374 |
} |
|
1375 |
||
1376 |
// ---------------------------------------------------------------------------- |
|
1377 |
// CCsSession::DeleteConversationL |
|
1378 |
// ---------------------------------------------------------------------------- |
|
1379 |
void CCsSession::DeleteConversationL(const RMessage2& aMessage) |
|
1380 |
{ |
|
1381 |
PRINT ( _L("Enter CCsSession::DeleteConversationL") ); |
|
1382 |
||
1383 |
TInt conversationId = aMessage.Int0(); |
|
1384 |
||
1385 |
// Delete handler |
|
1386 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1387 |
CCsConversationDeleteHandler* deleteHandler = |
|
1388 |
CCsConversationDeleteHandler::NewL(cache); |
|
1389 |
||
1390 |
deleteHandler->DeleteL(conversationId); |
|
1391 |
aMessage.Complete(EUserDeleteConversationComplete); |
|
1392 |
||
1393 |
PRINT ( _L("End CCsSession::DeleteConversationL") ); |
|
1394 |
} |
|
1395 |
||
1396 |
// ---------------------------------------------------------------------------- |
|
1397 |
// CCsSession::HandleRefreshConversationListL |
|
1398 |
// ---------------------------------------------------------------------------- |
|
1399 |
void CCsSession::HandleRefreshConversationListL() |
|
1400 |
{ |
|
1401 |
if (!iConversationListChangeObserver) |
|
1402 |
return; |
|
1403 |
||
1404 |
if (! (iNotifyHandling)) |
|
1405 |
{ |
|
1406 |
// Append in notify list |
|
1407 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
1408 |
CleanupStack::PushL(conversationEvent); |
|
1409 |
conversationEvent->SetEvent(KConversationEventListRefresh); |
|
1410 |
iEventList->AppendL(conversationEvent); |
|
1411 |
CleanupStack::Pop(conversationEvent); |
|
1412 |
} |
|
1413 |
else |
|
1414 |
{ |
|
1415 |
iAsyncReqRMessage.Complete(ERefreshConversationListEvent); |
|
1416 |
iNotifyHandling = EFalse; |
|
1417 |
} |
|
1418 |
} |
|
1419 |
||
1420 |
// ---------------------------------------------------------------------------- |
|
1421 |
// CCsSession::HandleRefreshConversationL |
|
1422 |
// ---------------------------------------------------------------------------- |
|
1423 |
void CCsSession::HandleRefreshConversationL() |
|
1424 |
{ |
|
1425 |
if (!iConversationChangeObserver) |
|
1426 |
return; |
|
1427 |
||
1428 |
if (! (iNotifyHandling)) |
|
1429 |
{ |
|
1430 |
// Append in notify list |
|
1431 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
1432 |
CleanupStack::PushL(conversationEvent); |
|
1433 |
conversationEvent->SetEvent(KConversationEventRefresh); |
|
1434 |
iEventList->AppendL(conversationEvent); |
|
1435 |
CleanupStack::Pop(conversationEvent); |
|
1436 |
} |
|
1437 |
else |
|
1438 |
{ |
|
1439 |
iAsyncReqRMessage.Complete(ERefreshConversationEvent); |
|
1440 |
iNotifyHandling = EFalse; |
|
1441 |
} |
|
1442 |
} |
|
1443 |
||
1444 |
// ---------------------------------------------------------------------------- |
|
1445 |
// Get conversation id |
|
1446 |
// ---------------------------------------------------------------------------- |
|
1447 |
void CCsSession::GetConversationIdL(const RMessage2& aMessage) |
|
1448 |
{ |
|
1449 |
// create a new buffer for writing into stream |
|
1450 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
1451 |
||
1452 |
CleanupStack::PushL(buf); |
|
1453 |
RBufWriteStream writeStream(*buf); |
|
1454 |
writeStream.PushL(); |
|
1455 |
||
1456 |
// Get the contact id |
|
1457 |
TInt contactId = aMessage.Int0(); |
|
1458 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1459 |
TInt conversationId = cache->GetConversationIdL(contactId); |
|
1460 |
||
1461 |
// Externalize link |
|
1462 |
writeStream.WriteInt32L(conversationId); |
|
1463 |
||
1464 |
// Results are already packed in the stream |
|
1465 |
writeStream.CommitL(); |
|
1466 |
||
1467 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1468 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 1469 |
TPtr8 ptr(des->Des()); |
1470 |
buf->Read(0, ptr, buf->Size()); |
|
1471 |
||
1472 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
1473 |
||
1474 |
aMessage.Write(1, *des); |
|
1475 |
aMessage.Complete(EGetConversationIdComplete); |
|
1476 |
delete des; |
|
1477 |
} |
|
1478 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1479 |
void CCsSession::GetConversationFromConversationIdL(const RMessage2& aMessage) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1480 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1481 |
// create a new buffer for writing into stream |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1482 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1483 |
CleanupStack::PushL(buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1484 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1485 |
RBufWriteStream writeStream(*buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1486 |
writeStream.PushL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1487 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1488 |
// Get the conversation id |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1489 |
TInt conversationId = aMessage.Int0(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1490 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1491 |
CCsClientConversation* clientConv = cache->GetConversationFromConversationIdL(conversationId); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1492 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1493 |
// if no conversation exists for given message-id, |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1494 |
// create a dummy conversation and complete response |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1495 |
if(clientConv == NULL) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1496 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1497 |
//create dummy conversation |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1498 |
clientConv = CCsClientConversation::NewL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1499 |
CleanupStack::PushL(clientConv); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1500 |
clientConv->SetConversationEntryId(-1); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1501 |
CCsConversationEntry* entry = CCsConversationEntry::NewL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1502 |
CleanupStack::PushL(entry); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1503 |
entry->SetEntryId(-1); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1504 |
clientConv->SetConversationEntryL(entry); // clone |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1505 |
CleanupStack::PopAndDestroy(entry); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1506 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1507 |
else |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1508 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1509 |
CleanupStack::PushL(clientConv); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1510 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1511 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1512 |
// Externalize |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1513 |
clientConv->ExternalizeL(writeStream); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1514 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1515 |
// Results are already packed in the stream |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1516 |
writeStream.CommitL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1517 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1518 |
// Create a heap descriptor from the buffer |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1519 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1520 |
TPtr8 ptr(des->Des()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1521 |
buf->Read(0, ptr, buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1522 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1523 |
CleanupStack::PopAndDestroy(3, buf); // clientConv, writestream, buf |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1524 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1525 |
aMessage.Write(1, *des); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1526 |
aMessage.Complete(EGetConversationFromConversationIdComplete); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1527 |
delete des; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1528 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1529 |
|
31 | 1530 |
// ---------------------------------------------------------------------------- |
1531 |
// GetConversationFromMessageIdL |
|
1532 |
// ---------------------------------------------------------------------------- |
|
1533 |
void CCsSession::GetConversationFromMessageIdL(const RMessage2& aMessage) |
|
1534 |
{ |
|
1535 |
// create a new buffer for writing into stream |
|
1536 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
1537 |
CleanupStack::PushL(buf); |
|
1538 |
||
1539 |
RBufWriteStream writeStream(*buf); |
|
1540 |
writeStream.PushL(); |
|
1541 |
||
1542 |
// Get the message id |
|
1543 |
TInt messageId = aMessage.Int0(); |
|
1544 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1545 |
CCsClientConversation* conversation = cache->GetConversationFromMessageIdL(messageId); |
|
1546 |
||
1547 |
// if no conversation exists for given message-id, |
|
1548 |
// create a dummy conversation and complete response |
|
1549 |
if(conversation == NULL) |
|
1550 |
{ |
|
1551 |
//create dummy conversation |
|
1552 |
conversation = CCsClientConversation::NewL(); |
|
1553 |
CleanupStack::PushL(conversation); |
|
1554 |
conversation->SetConversationEntryId(-1); |
|
1555 |
CCsConversationEntry* entry = CCsConversationEntry::NewL(); |
|
1556 |
CleanupStack::PushL(entry); |
|
1557 |
entry->SetEntryId(-1); |
|
1558 |
conversation->SetConversationEntryL(entry); // clone |
|
1559 |
CleanupStack::PopAndDestroy(entry); |
|
1560 |
} |
|
1561 |
else |
|
1562 |
{ |
|
1563 |
CleanupStack::PushL(conversation); |
|
1564 |
} |
|
1565 |
||
1566 |
// Externalize |
|
1567 |
conversation->ExternalizeL(writeStream); |
|
1568 |
||
1569 |
// Results are already packed in the stream |
|
1570 |
writeStream.CommitL(); |
|
1571 |
||
1572 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1573 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 1574 |
TPtr8 ptr(des->Des()); |
1575 |
buf->Read(0, ptr, buf->Size()); |
|
1576 |
||
1577 |
CleanupStack::PopAndDestroy(3, buf); // conversation, writestream, buf |
|
1578 |
||
1579 |
aMessage.Write(1, *des); |
|
1580 |
aMessage.Complete(EGetConversationFromMessageIdComplete); |
|
1581 |
delete des; |
|
1582 |
} |
|
1583 |
||
1584 |
// ---------------------------------------------------------------------------- |
|
1585 |
// CCsSession::GetConversationIdfromAddressL |
|
1586 |
// ---------------------------------------------------------------------------- |
|
1587 |
void CCsSession::GetConversationIdfromAddressL(const RMessage2& aMessage) |
|
1588 |
{ |
|
1589 |
TInt deslen = aMessage.GetDesLength(0); |
|
1590 |
||
1591 |
// Copy the data into a buffer |
|
1592 |
RBuf buffer; |
|
1593 |
buffer.CreateL(deslen); |
|
1594 |
buffer.CleanupClosePushL(); |
|
1595 |
aMessage.ReadL(0,buffer,0); |
|
1596 |
||
1597 |
||
1598 |
// Get the contact id |
|
1599 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1600 |
TInt conversationId = cache->GetConversationIdFromAddressL(buffer); |
|
1601 |
||
1602 |
// create a new buffer for writing into stream |
|
1603 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
1604 |
CleanupStack::PushL(buf); |
|
1605 |
||
1606 |
RBufWriteStream writeStream(*buf); |
|
1607 |
writeStream.PushL(); |
|
1608 |
// Externalize link |
|
1609 |
writeStream.WriteInt32L(conversationId); |
|
1610 |
||
1611 |
// Results are already packed in the stream |
|
1612 |
writeStream.CommitL(); |
|
1613 |
||
1614 |
// Create a heap descriptor from the buffer |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1615 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 1616 |
TPtr8 ptr(des->Des()); |
1617 |
buf->Read(0, ptr, buf->Size()); |
|
1618 |
||
1619 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
1620 |
CleanupStack::PopAndDestroy(&buffer); |
|
1621 |
||
1622 |
aMessage.Write(1, *des); |
|
1623 |
aMessage.Complete(EGetConversationIdFromAddressComplete); |
|
1624 |
delete des; |
|
1625 |
} |
|
1626 |
||
1627 |
// ---------------------------------------------------------------------------- |
|
1628 |
// CCsSession::MarkConversationReadL |
|
1629 |
// ---------------------------------------------------------------------------- |
|
1630 |
void CCsSession::MarkConversationReadL(const RMessage2& aMessage) |
|
1631 |
{ |
|
1632 |
PRINT ( _L("Enter CCsSession::MarkConversationReadL") ); |
|
1633 |
||
1634 |
TInt conversationId = aMessage.Int0(); |
|
1635 |
||
1636 |
// Mark read handler |
|
1637 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1638 |
CCsConversationMarkReadHandler* markHandler = CCsConversationMarkReadHandler::NewL(cache); |
|
1639 |
||
1640 |
markHandler->MarkReadL(conversationId); |
|
1641 |
||
1642 |
aMessage.Complete(EUserMarkReadConversationComplete); |
|
1643 |
||
1644 |
PRINT ( _L("End CCsSession::MarkConversationReadL") ); |
|
1645 |
} |
|
1646 |
//EOF |