author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:32:06 +0100 | |
branch | GCC_SURGE |
changeset 47 | 5b14749788d7 |
parent 27 | e4592d119491 |
parent 44 | 36f374c67aa8 |
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(); |
|
492 |
||
493 |
// get cache pointer |
|
494 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
495 |
||
496 |
// read the Client Conversation consist of Entry Id |
|
497 |
CCsClientConversation* ClientConversation = |
|
498 |
CCsClientConversation::NewL(); |
|
499 |
CleanupStack::PushL(ClientConversation); |
|
500 |
ClientConversation->InternalizeL(stream); |
|
501 |
CleanupStack::Pop(ClientConversation); |
|
502 |
CleanupStack::PopAndDestroy(2, buffer);//stream, buffer |
|
503 |
||
504 |
CleanupStack::PushL(ClientConversation); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
505 |
RPointerArray<CCsConversationEntry>* conversationEntryList= |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
506 |
new (ELeave) RPointerArray<CCsConversationEntry>(10); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
507 |
CleanupResetAndDestroyPushL(conversationEntryList); |
31 | 508 |
|
509 |
// get conversationlist for given ClientConversation |
|
510 |
cache->GetConversationsL(ClientConversation, conversationEntryList); |
|
511 |
||
512 |
// create a new buffer for writing into stream |
|
513 |
// write all list data into stream |
|
514 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
515 |
CleanupStack::PushL(buf); |
|
516 |
||
517 |
RBufWriteStream writeStream(*buf); |
|
518 |
writeStream.PushL(); |
|
519 |
||
520 |
TInt ItemCount = conversationEntryList->Count(); |
|
521 |
//write recent conversation entry list |
|
522 |
writeStream.WriteInt32L(ItemCount); |
|
523 |
||
524 |
// Write the conversation entry |
|
525 |
for (TInt iloop = 0; iloop < ItemCount; iloop++) |
|
526 |
{ |
|
527 |
CCsConversationEntry |
|
528 |
* entry = |
|
529 |
static_cast<CCsConversationEntry*> ( (*conversationEntryList)[iloop]); |
|
530 |
entry->ExternalizeL(writeStream); |
|
531 |
} |
|
532 |
||
533 |
// Results are already packed in the stream |
|
534 |
writeStream.CommitL(); |
|
535 |
||
536 |
// -------------------------------------------------------------- |
|
537 |
// 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
|
538 |
iDes = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
539 |
TPtr8 ptr(iDes->Des()); |
31 | 540 |
buf->Read(0, ptr, buf->Size()); |
541 |
||
542 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
543 |
|
31 | 544 |
// Cleanup |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
545 |
CleanupStack::PopAndDestroy(conversationEntryList); |
31 | 546 |
CleanupStack::PopAndDestroy(ClientConversation); |
547 |
} |
|
548 |
||
549 |
TInt rcevdBufferSize = aMessage.GetDesMaxLength(1); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
550 |
TInt reqdBufferSize = iDes->Size(); |
31 | 551 |
|
552 |
PRINT1 ( _L("Received buffer size = %d"), rcevdBufferSize ); |
|
553 |
PRINT1 ( _L("Required buffer size = %d"), reqdBufferSize ); |
|
554 |
||
555 |
// If the received buffer size from Client API is less than |
|
556 |
// the required buffer size write the required buffer size |
|
557 |
if (rcevdBufferSize < reqdBufferSize) |
|
558 |
{ |
|
559 |
PRINT ( _L("In-adequate buffer received") ); |
|
560 |
PRINT ( _L("Packing the required buffer size in response") ); |
|
561 |
||
562 |
TPckgC<TInt> bufferSizePackage(reqdBufferSize); |
|
563 |
aMessage.WriteL(1, bufferSizePackage); |
|
564 |
aMessage.Complete(EGetConversationBufferOverflow); |
|
565 |
iGetConversationBufferOverflow = ETrue; |
|
566 |
} |
|
567 |
else |
|
568 |
{ |
|
569 |
PRINT ( _L("Adequate buffer received") ); |
|
570 |
PRINT ( _L("Packing the results in response") ) |
|
571 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
572 |
aMessage.Write(1, *iDes); |
31 | 573 |
aMessage.Complete(EGetConversationOperationComplete); |
574 |
iGetConversationBufferOverflow = EFalse; |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
575 |
delete iDes; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
576 |
iDes = NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
577 |
} |
31 | 578 |
|
579 |
PRINT ( _L("End CCsSession::GetConversationsL") ); |
|
580 |
} |
|
581 |
||
582 |
// ---------------------------------------------------------------------------- |
|
583 |
// CCsSession::ShutdownServerL |
|
584 |
// Stops the scheduler |
|
585 |
// ---------------------------------------------------------------------------- |
|
586 |
void CCsSession::ShutdownServerL(const RMessage2& aMessage) |
|
587 |
{ |
|
588 |
aMessage.Complete(KErrNone); |
|
589 |
CActiveScheduler::Stop(); |
|
590 |
||
591 |
PRINT ( _L("CCsSession::ShutdownServerL - Server ShutDown") ); |
|
592 |
} |
|
593 |
||
594 |
// ---------------------------------------------------------------------------- |
|
595 |
// CCsSession::HandleNewConversationListEventL |
|
596 |
// Notify client about new conversation event |
|
597 |
// ---------------------------------------------------------------------------- |
|
598 |
void CCsSession::HandleNewConversationListEventL( |
|
599 |
CCsClientConversation* aClientConversation) |
|
600 |
{ |
|
601 |
PRINT ( _L("Enter CCsSession::HandleNewConversationListEventL") ); |
|
602 |
||
603 |
if (!iConversationListChangeObserver) |
|
604 |
return; |
|
605 |
||
606 |
if (! (iNotifyHandling)) |
|
607 |
{ |
|
608 |
//append in notify list |
|
609 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
610 |
CleanupStack::PushL(conversationEvent); |
|
611 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
612 |
conversationEvent->SetEvent(KConversationListEventNew); |
|
613 |
iEventList->AppendL(conversationEvent); |
|
614 |
CleanupStack::Pop(conversationEvent); |
|
615 |
} |
|
616 |
else |
|
617 |
{ |
|
618 |
// create a new buffer for writing into stream |
|
619 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
620 |
CleanupStack::PushL(buf); |
|
621 |
||
622 |
RBufWriteStream writeStream(*buf); |
|
623 |
writeStream.PushL(); |
|
624 |
||
625 |
//externalize ClientConversation |
|
626 |
aClientConversation->ExternalizeL(writeStream); |
|
627 |
||
628 |
// Results are already packed in the stream |
|
629 |
writeStream.CommitL(); |
|
630 |
||
631 |
// -------------------------------------------------------------- |
|
632 |
// Create a heap descriptor from the buffer |
|
633 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
634 |
TPtr8 ptr(notifyDes->Des()); |
|
635 |
buf->Read(0, ptr, buf->Size()); |
|
636 |
||
637 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
638 |
iAsyncReqRMessage.Complete(EAddConversationListEvent); |
|
639 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
|
640 |
iNotifyHandling = EFalse; |
|
641 |
} |
|
642 |
||
643 |
PRINT ( _L("End CCsSession::HandleNewConversationListEventL") ); |
|
644 |
} |
|
645 |
||
646 |
// ---------------------------------------------------------------------------- |
|
647 |
// CCsSession::HandleDeleteConversationListEventL |
|
648 |
// Notify client about delete conversation event |
|
649 |
// ---------------------------------------------------------------------------- |
|
650 |
void CCsSession::HandleDeleteConversationListEventL( |
|
651 |
CCsClientConversation* aClientConversation) |
|
652 |
{ |
|
653 |
PRINT ( _L("Enter CCsSession::HandleDeleteConversationListEventL") ); |
|
654 |
||
655 |
if (!iConversationListChangeObserver) |
|
656 |
return; |
|
657 |
||
658 |
if (! (iNotifyHandling)) |
|
659 |
{ |
|
660 |
//append in notify list |
|
661 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
662 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
663 |
CleanupStack::PushL(conversationEvent); |
|
664 |
conversationEvent->SetEvent(KConversationListEventDelete); |
|
665 |
iEventList->AppendL(conversationEvent); |
|
666 |
CleanupStack::Pop(conversationEvent); |
|
667 |
} |
|
668 |
else |
|
669 |
{ |
|
670 |
// create a new buffer for writing into stream |
|
671 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
672 |
CleanupStack::PushL(buf); |
|
673 |
||
674 |
RBufWriteStream writeStream(*buf); |
|
675 |
writeStream.PushL(); |
|
676 |
||
677 |
//externalize ClientConversation |
|
678 |
aClientConversation->ExternalizeL(writeStream); |
|
679 |
||
680 |
// Results are already packed in the stream |
|
681 |
writeStream.CommitL(); |
|
682 |
||
683 |
// -------------------------------------------------------------- |
|
684 |
// Create a heap descriptor from the buffer |
|
685 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
686 |
TPtr8 ptr(notifyDes->Des()); |
|
687 |
buf->Read(0, ptr, buf->Size()); |
|
688 |
||
689 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
690 |
iAsyncReqRMessage.Complete(EDeleteConversationListEvent); |
|
691 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
|
692 |
iNotifyHandling = EFalse; |
|
693 |
} |
|
694 |
||
695 |
PRINT ( _L("End CCsSession::HandleDeleteConversationListEventL") ); |
|
696 |
} |
|
697 |
||
698 |
// ---------------------------------------------------------------------------- |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
699 |
// CCsSession::HandlePartialDeleteConversationListEventL |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
700 |
// Notify client about partial delete conversation event |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
701 |
// ---------------------------------------------------------------------------- |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
702 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
703 |
void CCsSession::HandlePartialDeleteConversationListEvent( |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
704 |
CCsClientConversation* aClientConversation) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
705 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
706 |
PRINT ( _L("Enter CCsSession::HandlePartialDeleteConversationListEvent") ); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
707 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
708 |
if (!iConversationListChangeObserver) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
709 |
return; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
710 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
711 |
if (! (iNotifyHandling)) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
712 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
713 |
//append in notify list |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
714 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
715 |
conversationEvent->SetClientConversationL(*aClientConversation); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
716 |
CleanupStack::PushL(conversationEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
717 |
conversationEvent->SetEvent(KConversationListEventPartialDelete); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
718 |
iEventList->AppendL(conversationEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
719 |
CleanupStack::Pop(conversationEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
720 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
721 |
else |
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 |
// 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
|
724 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
725 |
CleanupStack::PushL(buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
726 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
727 |
RBufWriteStream writeStream(*buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
728 |
writeStream.PushL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
729 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
730 |
//externalize ClientConversation |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
731 |
aClientConversation->ExternalizeL(writeStream); |
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 |
// Results are already packed in the stream |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
734 |
writeStream.CommitL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
735 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
736 |
// -------------------------------------------------------------- |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
737 |
// Create a heap descriptor from the buffer |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
738 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
739 |
TPtr8 ptr(notifyDes->Des()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
740 |
buf->Read(0, ptr, buf->Size()); |
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 |
iAsyncReqRMessage.Write(1, *notifyDes); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
743 |
iAsyncReqRMessage.Complete(EPartialDeleteConversationListEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
744 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
745 |
iNotifyHandling = EFalse; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
746 |
} |
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 |
// ---------------------------------------------------------------------------- |
31 | 750 |
// CCsSession::HandleModifyConversationListEventL |
751 |
// Notify client about update conversation event |
|
752 |
// ---------------------------------------------------------------------------- |
|
753 |
void CCsSession::HandleModifyConversationListEventL( |
|
754 |
CCsClientConversation* aClientConversation) |
|
755 |
{ |
|
756 |
PRINT ( _L("Enter CCsSession::HandleModifyConversationListEventL") ); |
|
757 |
||
758 |
if (!iConversationListChangeObserver) |
|
759 |
return; |
|
760 |
||
761 |
if (! (iNotifyHandling)) |
|
762 |
{ |
|
763 |
//append in notify list |
|
764 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
765 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
766 |
CleanupStack::PushL(conversationEvent); |
|
767 |
conversationEvent->SetEvent(KConversationListEventUpdate); |
|
768 |
iEventList->AppendL(conversationEvent); |
|
769 |
CleanupStack::Pop(conversationEvent); |
|
770 |
} |
|
771 |
else |
|
772 |
{ |
|
773 |
// create a new buffer for writing into stream |
|
774 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
775 |
CleanupStack::PushL(buf); |
|
776 |
||
777 |
RBufWriteStream writeStream(*buf); |
|
778 |
writeStream.PushL(); |
|
779 |
||
780 |
//externalize ClientConversation |
|
781 |
aClientConversation->ExternalizeL(writeStream); |
|
782 |
||
783 |
// Results are already packed in the stream |
|
784 |
writeStream.CommitL(); |
|
785 |
// -------------------------------------------------------------- |
|
786 |
||
787 |
// Create a heap descriptor from the buffer |
|
788 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
789 |
TPtr8 ptr(notifyDes->Des()); |
|
790 |
buf->Read(0, ptr, buf->Size()); |
|
791 |
||
792 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
793 |
iAsyncReqRMessage.Complete(EModifyConversationListEvent); |
|
794 |
CleanupStack::PopAndDestroy(3, buf); // notifyDes, writestream, buf |
|
795 |
iNotifyHandling = EFalse; |
|
796 |
} |
|
797 |
||
798 |
PRINT ( _L("End CCsSession::HandleModifyConversationListEventL") ); |
|
799 |
} |
|
800 |
||
801 |
// ---------------------------------------------------------------------------- |
|
802 |
// CCsSession::RequestChangeEventL |
|
803 |
// the function to register for cache change event notification |
|
804 |
// ---------------------------------------------------------------------------- |
|
805 |
void CCsSession::RequestChangeEventL(const RMessage2& aMessage) |
|
806 |
{ |
|
807 |
iAsyncReqRMessage = aMessage; |
|
808 |
iNotifyHandling = ETrue; |
|
809 |
||
810 |
if (iEventList->Count() > 0) |
|
811 |
{ |
|
812 |
CCsConversationEvent* conversationEvent = (*iEventList)[0]; |
|
813 |
||
814 |
// check if the reqCnt matches with the latest arrived count |
|
815 |
// then its not a duplicate, delete the top event |
|
816 |
if (iReqCnt == aMessage.Int2()) |
|
817 |
{ |
|
818 |
iEventList->Remove(0); |
|
819 |
delete conversationEvent; |
|
820 |
||
821 |
if (iEventList->Count() > 0) |
|
822 |
{ |
|
823 |
// increment the count |
|
824 |
iReqCnt++; |
|
825 |
conversationEvent = (*iEventList)[0]; |
|
826 |
} |
|
827 |
else |
|
828 |
{ |
|
829 |
// no more pending events, simply return |
|
830 |
return; |
|
831 |
} |
|
832 |
} |
|
833 |
||
834 |
HBufC8* buffer = HBufC8::NewLC(4); |
|
835 |
TPtr8 cntPtr(buffer->Des()); |
|
836 |
_LIT8(KFormat,"%d"); |
|
837 |
cntPtr.Format(KFormat, iReqCnt); |
|
838 |
iAsyncReqRMessage.Write(0, *buffer); |
|
839 |
||
840 |
// create a new buffer for writing into stream |
|
841 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
842 |
CleanupStack::PushL(buf); |
|
843 |
||
844 |
RBufWriteStream writeStream(*buf); |
|
845 |
writeStream.PushL(); |
|
846 |
||
847 |
// Externalize ClientConversation |
|
848 |
if (conversationEvent->ClientConversation()) |
|
849 |
conversationEvent->ClientConversation()->ExternalizeL(writeStream); |
|
850 |
||
851 |
// Results are already packed in the stream |
|
852 |
writeStream.CommitL(); |
|
853 |
||
854 |
// -------------------------------------------------------------- |
|
855 |
// Create a heap descriptor from the buffer |
|
856 |
HBufC8* notifyDes = HBufC8::NewLC(buf->Size()); |
|
857 |
TPtr8 ptr(notifyDes->Des()); |
|
858 |
buf->Read(0, ptr, buf->Size()); |
|
859 |
||
860 |
iAsyncReqRMessage.Write(1, *notifyDes); |
|
861 |
||
862 |
NotifyClient(conversationEvent); |
|
863 |
||
864 |
CleanupStack::PopAndDestroy(4, buffer); |
|
865 |
// notifyDes, writestream, buf, buffer |
|
866 |
iNotifyHandling = EFalse; |
|
867 |
} |
|
868 |
} |
|
869 |
||
870 |
// ---------------------------------------------------------------------------- |
|
871 |
// CCsSession::RemoveChangeEventL |
|
872 |
// Deregister the cache change event notification |
|
873 |
// ---------------------------------------------------------------------------- |
|
874 |
void CCsSession::RemoveChangeEventL(const RMessage2& aMessage) |
|
875 |
{ |
|
876 |
if (! (iNotifyHandling)) |
|
877 |
{ |
|
878 |
// complete message with aMessage |
|
879 |
aMessage.Complete(KErrNone); |
|
880 |
} |
|
881 |
else |
|
882 |
{ |
|
883 |
iAsyncReqRMessage.Complete(KErrCancel); |
|
884 |
iNotifyHandling = EFalse; |
|
885 |
// complete message with aMessage |
|
886 |
aMessage.Complete(KErrNone); |
|
887 |
} |
|
888 |
} |
|
889 |
||
890 |
// ---------------------------------------------------------------------------- |
|
891 |
// CCsSession::GetCachingStatusL |
|
892 |
// the function to request conversation server |
|
893 |
// to get caching status. |
|
894 |
// ---------------------------------------------------------------------------- |
|
895 |
void CCsSession::GetCachingStatusL(const RMessage2& aMessage) |
|
896 |
{ |
|
897 |
PRINT ( _L("Enter CCsSession::GetCachingStatusL") ); |
|
898 |
||
899 |
// create a new buffer for writing into stream |
|
900 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
901 |
||
902 |
CleanupStack::PushL(buf); |
|
903 |
RBufWriteStream writeStream(*buf); |
|
904 |
writeStream.PushL(); |
|
905 |
||
906 |
// Externalize caching status |
|
907 |
writeStream.WriteUint8L(iServer->GetCachingStatus()); |
|
908 |
||
909 |
// Results are already packed in the stream |
|
910 |
writeStream.CommitL(); |
|
911 |
// -------------------------------------------------------------- |
|
912 |
||
913 |
// 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
|
914 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 915 |
TPtr8 ptr(des->Des()); |
916 |
buf->Read(0, ptr, buf->Size()); |
|
917 |
||
918 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
919 |
||
920 |
aMessage.Write(1, *des); |
|
921 |
aMessage.Complete(KErrNone); |
|
922 |
delete des; |
|
923 |
||
924 |
PRINT ( _L("End CCsSession::GetCachingStatusL") ); |
|
925 |
} |
|
926 |
||
927 |
// ---------------------------------------------------------------------------- |
|
928 |
// CCsSession::GetTotalUnreadCountL |
|
929 |
// Gets total unread conversation entries. |
|
930 |
// ---------------------------------------------------------------------------- |
|
931 |
void CCsSession::GetTotalUnreadCountL(const RMessage2& aMessage) |
|
932 |
{ |
|
933 |
PRINT ( _L("Enter CCsSession::GetTotalUnreadCountL") ); |
|
934 |
||
935 |
// create a new buffer for writing into stream |
|
936 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
937 |
||
938 |
CleanupStack::PushL(buf); |
|
939 |
RBufWriteStream writeStream(*buf); |
|
940 |
writeStream.PushL(); |
|
941 |
||
942 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
943 |
||
944 |
// Externalize caching status |
|
945 |
writeStream.WriteUint32L(cache->GetTotalUnreadCount()); |
|
946 |
||
947 |
// Results are already packed in the stream |
|
948 |
writeStream.CommitL(); |
|
949 |
// -------------------------------------------------------------- |
|
950 |
||
951 |
// 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
|
952 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 953 |
TPtr8 ptr(des->Des()); |
954 |
buf->Read(0, ptr, buf->Size()); |
|
955 |
||
956 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
957 |
||
958 |
aMessage.Write(1, *des); |
|
959 |
aMessage.Complete(KErrNone); |
|
960 |
delete des; |
|
961 |
||
962 |
PRINT ( _L("End CCsSession::GetTotalUnreadCountL") ); |
|
963 |
} |
|
964 |
||
965 |
// ---------------------------------------------------------------------------- |
|
966 |
// CCsSession::SetConversationListChangeObserverL |
|
967 |
// the function to request conversation server |
|
968 |
// to set ConversationListChangeObserver. |
|
969 |
// ---------------------------------------------------------------------------- |
|
970 |
void CCsSession::SetConversationListChangeObserverL(const RMessage2& aMessage) |
|
971 |
{ |
|
972 |
iConversationListChangeObserver = ETrue; |
|
973 |
aMessage.Complete(KErrNone); |
|
974 |
} |
|
975 |
||
976 |
// ---------------------------------------------------------------------------- |
|
977 |
// CCsSession::ResetConversationListChangeObserverL |
|
978 |
// the function to request conversation server |
|
979 |
// to reset ConversationListChangeObserver. |
|
980 |
// ---------------------------------------------------------------------------- |
|
981 |
void CCsSession::ResetConversationListChangeObserverL(const RMessage2& aMessage) |
|
982 |
{ |
|
983 |
iConversationListChangeObserver = EFalse; |
|
984 |
aMessage.Complete(KErrNone); |
|
985 |
} |
|
986 |
||
987 |
// ---------------------------------------------------------------------------- |
|
988 |
// CCsSession::SetConversationChangeObserverL |
|
989 |
// the function to request conversation server |
|
990 |
// to set ConversationChangeObserver. |
|
991 |
// ---------------------------------------------------------------------------- |
|
992 |
void CCsSession::SetConversationChangeObserverL(const RMessage2& aMessage) |
|
993 |
{ |
|
994 |
// Read Contact from the message |
|
995 |
HBufC8* buffer = HBufC8::NewLC(KBigBuffer); |
|
996 |
||
997 |
TPtr8 bufferPtr(buffer->Des()); |
|
998 |
aMessage.ReadL(0, bufferPtr); |
|
999 |
||
1000 |
// Stream over the buffer |
|
1001 |
RDesReadStream stream(bufferPtr); |
|
1002 |
stream.PushL(); |
|
1003 |
||
1004 |
// Get the client conversation |
|
1005 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
|
1006 |
CleanupStack::PushL(clientConversation); |
|
1007 |
clientConversation->InternalizeL(stream); |
|
1008 |
CleanupStack::Pop(clientConversation); |
|
1009 |
||
1010 |
CleanupStack::PopAndDestroy(2, buffer);//stream, buffer |
|
1011 |
||
1012 |
iMonitoredConversation = clientConversation; |
|
1013 |
iConversationChangeObserver = ETrue; |
|
1014 |
||
1015 |
aMessage.Complete(KErrNone); |
|
1016 |
} |
|
1017 |
||
1018 |
// ---------------------------------------------------------------------------- |
|
1019 |
// CCsSession::ResetConversationChangeObserverL |
|
1020 |
// the function to request conversation server |
|
1021 |
// to reset ConversationChangeObserver. |
|
1022 |
// ---------------------------------------------------------------------------- |
|
1023 |
void CCsSession::ResetConversationChangeObserverL(const RMessage2& aMessage) |
|
1024 |
{ |
|
1025 |
// Read Contact from the message |
|
1026 |
HBufC8* buffer = HBufC8::NewLC(KBigBuffer); |
|
1027 |
||
1028 |
TPtr8 bufferPtr(buffer->Des()); |
|
1029 |
aMessage.ReadL(0, bufferPtr); |
|
1030 |
||
1031 |
// Stream over the buffer |
|
1032 |
RDesReadStream stream(bufferPtr); |
|
1033 |
stream.PushL(); |
|
1034 |
||
1035 |
// Read the client conversation |
|
1036 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
|
1037 |
CleanupStack::PushL(clientConversation); |
|
1038 |
clientConversation->InternalizeL(stream); |
|
1039 |
CleanupStack::Pop(clientConversation); |
|
1040 |
||
1041 |
CleanupStack::PopAndDestroy(2, buffer); //stream, buffer |
|
1042 |
||
1043 |
if (iMonitoredConversation) |
|
1044 |
{ |
|
1045 |
delete iMonitoredConversation; |
|
1046 |
iMonitoredConversation = NULL; |
|
1047 |
iConversationChangeObserver = EFalse; |
|
1048 |
} |
|
1049 |
||
1050 |
delete clientConversation; |
|
1051 |
||
1052 |
aMessage.Complete(KErrNone); |
|
1053 |
} |
|
1054 |
||
1055 |
// ---------------------------------------------------------------------------- |
|
1056 |
// CCsSession::SetCachingStatusObserverL |
|
1057 |
// the function to request conversation server |
|
1058 |
// to set caching status observer flag. |
|
1059 |
// ---------------------------------------------------------------------------- |
|
1060 |
void CCsSession::SetCachingStatusObserverL(const RMessage2& aMessage) |
|
1061 |
{ |
|
1062 |
iCachingChangeObserver = ETrue; |
|
1063 |
aMessage.Complete(KErrNone); |
|
1064 |
} |
|
1065 |
||
1066 |
// ---------------------------------------------------------------------------- |
|
1067 |
// CCsSession::ResetCachingStatusObserverL |
|
1068 |
// the function to request conversation server |
|
1069 |
// to reset caching status observer flag. |
|
1070 |
// ---------------------------------------------------------------------------- |
|
1071 |
void CCsSession::ResetCachingStatusObserverL(const RMessage2& aMessage) |
|
1072 |
{ |
|
1073 |
iCachingChangeObserver = EFalse; |
|
1074 |
aMessage.Complete(KErrNone); |
|
1075 |
} |
|
1076 |
||
1077 |
// ---------------------------------------------------------------------------- |
|
1078 |
// CCsSession::HandleNewConversationEventL |
|
1079 |
// the function to handles the new conversation event received from cache |
|
1080 |
// asynchronously |
|
1081 |
// ---------------------------------------------------------------------------- |
|
1082 |
void CCsSession::HandleNewConversationEventL( |
|
1083 |
CCsClientConversation* aClientConversation) |
|
1084 |
{ |
|
1085 |
PRINT ( _L("Enter CCsSession::HandleNewConversationEventL") ); |
|
1086 |
||
1087 |
if (!iConversationChangeObserver) |
|
1088 |
return; |
|
1089 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1090 |
//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
|
1091 |
//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
|
1092 |
//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
|
1093 |
// else dont send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1094 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1095 |
if ((aClientConversation->GetContactId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1096 |
iMonitoredConversation->GetContactId() && |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1097 |
aClientConversation->GetContactId() != -1) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1098 |
||(aClientConversation->GetConversationEntryId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1099 |
iMonitoredConversation->GetConversationEntryId())) |
31 | 1100 |
{ |
1101 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1102 |
if (! (iNotifyHandling)) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1103 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1104 |
//append in notify list |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1105 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1106 |
CleanupStack::PushL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1107 |
conversationEvent->SetClientConversationL(*aClientConversation); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1108 |
conversationEvent->SetEvent(KConversationEventNew); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1109 |
iEventList->AppendL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1110 |
CleanupStack::Pop(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1111 |
} |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1112 |
else |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1113 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1114 |
// 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
|
1115 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1116 |
CleanupStack::PushL(buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1117 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1118 |
RBufWriteStream writeStream(*buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1119 |
writeStream.PushL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1120 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1121 |
//externalize ClientConversation |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1122 |
aClientConversation->ExternalizeL(writeStream); |
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 |
// Results are already packed in the stream |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1125 |
writeStream.CommitL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1126 |
// -------------------------------------------------------------- |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1127 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1128 |
// Create a heap descriptor from the buffer |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1129 |
HBufC8* des = HBufC8::NewLC(buf->Size()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1130 |
CleanupStack::Pop(des); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1131 |
TPtr8 ptr(des->Des()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1132 |
buf->Read(0, ptr, buf->Size()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1133 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1134 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
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 |
iAsyncReqRMessage.Write(1, *des); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1137 |
iAsyncReqRMessage.Complete(EAddConversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1138 |
delete des; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1139 |
iNotifyHandling = EFalse; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1140 |
} |
31 | 1141 |
} |
1142 |
PRINT ( _L("End CCsSession::HandleNewConversationEventL") ); |
|
1143 |
} |
|
1144 |
||
1145 |
// ---------------------------------------------------------------------------- |
|
1146 |
// CCsSession::HandleDeleteConversationEventL |
|
1147 |
// the function to handles the delete conversation event received from cache |
|
1148 |
// asynchronously |
|
1149 |
// ---------------------------------------------------------------------------- |
|
1150 |
void CCsSession::HandleDeleteConversationEventL( |
|
1151 |
CCsClientConversation* aClientConversation) |
|
1152 |
{ |
|
1153 |
PRINT ( _L("Enter CCsSession::HandleDeleteConversationEventL") ); |
|
1154 |
||
1155 |
if (!iConversationChangeObserver) |
|
1156 |
return; |
|
1157 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1158 |
if ((aClientConversation->GetContactId() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1159 |
!= iMonitoredConversation->GetContactId()) && |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1160 |
(aClientConversation->GetConversationEntryId() |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1161 |
!= iMonitoredConversation->GetConversationEntryId()) |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
1162 |
) |
31 | 1163 |
return; |
1164 |
||
1165 |
if (! (iNotifyHandling)) |
|
1166 |
{ |
|
1167 |
//append in notify list |
|
1168 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
1169 |
CleanupStack::PushL(conversationEvent); |
|
1170 |
conversationEvent->SetClientConversationL(*aClientConversation); |
|
1171 |
conversationEvent->SetEvent(KConversationEventDelete); |
|
1172 |
iEventList->AppendL(conversationEvent); |
|
1173 |
CleanupStack::Pop(conversationEvent); |
|
1174 |
} |
|
1175 |
else |
|
1176 |
{ |
|
1177 |
// create a new buffer for writing into stream |
|
1178 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
1179 |
CleanupStack::PushL(buf); |
|
1180 |
||
1181 |
RBufWriteStream writeStream(*buf); |
|
1182 |
writeStream.PushL(); |
|
1183 |
||
1184 |
//externalize ClientConversation |
|
1185 |
aClientConversation->ExternalizeL(writeStream); |
|
1186 |
||
1187 |
// Results are already packed in the stream |
|
1188 |
writeStream.CommitL(); |
|
1189 |
// -------------------------------------------------------------- |
|
1190 |
||
1191 |
// 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
|
1192 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1193 |
|
31 | 1194 |
TPtr8 ptr(des->Des()); |
1195 |
buf->Read(0, ptr, buf->Size()); |
|
1196 |
||
1197 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
1198 |
||
1199 |
iAsyncReqRMessage.Write(1, *des); |
|
1200 |
iAsyncReqRMessage.Complete(EDeleteConversationEvent); |
|
1201 |
delete des; |
|
1202 |
iNotifyHandling = EFalse; |
|
1203 |
} |
|
1204 |
||
1205 |
PRINT ( _L("End CCsSession::HandleDeleteConversationEventL") ); |
|
1206 |
} |
|
1207 |
||
1208 |
// ---------------------------------------------------------------------------- |
|
1209 |
// CCsSession::HandleModifyConversationEventL |
|
1210 |
// the function to handles the modify conversation event received from cache |
|
1211 |
// asynchronously |
|
1212 |
// ---------------------------------------------------------------------------- |
|
1213 |
void CCsSession::HandleModifyConversationEventL( |
|
1214 |
CCsClientConversation* aClientConversation) |
|
1215 |
{ |
|
1216 |
PRINT ( _L("Enter CCsSession::HandleModifyConversationEventL") ); |
|
1217 |
||
1218 |
if (!iConversationChangeObserver) |
|
1219 |
return; |
|
1220 |
||
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1221 |
//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
|
1222 |
//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
|
1223 |
//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
|
1224 |
// else dont send |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1225 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1226 |
if ((aClientConversation->GetContactId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1227 |
iMonitoredConversation->GetContactId() && |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1228 |
aClientConversation->GetContactId() != -1) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1229 |
||(aClientConversation->GetConversationEntryId() == |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1230 |
iMonitoredConversation->GetConversationEntryId())) |
31 | 1231 |
{ |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1232 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1233 |
if (! (iNotifyHandling)) |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1234 |
{ |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1235 |
//append in notify list |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1236 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1237 |
CleanupStack::PushL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1238 |
conversationEvent->SetClientConversationL(*aClientConversation); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1239 |
conversationEvent->SetEvent(KConversationEventUpdate); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1240 |
iEventList->AppendL(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1241 |
CleanupStack::Pop(conversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1242 |
} |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1243 |
else |
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 |
// 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
|
1246 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1247 |
CleanupStack::PushL(buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1248 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1249 |
RBufWriteStream writeStream(*buf); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1250 |
writeStream.PushL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1251 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1252 |
//externalize ClientConversation |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1253 |
aClientConversation->ExternalizeL(writeStream); |
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 |
// Results are already packed in the stream |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1256 |
writeStream.CommitL(); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1257 |
// -------------------------------------------------------------- |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1258 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1259 |
// 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
|
1260 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1261 |
TPtr8 ptr(des->Des()); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1262 |
buf->Read(0, ptr, buf->Size()); |
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 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1265 |
|
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1266 |
iAsyncReqRMessage.Write(1, *des); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1267 |
iAsyncReqRMessage.Complete(EModifyConversationEvent); |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1268 |
delete des; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1269 |
iNotifyHandling = EFalse; |
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
1270 |
} |
31 | 1271 |
} |
1272 |
PRINT ( _L("End CCsSession::HandleModifyConversationEventL") ); |
|
1273 |
} |
|
1274 |
||
1275 |
// ---------------------------------------------------------------------------- |
|
1276 |
// CCsSession::NotifyClient |
|
1277 |
// The function to notify client for cache change event |
|
1278 |
// ---------------------------------------------------------------------------- |
|
1279 |
void CCsSession::NotifyClient(CCsConversationEvent* aConversationEvent) |
|
1280 |
{ |
|
1281 |
if (aConversationEvent->IsNewConversationListEventSet()) |
|
1282 |
{ |
|
1283 |
iAsyncReqRMessage.Complete(EAddConversationListEvent); |
|
1284 |
} |
|
1285 |
else if (aConversationEvent->IsDeleteConversationListEventSet()) |
|
1286 |
{ |
|
1287 |
iAsyncReqRMessage.Complete(EDeleteConversationListEvent); |
|
1288 |
} |
|
1289 |
else if (aConversationEvent->IsUpdateConversationListEventSet()) |
|
1290 |
{ |
|
1291 |
iAsyncReqRMessage.Complete(EModifyConversationListEvent); |
|
1292 |
} |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1293 |
else if(aConversationEvent->IsPartialDeleteConversationListEventSet()) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1294 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1295 |
iAsyncReqRMessage.Complete(EPartialDeleteConversationListEvent); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1296 |
} |
31 | 1297 |
else if (aConversationEvent->IsNewConversationEventSet()) |
1298 |
{ |
|
1299 |
iAsyncReqRMessage.Complete(EAddConversationEvent); |
|
1300 |
} |
|
1301 |
else if (aConversationEvent->IsDeleteConversationEventSet()) |
|
1302 |
{ |
|
1303 |
iAsyncReqRMessage.Complete(EDeleteConversationEvent); |
|
1304 |
} |
|
1305 |
else if (aConversationEvent->IsUpdateConversationEventSet()) |
|
1306 |
{ |
|
1307 |
iAsyncReqRMessage.Complete(EModifyConversationEvent); |
|
1308 |
} |
|
1309 |
else if (aConversationEvent->IsRefreshConversationListEventSet()) |
|
1310 |
{ |
|
1311 |
iAsyncReqRMessage.Complete(KConversationEventListRefresh); |
|
1312 |
} |
|
1313 |
else if (aConversationEvent->IsRefreshConversationEventSet()) |
|
1314 |
{ |
|
1315 |
iAsyncReqRMessage.Complete(KConversationEventRefresh); |
|
1316 |
} |
|
1317 |
} |
|
1318 |
||
1319 |
// ---------------------------------------------------------------------------- |
|
1320 |
// CCsSession::HandleChangeEventL |
|
1321 |
// The function handles cache change events |
|
1322 |
// ---------------------------------------------------------------------------- |
|
1323 |
void CCsSession::HandleChangeEventL(CCsClientConversation* aConversation, |
|
1324 |
TUint32 aEvent) |
|
1325 |
{ |
|
1326 |
if (aEvent & KConversationListEventNew) |
|
1327 |
{ |
|
1328 |
HandleNewConversationListEventL(aConversation); |
|
1329 |
} |
|
1330 |
else if (aEvent & KConversationListEventUpdate) |
|
1331 |
{ |
|
1332 |
HandleModifyConversationListEventL(aConversation); |
|
1333 |
} |
|
1334 |
else if (aEvent & KConversationListEventDelete) |
|
1335 |
{ |
|
1336 |
HandleDeleteConversationListEventL(aConversation); |
|
1337 |
} |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1338 |
else if(aEvent & KConversationListEventPartialDelete) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1339 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1340 |
HandlePartialDeleteConversationListEvent(aConversation); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1341 |
} |
31 | 1342 |
else if (aEvent & KConversationEventNew) |
1343 |
{ |
|
1344 |
HandleNewConversationEventL(aConversation); |
|
1345 |
} |
|
1346 |
else if (aEvent & KConversationEventUpdate) |
|
1347 |
{ |
|
1348 |
HandleModifyConversationEventL(aConversation); |
|
1349 |
} |
|
1350 |
else if (aEvent & KConversationEventDelete) |
|
1351 |
{ |
|
1352 |
HandleDeleteConversationEventL(aConversation); |
|
1353 |
} |
|
1354 |
else if (aEvent & KConversationEventListRefresh) |
|
1355 |
{ |
|
1356 |
HandleRefreshConversationListL(); |
|
1357 |
} |
|
1358 |
else if (aEvent & KConversationEventRefresh) |
|
1359 |
{ |
|
1360 |
HandleRefreshConversationL(); |
|
1361 |
} |
|
1362 |
} |
|
1363 |
||
1364 |
// ---------------------------------------------------------------------------- |
|
1365 |
// CCsSession::DeleteConversationL |
|
1366 |
// ---------------------------------------------------------------------------- |
|
1367 |
void CCsSession::DeleteConversationL(const RMessage2& aMessage) |
|
1368 |
{ |
|
1369 |
PRINT ( _L("Enter CCsSession::DeleteConversationL") ); |
|
1370 |
||
1371 |
TInt conversationId = aMessage.Int0(); |
|
1372 |
||
1373 |
// Delete handler |
|
1374 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1375 |
CCsConversationDeleteHandler* deleteHandler = |
|
1376 |
CCsConversationDeleteHandler::NewL(cache); |
|
1377 |
||
1378 |
deleteHandler->DeleteL(conversationId); |
|
1379 |
aMessage.Complete(EUserDeleteConversationComplete); |
|
1380 |
||
1381 |
PRINT ( _L("End CCsSession::DeleteConversationL") ); |
|
1382 |
} |
|
1383 |
||
1384 |
// ---------------------------------------------------------------------------- |
|
1385 |
// CCsSession::HandleRefreshConversationListL |
|
1386 |
// ---------------------------------------------------------------------------- |
|
1387 |
void CCsSession::HandleRefreshConversationListL() |
|
1388 |
{ |
|
1389 |
if (!iConversationListChangeObserver) |
|
1390 |
return; |
|
1391 |
||
1392 |
if (! (iNotifyHandling)) |
|
1393 |
{ |
|
1394 |
// Append in notify list |
|
1395 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
1396 |
CleanupStack::PushL(conversationEvent); |
|
1397 |
conversationEvent->SetEvent(KConversationEventListRefresh); |
|
1398 |
iEventList->AppendL(conversationEvent); |
|
1399 |
CleanupStack::Pop(conversationEvent); |
|
1400 |
} |
|
1401 |
else |
|
1402 |
{ |
|
1403 |
iAsyncReqRMessage.Complete(ERefreshConversationListEvent); |
|
1404 |
iNotifyHandling = EFalse; |
|
1405 |
} |
|
1406 |
} |
|
1407 |
||
1408 |
// ---------------------------------------------------------------------------- |
|
1409 |
// CCsSession::HandleRefreshConversationL |
|
1410 |
// ---------------------------------------------------------------------------- |
|
1411 |
void CCsSession::HandleRefreshConversationL() |
|
1412 |
{ |
|
1413 |
if (!iConversationChangeObserver) |
|
1414 |
return; |
|
1415 |
||
1416 |
if (! (iNotifyHandling)) |
|
1417 |
{ |
|
1418 |
// Append in notify list |
|
1419 |
CCsConversationEvent* conversationEvent = CCsConversationEvent::NewL(); |
|
1420 |
CleanupStack::PushL(conversationEvent); |
|
1421 |
conversationEvent->SetEvent(KConversationEventRefresh); |
|
1422 |
iEventList->AppendL(conversationEvent); |
|
1423 |
CleanupStack::Pop(conversationEvent); |
|
1424 |
} |
|
1425 |
else |
|
1426 |
{ |
|
1427 |
iAsyncReqRMessage.Complete(ERefreshConversationEvent); |
|
1428 |
iNotifyHandling = EFalse; |
|
1429 |
} |
|
1430 |
} |
|
1431 |
||
1432 |
// ---------------------------------------------------------------------------- |
|
1433 |
// Get conversation id |
|
1434 |
// ---------------------------------------------------------------------------- |
|
1435 |
void CCsSession::GetConversationIdL(const RMessage2& aMessage) |
|
1436 |
{ |
|
1437 |
// create a new buffer for writing into stream |
|
1438 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
1439 |
||
1440 |
CleanupStack::PushL(buf); |
|
1441 |
RBufWriteStream writeStream(*buf); |
|
1442 |
writeStream.PushL(); |
|
1443 |
||
1444 |
// Get the contact id |
|
1445 |
TInt contactId = aMessage.Int0(); |
|
1446 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1447 |
TInt conversationId = cache->GetConversationIdL(contactId); |
|
1448 |
||
1449 |
// Externalize link |
|
1450 |
writeStream.WriteInt32L(conversationId); |
|
1451 |
||
1452 |
// Results are already packed in the stream |
|
1453 |
writeStream.CommitL(); |
|
1454 |
||
1455 |
// 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
|
1456 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 1457 |
TPtr8 ptr(des->Des()); |
1458 |
buf->Read(0, ptr, buf->Size()); |
|
1459 |
||
1460 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
1461 |
||
1462 |
aMessage.Write(1, *des); |
|
1463 |
aMessage.Complete(EGetConversationIdComplete); |
|
1464 |
delete des; |
|
1465 |
} |
|
1466 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1467 |
void CCsSession::GetConversationFromConversationIdL(const RMessage2& aMessage) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1468 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1469 |
// 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
|
1470 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1471 |
CleanupStack::PushL(buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1472 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1473 |
RBufWriteStream writeStream(*buf); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1474 |
writeStream.PushL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1475 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1476 |
// Get the conversation id |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1477 |
TInt conversationId = aMessage.Int0(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1478 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1479 |
CCsClientConversation* clientConv = cache->GetConversationFromConversationIdL(conversationId); |
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 |
// 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
|
1482 |
// create a dummy conversation and complete response |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1483 |
if(clientConv == NULL) |
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 |
//create dummy conversation |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1486 |
clientConv = CCsClientConversation::NewL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1487 |
CleanupStack::PushL(clientConv); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1488 |
clientConv->SetConversationEntryId(-1); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1489 |
CCsConversationEntry* entry = CCsConversationEntry::NewL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1490 |
CleanupStack::PushL(entry); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1491 |
entry->SetEntryId(-1); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1492 |
clientConv->SetConversationEntryL(entry); // clone |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1493 |
CleanupStack::PopAndDestroy(entry); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1494 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1495 |
else |
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 |
CleanupStack::PushL(clientConv); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1498 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1499 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1500 |
// Externalize |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1501 |
clientConv->ExternalizeL(writeStream); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1502 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1503 |
// Results are already packed in the stream |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1504 |
writeStream.CommitL(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1505 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1506 |
// Create a heap descriptor from the buffer |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1507 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1508 |
TPtr8 ptr(des->Des()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1509 |
buf->Read(0, ptr, buf->Size()); |
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 |
CleanupStack::PopAndDestroy(3, buf); // clientConv, writestream, buf |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1512 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1513 |
aMessage.Write(1, *des); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1514 |
aMessage.Complete(EGetConversationFromConversationIdComplete); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1515 |
delete des; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1516 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
1517 |
|
31 | 1518 |
// ---------------------------------------------------------------------------- |
1519 |
// GetConversationFromMessageIdL |
|
1520 |
// ---------------------------------------------------------------------------- |
|
1521 |
void CCsSession::GetConversationFromMessageIdL(const RMessage2& aMessage) |
|
1522 |
{ |
|
1523 |
// create a new buffer for writing into stream |
|
1524 |
CBufFlat* buf = CBufFlat::NewL(KBigBuffer); |
|
1525 |
CleanupStack::PushL(buf); |
|
1526 |
||
1527 |
RBufWriteStream writeStream(*buf); |
|
1528 |
writeStream.PushL(); |
|
1529 |
||
1530 |
// Get the message id |
|
1531 |
TInt messageId = aMessage.Int0(); |
|
1532 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1533 |
CCsClientConversation* conversation = cache->GetConversationFromMessageIdL(messageId); |
|
1534 |
||
1535 |
// if no conversation exists for given message-id, |
|
1536 |
// create a dummy conversation and complete response |
|
1537 |
if(conversation == NULL) |
|
1538 |
{ |
|
1539 |
//create dummy conversation |
|
1540 |
conversation = CCsClientConversation::NewL(); |
|
1541 |
CleanupStack::PushL(conversation); |
|
1542 |
conversation->SetConversationEntryId(-1); |
|
1543 |
CCsConversationEntry* entry = CCsConversationEntry::NewL(); |
|
1544 |
CleanupStack::PushL(entry); |
|
1545 |
entry->SetEntryId(-1); |
|
1546 |
conversation->SetConversationEntryL(entry); // clone |
|
1547 |
CleanupStack::PopAndDestroy(entry); |
|
1548 |
} |
|
1549 |
else |
|
1550 |
{ |
|
1551 |
CleanupStack::PushL(conversation); |
|
1552 |
} |
|
1553 |
||
1554 |
// Externalize |
|
1555 |
conversation->ExternalizeL(writeStream); |
|
1556 |
||
1557 |
// Results are already packed in the stream |
|
1558 |
writeStream.CommitL(); |
|
1559 |
||
1560 |
// 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
|
1561 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 1562 |
TPtr8 ptr(des->Des()); |
1563 |
buf->Read(0, ptr, buf->Size()); |
|
1564 |
||
1565 |
CleanupStack::PopAndDestroy(3, buf); // conversation, writestream, buf |
|
1566 |
||
1567 |
aMessage.Write(1, *des); |
|
1568 |
aMessage.Complete(EGetConversationFromMessageIdComplete); |
|
1569 |
delete des; |
|
1570 |
} |
|
1571 |
||
1572 |
// ---------------------------------------------------------------------------- |
|
1573 |
// CCsSession::GetConversationIdfromAddressL |
|
1574 |
// ---------------------------------------------------------------------------- |
|
1575 |
void CCsSession::GetConversationIdfromAddressL(const RMessage2& aMessage) |
|
1576 |
{ |
|
1577 |
TInt deslen = aMessage.GetDesLength(0); |
|
1578 |
||
1579 |
// Copy the data into a buffer |
|
1580 |
RBuf buffer; |
|
1581 |
buffer.CreateL(deslen); |
|
1582 |
buffer.CleanupClosePushL(); |
|
1583 |
aMessage.ReadL(0,buffer,0); |
|
1584 |
||
1585 |
||
1586 |
// Get the contact id |
|
1587 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1588 |
TInt conversationId = cache->GetConversationIdFromAddressL(buffer); |
|
1589 |
||
1590 |
// create a new buffer for writing into stream |
|
1591 |
CBufFlat* buf = CBufFlat::NewL(KTinyBuffer); |
|
1592 |
CleanupStack::PushL(buf); |
|
1593 |
||
1594 |
RBufWriteStream writeStream(*buf); |
|
1595 |
writeStream.PushL(); |
|
1596 |
// Externalize link |
|
1597 |
writeStream.WriteInt32L(conversationId); |
|
1598 |
||
1599 |
// Results are already packed in the stream |
|
1600 |
writeStream.CommitL(); |
|
1601 |
||
1602 |
// 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
|
1603 |
HBufC8* des = HBufC8::NewL(buf->Size()); |
31 | 1604 |
TPtr8 ptr(des->Des()); |
1605 |
buf->Read(0, ptr, buf->Size()); |
|
1606 |
||
1607 |
CleanupStack::PopAndDestroy(2, buf); // writestream, buf |
|
1608 |
CleanupStack::PopAndDestroy(&buffer); |
|
1609 |
||
1610 |
aMessage.Write(1, *des); |
|
1611 |
aMessage.Complete(EGetConversationIdFromAddressComplete); |
|
1612 |
delete des; |
|
1613 |
} |
|
1614 |
||
1615 |
// ---------------------------------------------------------------------------- |
|
1616 |
// CCsSession::MarkConversationReadL |
|
1617 |
// ---------------------------------------------------------------------------- |
|
1618 |
void CCsSession::MarkConversationReadL(const RMessage2& aMessage) |
|
1619 |
{ |
|
1620 |
PRINT ( _L("Enter CCsSession::MarkConversationReadL") ); |
|
1621 |
||
1622 |
TInt conversationId = aMessage.Int0(); |
|
1623 |
||
1624 |
// Mark read handler |
|
1625 |
CCsConversationCache* cache = iServer->ConversationCacheInterface(); |
|
1626 |
CCsConversationMarkReadHandler* markHandler = CCsConversationMarkReadHandler::NewL(cache); |
|
1627 |
||
1628 |
markHandler->MarkReadL(conversationId); |
|
1629 |
||
1630 |
aMessage.Complete(EUserMarkReadConversationComplete); |
|
1631 |
||
1632 |
PRINT ( _L("End CCsSession::MarkConversationReadL") ); |
|
1633 |
} |
|
1634 |
//EOF |