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: This is the client side interface for the conversation
|
|
15 |
* server.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
|
|
22 |
// SYSTEM INCLUDES
|
|
23 |
#include <ccsconversationentry.h>
|
|
24 |
#include <ccsclientconversation.h>
|
|
25 |
#include <mcsresultsobserver.h>
|
|
26 |
#include <mcsconversationlistchangeobserver.h>
|
|
27 |
#include <mcsconversationchangeobserver.h>
|
|
28 |
#include <mcscachingstatusobserver.h>
|
|
29 |
#include <ccsrequesthandler.h>
|
|
30 |
#include <rcssession.h>
|
|
31 |
#include <ccsnotificationhandler.h>
|
|
32 |
|
|
33 |
//USER INCLUDES
|
|
34 |
#include "ccsdebug.h"
|
|
35 |
#include "ccsconversationchangeobserver.h"
|
|
36 |
|
|
37 |
const TInt KSmallIpcBuffer = 256; //256 bytes
|
|
38 |
const TInt KBigIpcBuffer = 2048; // 2K
|
|
39 |
|
|
40 |
// ========================= MEMBER FUNCTIONS ==================================
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CCSRequestHandler::NewL()
|
|
44 |
// Two-phased constructor.
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
EXPORT_C CCSRequestHandler* CCSRequestHandler::NewL()
|
|
47 |
{
|
|
48 |
PRINT ( _L("Enter CCSRequestHandler::NewL") );
|
|
49 |
|
|
50 |
CCSRequestHandler* self = NewLC( );
|
|
51 |
CleanupStack::Pop( self );
|
|
52 |
|
|
53 |
PRINT ( _L("End CCSRequestHandler::NewL") );
|
|
54 |
|
|
55 |
return( self ) ;
|
|
56 |
}
|
|
57 |
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
// CCSRequestHandler::NewLC()
|
|
60 |
// Two-phased constructor.
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
EXPORT_C CCSRequestHandler* CCSRequestHandler::NewLC(/*CVPbkContactManager* aVPbkContactManager*/)
|
|
63 |
{
|
|
64 |
PRINT ( _L("Enter CCSRequestHandler::NewLC") );
|
|
65 |
|
|
66 |
CCSRequestHandler* self = new ( ELeave ) CCSRequestHandler();
|
|
67 |
CleanupStack::PushL( self );
|
|
68 |
self->ConstructL(/*aVPbkContactManager*/);
|
|
69 |
|
|
70 |
PRINT ( _L("End CCSRequestHandler::NewLC") );
|
|
71 |
|
|
72 |
return self;
|
|
73 |
}
|
|
74 |
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
// CCSRequestHandler::CCSAsyncRequestHandler()
|
|
77 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
CCSRequestHandler::CCSRequestHandler()
|
|
80 |
: CActive( EPriorityStandard )
|
|
81 |
{
|
|
82 |
CActiveScheduler::Add( this );
|
|
83 |
}
|
|
84 |
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
// CCSRequestHandler::ConstructL()
|
|
87 |
// Symbian 2nd phase constructor can leave.
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
void CCSRequestHandler::ConstructL()
|
|
90 |
{
|
|
91 |
PRINT ( _L("Enter CCSRequestHandler::ConstructL") );
|
|
92 |
|
|
93 |
User::LeaveIfError( iSession.Connect() );
|
|
94 |
|
|
95 |
// Notification handler
|
|
96 |
iNotificationHandler = CCsNotificationHandler::NewL(this);
|
|
97 |
|
|
98 |
// Observers
|
|
99 |
iResultsObserver = NULL;
|
|
100 |
iCachingStatusObserver = NULL;
|
|
101 |
iConversationListChangeObserver = NULL;
|
|
102 |
iConversationChangeObserver = NULL;
|
|
103 |
|
|
104 |
PRINT ( _L("End CCSRequestHandler::ConstructL") );
|
|
105 |
}
|
|
106 |
|
|
107 |
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
// CCSRequestHandler::~CCSRequestHandler()
|
|
110 |
// Destructor.
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
CCSRequestHandler::~CCSRequestHandler()
|
|
113 |
{
|
|
114 |
PRINT ( _L("Enter CCSRequestHandler::~CCSRequestHandler") );
|
|
115 |
|
|
116 |
Cancel();
|
|
117 |
|
|
118 |
// Cleanup
|
|
119 |
if ( iBuffer )
|
|
120 |
{
|
|
121 |
delete iBuffer;
|
|
122 |
iBuffer = NULL;
|
|
123 |
}
|
|
124 |
|
|
125 |
if ( iResultsBuffer )
|
|
126 |
{
|
|
127 |
delete iResultsBuffer;
|
|
128 |
iResultsBuffer = NULL;
|
|
129 |
}
|
|
130 |
|
|
131 |
if ( iNotificationHandler )
|
|
132 |
{
|
|
133 |
delete iNotificationHandler;
|
|
134 |
iNotificationHandler = NULL;
|
|
135 |
}
|
|
136 |
|
|
137 |
if( iListResultsBuffer )
|
|
138 |
{
|
|
139 |
delete iListResultsBuffer;
|
|
140 |
iListResultsBuffer=NULL;
|
|
141 |
}
|
|
142 |
if( iConvResultsBuffer )
|
|
143 |
{
|
|
144 |
delete iConvResultsBuffer;
|
|
145 |
iConvResultsBuffer=NULL;
|
|
146 |
}
|
|
147 |
|
|
148 |
// Close the session
|
|
149 |
iSession.Close();
|
|
150 |
|
|
151 |
PRINT ( _L("End CCSRequestHandler::~CCSRequestHandler") );
|
|
152 |
}
|
|
153 |
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
// CCSRequestHandler::HandleGetConversationListResults()
|
|
156 |
// This shall handle all entry list result from server
|
|
157 |
//
|
|
158 |
// -----------------------------------------------------------------------------
|
|
159 |
void CCSRequestHandler::HandleGetConversationListResults()
|
|
160 |
{
|
|
161 |
PRINT( _L("Enter CCSRequestHandler::HandleGetConversationListResults") );
|
|
162 |
|
|
163 |
TInt error = KErrNone;
|
|
164 |
RPointerArray<CCsClientConversation> clientConversationList;
|
|
165 |
|
|
166 |
// Parse the results
|
|
167 |
RDesReadStream resultStream(iListResultsBuffer->Des());
|
|
168 |
TInt listCount = 0;
|
|
169 |
|
|
170 |
TRAP(error,
|
|
171 |
resultStream.PushL();
|
|
172 |
listCount = resultStream.ReadUint16L();
|
|
173 |
resultStream.Pop()
|
|
174 |
);
|
|
175 |
|
|
176 |
if(error != KErrNone)
|
|
177 |
{
|
|
178 |
//call panic
|
|
179 |
}
|
|
180 |
|
|
181 |
for (TInt iloop = 0 ; iloop < listCount; iloop++)
|
|
182 |
{
|
|
183 |
TRAP(error,
|
|
184 |
resultStream.PushL();
|
|
185 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL();
|
|
186 |
CleanupStack::PushL(clientConversation);
|
|
187 |
clientConversation->InternalizeL(resultStream);
|
|
188 |
clientConversationList.AppendL(clientConversation);
|
|
189 |
CleanupStack::Pop(clientConversation);
|
|
190 |
resultStream.Pop()
|
|
191 |
);
|
|
192 |
|
|
193 |
if(error != KErrNone)
|
|
194 |
{
|
|
195 |
//call panic
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
// Clear all the internal buffers
|
|
200 |
// Cleanup
|
|
201 |
delete iListResultsBuffer;
|
|
202 |
iListResultsBuffer = NULL;
|
|
203 |
|
|
204 |
resultStream.Close();
|
|
205 |
|
|
206 |
// Pass the results to the observer
|
|
207 |
if ( iResultsObserver )
|
|
208 |
{
|
|
209 |
iResultsObserver->ConversationList(clientConversationList);
|
|
210 |
}
|
|
211 |
|
|
212 |
clientConversationList.ResetAndDestroy();
|
|
213 |
|
|
214 |
PRINT( _L("End CCSRequestHandler::HandleGetConversationListResults") );
|
|
215 |
}
|
|
216 |
|
|
217 |
// -----------------------------------------------------------------------------
|
|
218 |
// CCSRequestHandler::HandleGetConversationResults()
|
|
219 |
// This shall handle GetCoversation results async from server
|
|
220 |
//
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
void CCSRequestHandler::HandleGetConversationResults()
|
|
223 |
{
|
|
224 |
PRINT( _L("Enter CCSRequestHandler::HandleGetConversationResults") );
|
|
225 |
|
|
226 |
TInt error = KErrNone;
|
|
227 |
|
|
228 |
RPointerArray<CCsConversationEntry> ConversationEntryList;
|
|
229 |
// Parse the results
|
|
230 |
RDesReadStream resultStream(iConvResultsBuffer->Des());
|
|
231 |
TInt conversationEntryCount = 0;
|
|
232 |
|
|
233 |
TRAP(error, resultStream.PushL();
|
|
234 |
|
|
235 |
conversationEntryCount = resultStream.ReadInt32L();
|
|
236 |
|
|
237 |
resultStream.Pop());
|
|
238 |
|
|
239 |
if(error != KErrNone)
|
|
240 |
{
|
|
241 |
//call panic
|
|
242 |
}
|
|
243 |
|
|
244 |
PRINT1 ( _L("Number of conversation entries = %d"), conversationEntryCount );
|
|
245 |
|
|
246 |
// conversation entries
|
|
247 |
for ( TInt iloop = 0; iloop < conversationEntryCount; iloop++ )
|
|
248 |
{
|
|
249 |
TRAP(error,
|
|
250 |
resultStream.PushL();
|
|
251 |
|
|
252 |
CCsConversationEntry* conversationEntry = CCsConversationEntry::NewL();
|
|
253 |
CleanupStack::PushL(conversationEntry);
|
|
254 |
|
|
255 |
conversationEntry->InternalizeL(resultStream);
|
|
256 |
ConversationEntryList.AppendL(conversationEntry);
|
|
257 |
|
|
258 |
CleanupStack::Pop(conversationEntry);
|
|
259 |
resultStream.Pop());
|
|
260 |
|
|
261 |
if(error != KErrNone)
|
|
262 |
{
|
|
263 |
//call panic
|
|
264 |
}
|
|
265 |
}
|
|
266 |
|
|
267 |
// Cleanup
|
|
268 |
if ( iBuffer )
|
|
269 |
{
|
|
270 |
delete iBuffer;
|
|
271 |
iBuffer = NULL;
|
|
272 |
}
|
|
273 |
delete iConvResultsBuffer;
|
|
274 |
iConvResultsBuffer = NULL;
|
|
275 |
|
|
276 |
resultStream.Close();
|
|
277 |
|
|
278 |
// Pass the results to the observer
|
|
279 |
if ( iResultsObserver )
|
|
280 |
{
|
|
281 |
iResultsObserver->Conversations(ConversationEntryList);
|
|
282 |
}
|
|
283 |
|
|
284 |
// cleanup heap data
|
|
285 |
ConversationEntryList.ResetAndDestroy();
|
|
286 |
|
|
287 |
PRINT_TIMESTAMP ("End CCSRequestHandler::HandleGetConversationResults");
|
|
288 |
}
|
|
289 |
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
// CCSRequestHandler::HandleGetEntryListOverflow()
|
|
292 |
// Handle the buffer overflow error for get entry list results
|
|
293 |
// -----------------------------------------------------------------------------
|
|
294 |
void CCSRequestHandler::HandleGetConversationListOverflow()
|
|
295 |
{
|
|
296 |
PRINT ( _L("Enter CCSRequestHandler::HandleGetConversationListOverflow") );
|
|
297 |
|
|
298 |
if ( !iListResultsBuffer )
|
|
299 |
{
|
|
300 |
return;
|
|
301 |
}
|
|
302 |
TInt error = KErrNone;
|
|
303 |
|
|
304 |
// New buffer size is now stored in results buffer
|
|
305 |
RDesReadStream stream(iListResultsBuffer->Des());
|
|
306 |
TInt bufferSize = 0;
|
|
307 |
|
|
308 |
TRAP(error,
|
|
309 |
stream.PushL();
|
|
310 |
bufferSize = stream.ReadInt32L();
|
|
311 |
stream.Pop()
|
|
312 |
);
|
|
313 |
|
|
314 |
if(error != KErrNone)
|
|
315 |
{
|
|
316 |
//call panic
|
|
317 |
}
|
|
318 |
|
|
319 |
stream.Close();
|
|
320 |
|
|
321 |
// Delete and recreate the results buffer
|
|
322 |
delete iListResultsBuffer;
|
|
323 |
iListResultsBuffer = NULL;
|
|
324 |
|
|
325 |
// Buffer created for the new size
|
|
326 |
TRAP(error,
|
|
327 |
iListResultsBuffer = HBufC8::NewL(bufferSize);
|
|
328 |
iSession.GetConversationListL(iListResultsBuffer->Des(),iStatus)
|
|
329 |
);
|
|
330 |
|
|
331 |
if(error != KErrNone)
|
|
332 |
{
|
|
333 |
//call panic
|
|
334 |
}
|
|
335 |
SetActive();
|
|
336 |
|
|
337 |
PRINT ( _L("End CCSRequestHandler::HandleGetEntryListOverflow") );
|
|
338 |
}
|
|
339 |
|
|
340 |
// -----------------------------------------------------------------------------
|
|
341 |
// CCSRequestHandler::HandleGetConversationOverflow()
|
|
342 |
// Handle the buffer overflow error for get conversation results
|
|
343 |
// -----------------------------------------------------------------------------
|
|
344 |
void CCSRequestHandler::HandleGetConversationOverflow()
|
|
345 |
{
|
|
346 |
PRINT ( _L("Enter CCSRequestHandler::HandleGetConversationOverflow") );
|
|
347 |
|
|
348 |
if ( !iConvResultsBuffer )
|
|
349 |
{
|
|
350 |
return;
|
|
351 |
}
|
|
352 |
TInt error = KErrNone;
|
|
353 |
|
|
354 |
// New buffer size is now stored in results buffer
|
|
355 |
RDesReadStream stream(iConvResultsBuffer->Des());
|
|
356 |
TInt bufferSize = 0;
|
|
357 |
|
|
358 |
// Read the buffer size and create a new buffer
|
|
359 |
TRAP(error,
|
|
360 |
stream.PushL();
|
|
361 |
bufferSize = stream.ReadInt32L();
|
|
362 |
stream.Pop()
|
|
363 |
);
|
|
364 |
|
|
365 |
if(error != KErrNone)
|
|
366 |
{
|
|
367 |
//call panic
|
|
368 |
}
|
|
369 |
|
|
370 |
stream.Close();
|
|
371 |
|
|
372 |
// Delete and recreate the results buffer
|
|
373 |
delete iConvResultsBuffer;
|
|
374 |
iConvResultsBuffer = NULL;
|
|
375 |
|
|
376 |
// Buffer created for the new size
|
|
377 |
TRAP(error,
|
|
378 |
iConvResultsBuffer = HBufC8::NewL(bufferSize);
|
|
379 |
iSession.SendNewBufferGetConversationL(iConvResultsBuffer->Des(),iStatus)
|
|
380 |
);
|
|
381 |
|
|
382 |
if(error != KErrNone)
|
|
383 |
{
|
|
384 |
//call panic
|
|
385 |
}
|
|
386 |
|
|
387 |
SetActive();
|
|
388 |
|
|
389 |
PRINT ( _L("End CCSRequestHandler::HandleGetConversationListOverflow") );
|
|
390 |
}
|
|
391 |
|
|
392 |
// -----------------------------------------------------------------------------
|
|
393 |
// CCSRequestHandler::RequestResultsEventL()
|
|
394 |
// Add conversation result Observer
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
EXPORT_C void CCSRequestHandler::RequestResultsEventL(
|
|
397 |
MCsResultsObserver* aObserver)
|
|
398 |
{
|
|
399 |
iResultsObserver = aObserver;
|
|
400 |
}
|
|
401 |
|
|
402 |
// -----------------------------------------------------------------------------
|
|
403 |
// CCSRequestHandler::RemoveResultsEventL()
|
|
404 |
// Remove conversation result observer
|
|
405 |
// -----------------------------------------------------------------------------
|
|
406 |
EXPORT_C void CCSRequestHandler::RemoveResultsEventL
|
|
407 |
(MCsResultsObserver* /*aObserver*/)
|
|
408 |
{
|
|
409 |
iResultsObserver = NULL;
|
|
410 |
}
|
|
411 |
|
|
412 |
// -----------------------------------------------------------------------------
|
|
413 |
// CCSRequestHandler::RequestConversationListChangeEventL()
|
|
414 |
// Add conversation list change event Observer
|
|
415 |
// -----------------------------------------------------------------------------
|
|
416 |
EXPORT_C void CCSRequestHandler::RequestConversationListChangeEventL(
|
|
417 |
MCsConversationListChangeObserver* aObserver)
|
|
418 |
{
|
|
419 |
iConversationListChangeObserver = aObserver;
|
|
420 |
|
|
421 |
// Register to server.
|
|
422 |
iNotificationHandler->RequestConversationListChangeEventL();
|
|
423 |
}
|
|
424 |
|
|
425 |
// -----------------------------------------------------------------------------
|
|
426 |
// CCSRequestHandler::RemoveConversationListChangeEventL()
|
|
427 |
// Remove conversation list change event Observer
|
|
428 |
// -----------------------------------------------------------------------------
|
|
429 |
EXPORT_C void CCSRequestHandler::RemoveConversationListChangeEventL(
|
|
430 |
MCsConversationListChangeObserver* /*aObserver*/)
|
|
431 |
{
|
|
432 |
iConversationListChangeObserver = NULL;
|
|
433 |
|
|
434 |
// De-register from the server
|
|
435 |
iNotificationHandler->RemoveConversationListChangeEventL();
|
|
436 |
}
|
|
437 |
|
|
438 |
// -----------------------------------------------------------------------------
|
|
439 |
// CCSRequestHandler::RequestConversationChangeEventL()
|
|
440 |
// Add conversation change event Observer
|
|
441 |
// -----------------------------------------------------------------------------
|
|
442 |
EXPORT_C void CCSRequestHandler::RequestConversationChangeEventL(
|
|
443 |
MCsConversationChangeObserver* aObserver,
|
|
444 |
CCsClientConversation* aClientConversation)
|
|
445 |
{
|
|
446 |
CCsConversationChangeObserver* conChgObserver =
|
|
447 |
CCsConversationChangeObserver::NewL();
|
|
448 |
CleanupStack::PushL(conChgObserver);
|
|
449 |
conChgObserver->SetClientConversationL(*aClientConversation);
|
|
450 |
conChgObserver->SetConversationChangeObserverL(aObserver);
|
|
451 |
iConversationChangeObserver = conChgObserver;
|
|
452 |
CleanupStack::Pop(conChgObserver);
|
|
453 |
|
|
454 |
iNotificationHandler->RequestConversationChangeEventL(aClientConversation);
|
|
455 |
}
|
|
456 |
|
|
457 |
// -----------------------------------------------------------------------------
|
|
458 |
// CCSRequestHandler::RemoveConversationChangeEventL()
|
|
459 |
// Remove conversation change event observer
|
|
460 |
// -----------------------------------------------------------------------------
|
|
461 |
EXPORT_C void CCSRequestHandler::RemoveConversationChangeEventL(
|
|
462 |
MCsConversationChangeObserver* /*aObserver*/,
|
|
463 |
CCsClientConversation* aClientConversation)
|
|
464 |
{
|
|
465 |
if ( iConversationChangeObserver )
|
|
466 |
{
|
|
467 |
delete iConversationChangeObserver;
|
|
468 |
iConversationChangeObserver = NULL;
|
|
469 |
}
|
|
470 |
|
|
471 |
iNotificationHandler->RemoveConversationChangeEventL(aClientConversation);
|
|
472 |
}
|
|
473 |
|
|
474 |
// -----------------------------------------------------------------------------
|
|
475 |
// CCSRequestHandler::RequestCachingStatusEventL()
|
|
476 |
// Add caching status Observer
|
|
477 |
// -----------------------------------------------------------------------------
|
|
478 |
EXPORT_C void CCSRequestHandler::RequestCachingStatusEventL(
|
|
479 |
MCsCachingStatusObserver* /*aObserver*/)
|
|
480 |
{
|
|
481 |
User::Leave(KErrNotSupported);
|
|
482 |
}
|
|
483 |
|
|
484 |
// -----------------------------------------------------------------------------
|
|
485 |
// CCSRequestHandler::RemoveCachingStatusEventL()
|
|
486 |
// Remove caching status Observer
|
|
487 |
// -----------------------------------------------------------------------------
|
|
488 |
EXPORT_C void CCSRequestHandler::RemoveCachingStatusEventL(
|
|
489 |
MCsCachingStatusObserver* /*aObserver*/)
|
|
490 |
{
|
|
491 |
User::Leave(KErrNotSupported);
|
|
492 |
}
|
|
493 |
|
|
494 |
// -----------------------------------------------------------------------------
|
|
495 |
// CCSRequestHandler::RunL()
|
|
496 |
// Invoked to handle responses from the server.
|
|
497 |
// -----------------------------------------------------------------------------
|
|
498 |
void CCSRequestHandler::RunL()
|
|
499 |
{
|
|
500 |
switch ( iStatus.Int() )
|
|
501 |
{
|
|
502 |
case EGetConversationListOperationComplete:
|
|
503 |
HandleGetConversationListResults();
|
|
504 |
break;
|
|
505 |
|
|
506 |
case EGetConversationListBufferOverflow:
|
|
507 |
HandleGetConversationListOverflow();
|
|
508 |
break;
|
|
509 |
|
|
510 |
case EGetConversationOperationComplete:
|
|
511 |
HandleGetConversationResults();
|
|
512 |
break;
|
|
513 |
|
|
514 |
case EGetConversationBufferOverflow:
|
|
515 |
HandleGetConversationOverflow();
|
|
516 |
break;
|
|
517 |
|
|
518 |
default:
|
|
519 |
HandleErrorL(iStatus.Int());
|
|
520 |
break;
|
|
521 |
}
|
|
522 |
}
|
|
523 |
|
|
524 |
// -----------------------------------------------------------------------------
|
|
525 |
// CCSRequestHandler::HandleErrorL()
|
|
526 |
// Send the error code to the client.
|
|
527 |
// -----------------------------------------------------------------------------
|
|
528 |
void CCSRequestHandler::HandleErrorL(TInt /*aErrorCode*/)
|
|
529 |
{
|
|
530 |
// Not supported
|
|
531 |
}
|
|
532 |
|
|
533 |
// -----------------------------------------------------------------------------
|
|
534 |
// CCSRequestHandler::DoCancel()
|
|
535 |
// Cancels any outstanding operation.
|
|
536 |
// -----------------------------------------------------------------------------
|
|
537 |
void CCSRequestHandler::DoCancel()
|
|
538 |
{
|
|
539 |
// Do nothing
|
|
540 |
}
|
|
541 |
|
|
542 |
// -----------------------------------------------------------------------------
|
|
543 |
// CCSRequestHandler::Version()
|
|
544 |
// Recovers the conversation server version.
|
|
545 |
// -----------------------------------------------------------------------------
|
|
546 |
EXPORT_C TVersion CCSRequestHandler::Version() const
|
|
547 |
{
|
|
548 |
return (iSession.Version());
|
|
549 |
}
|
|
550 |
|
|
551 |
// -----------------------------------------------------------------------------
|
|
552 |
// CCSRequestHandler::ShutdownServerL()
|
|
553 |
// Shuts down the conversation server.
|
|
554 |
// -----------------------------------------------------------------------------
|
|
555 |
EXPORT_C void CCSRequestHandler::ShutdownServerL()
|
|
556 |
{
|
|
557 |
return (iSession.ShutdownServerL());
|
|
558 |
}
|
|
559 |
|
|
560 |
// -----------------------------------------------------------------------------
|
|
561 |
// CCSRequestHandler::GetConversationListL()
|
|
562 |
// Get Recent Conversation Entry list with display name
|
|
563 |
// for all stored conversation entry IDs.
|
|
564 |
// This API can be used to prepare conversation list view.
|
|
565 |
// -----------------------------------------------------------------------------
|
|
566 |
EXPORT_C void CCSRequestHandler::GetConversationListL()
|
|
567 |
{
|
|
568 |
PRINT( _L("Enter CCSRequestHandler::GetConversationListL") );
|
|
569 |
|
|
570 |
// ------------------------- Results Buffer ---------------------
|
|
571 |
|
|
572 |
// Create a buffer to store the search results.
|
|
573 |
if(iListResultsBuffer)
|
|
574 |
{
|
|
575 |
delete iListResultsBuffer;
|
|
576 |
iListResultsBuffer = NULL;
|
|
577 |
}
|
|
578 |
iListResultsBuffer = HBufC8::NewL(KBufferMaxLen);
|
|
579 |
|
|
580 |
// Send the ASYNC request
|
|
581 |
iSession.GetConversationListL(iListResultsBuffer->Des(),
|
|
582 |
iStatus);
|
|
583 |
SetActive();
|
|
584 |
|
|
585 |
PRINT( _L("End CCSRequestHandler::GetConversationListL") );
|
|
586 |
}
|
|
587 |
|
|
588 |
// -----------------------------------------------------------------------------
|
|
589 |
// CCSRequestHandler::GetConversationUnreadListL()
|
|
590 |
// Get Recent unread Conversation Entry list with display name
|
|
591 |
// for all stored conversation entry IDs.
|
|
592 |
// This API can be used to prepare conversation list view.
|
|
593 |
// -----------------------------------------------------------------------------
|
|
594 |
EXPORT_C void CCSRequestHandler::GetConversationUnreadListL(RPointerArray<
|
|
595 |
CCsClientConversation>* aClientConversationList)
|
|
596 |
{
|
|
597 |
PRINT( _L("Enter CCSRequestHandler::GetConversationUnreadListL") );
|
|
598 |
|
|
599 |
TInt resultBufferSize = KBufferMaxLen;
|
|
600 |
TInt isOverflow = EFalse;
|
|
601 |
TInt error = KErrNone;
|
|
602 |
|
|
603 |
HBufC8* overflow = HBufC8::NewL(sizeof(TInt));
|
|
604 |
CleanupStack::PushL(overflow);
|
|
605 |
|
|
606 |
do
|
|
607 |
{
|
|
608 |
|
|
609 |
// 1. Create fresh Result buffer.
|
|
610 |
if (iResultsBuffer)
|
|
611 |
{
|
|
612 |
delete iResultsBuffer;
|
|
613 |
iResultsBuffer = NULL;
|
|
614 |
}
|
|
615 |
iResultsBuffer = HBufC8::NewL(resultBufferSize);
|
|
616 |
|
|
617 |
// 2. Send the SYNC request.
|
|
618 |
iSession.GetConversationUnreadListL(overflow->Des(),
|
|
619 |
iResultsBuffer->Des());
|
|
620 |
|
|
621 |
// 3. Read Overflow status.
|
|
622 |
RDesReadStream overflowStream(overflow->Des());
|
|
623 |
|
|
624 |
TRAP(error,
|
|
625 |
overflowStream.PushL();
|
|
626 |
isOverflow = overflowStream.ReadUint16L();
|
|
627 |
overflowStream.Pop());
|
|
628 |
|
|
629 |
overflowStream.Close();
|
|
630 |
|
|
631 |
// 4. If Overflow, reset the result buffer size.
|
|
632 |
if (isOverflow)
|
|
633 |
{
|
|
634 |
// New buffer size is now stored in results buffer
|
|
635 |
RDesReadStream stream(iResultsBuffer->Des());
|
|
636 |
|
|
637 |
TRAP(error,
|
|
638 |
stream.PushL();
|
|
639 |
resultBufferSize = stream.ReadInt32L();
|
|
640 |
stream.Pop());
|
|
641 |
|
|
642 |
stream.Close();
|
|
643 |
}
|
|
644 |
}
|
|
645 |
while (isOverflow);
|
|
646 |
|
|
647 |
CleanupStack::PopAndDestroy(overflow);
|
|
648 |
|
|
649 |
// 5. No Overflow, Parse the results
|
|
650 |
RDesReadStream resultStream(iResultsBuffer->Des());
|
|
651 |
TInt listCount = 0;
|
|
652 |
|
|
653 |
TRAP(error,
|
|
654 |
resultStream.PushL();
|
|
655 |
listCount = resultStream.ReadUint16L();
|
|
656 |
resultStream.Pop()
|
|
657 |
);
|
|
658 |
|
|
659 |
for (TInt iloop = 0; iloop < listCount; iloop++)
|
|
660 |
{
|
|
661 |
TRAP(error,
|
|
662 |
resultStream.PushL();
|
|
663 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL();
|
|
664 |
CleanupStack::PushL(clientConversation);
|
|
665 |
clientConversation->InternalizeL(resultStream);
|
|
666 |
aClientConversationList->AppendL(clientConversation);
|
|
667 |
CleanupStack::Pop(clientConversation);
|
|
668 |
resultStream.Pop());
|
|
669 |
}
|
|
670 |
|
|
671 |
// Clear all the internal buffers
|
|
672 |
// Cleanup
|
|
673 |
delete iResultsBuffer;
|
|
674 |
iResultsBuffer = NULL;
|
|
675 |
resultStream.Close();
|
|
676 |
|
|
677 |
PRINT( _L("End CCSRequestHandler::GetConversationUnreadListL") );
|
|
678 |
}
|
|
679 |
|
|
680 |
// -----------------------------------------------------------------------------
|
|
681 |
// CCSRequestHandler::GetConversationsL()
|
|
682 |
// Get Conversation Entry list for given Conversation Entry ID to prepare
|
|
683 |
// convresation view.
|
|
684 |
// -----------------------------------------------------------------------------
|
|
685 |
EXPORT_C void CCSRequestHandler::GetConversationsL(
|
|
686 |
CCsClientConversation* aClientConversation)
|
|
687 |
{
|
|
688 |
PRINT( _L("Enter CCSRequestHandler::GetConversationsL") );
|
|
689 |
|
|
690 |
// check if the aclientconversation is null then return
|
|
691 |
if ( aClientConversation == NULL)
|
|
692 |
{
|
|
693 |
return;
|
|
694 |
}
|
|
695 |
|
|
696 |
//-------------------Contact-----------------------------
|
|
697 |
|
|
698 |
// Tmp buffer
|
|
699 |
CBufFlat* dataBuf = CBufFlat::NewL(KBufferMaxLen);
|
|
700 |
CleanupStack::PushL(dataBuf);
|
|
701 |
|
|
702 |
// Stream over the temp buffer
|
|
703 |
RBufWriteStream dataStream(*dataBuf);
|
|
704 |
dataStream.PushL();
|
|
705 |
|
|
706 |
// Write the Client Conversation in the stream
|
|
707 |
aClientConversation->ExternalizeL(dataStream);
|
|
708 |
dataStream.CommitL();
|
|
709 |
|
|
710 |
//------------------Input Buffer--------------------------
|
|
711 |
// Create a HBufC8 for IPC
|
|
712 |
iBuffer = HBufC8::NewL(dataBuf->Size());
|
|
713 |
TPtr8 dataPtr(iBuffer->Des());
|
|
714 |
dataBuf->Read(0, dataPtr, dataBuf->Size());
|
|
715 |
|
|
716 |
CleanupStack::PopAndDestroy(2, dataBuf);
|
|
717 |
|
|
718 |
// ------------------------- Results Buffer ---------------------
|
|
719 |
|
|
720 |
// Create a buffer to store the search results.
|
|
721 |
if(iConvResultsBuffer)
|
|
722 |
{
|
|
723 |
delete iConvResultsBuffer;
|
|
724 |
iConvResultsBuffer = NULL;
|
|
725 |
}
|
|
726 |
iConvResultsBuffer = HBufC8::NewL(KBufferMaxLen);
|
|
727 |
|
|
728 |
// Send the ASYNC request
|
|
729 |
iSession.GetConversationsL(iBuffer->Des(),
|
|
730 |
iConvResultsBuffer->Des(),
|
|
731 |
iStatus);
|
|
732 |
SetActive();
|
|
733 |
}
|
|
734 |
|
|
735 |
// -----------------------------------------------------------------------------
|
|
736 |
// CCSRequestHandler::GetCachingStatusL()
|
|
737 |
// Get caching status
|
|
738 |
// Synchronous
|
|
739 |
// -----------------------------------------------------------------------------
|
|
740 |
EXPORT_C TUint8 CCSRequestHandler::GetCachingStatusL()
|
|
741 |
{
|
|
742 |
PRINT ( _L("Enter CCSRequestHandler::GetCachingStatusL") );
|
|
743 |
|
|
744 |
// ------------------------- Results Buffer ---------------------
|
|
745 |
// Create a buffer to store the results.
|
|
746 |
if(iResultsBuffer)
|
|
747 |
{
|
|
748 |
delete iResultsBuffer;
|
|
749 |
iResultsBuffer = NULL;
|
|
750 |
}
|
|
751 |
iResultsBuffer = HBufC8::NewL(KBufferMaxLen);
|
|
752 |
|
|
753 |
// --------------------------------------------------------------
|
|
754 |
|
|
755 |
// Send the request
|
|
756 |
iSession.GetCachingStatusL(iResultsBuffer->Des());
|
|
757 |
|
|
758 |
// Parse the results
|
|
759 |
RDesReadStream resultStream(iResultsBuffer->Des());
|
|
760 |
resultStream.PushL();
|
|
761 |
|
|
762 |
TUint8 cachestatus = resultStream.ReadUint8L();
|
|
763 |
|
|
764 |
// Cleanup
|
|
765 |
delete iResultsBuffer;
|
|
766 |
iResultsBuffer = NULL;
|
|
767 |
resultStream.Pop();
|
|
768 |
resultStream.Close();
|
|
769 |
|
|
770 |
PRINT( _L("End CCSRequestHandler::GetCachingStatusL") );
|
|
771 |
return cachestatus;
|
|
772 |
}
|
|
773 |
|
|
774 |
// -----------------------------------------------------------------------------
|
|
775 |
// CCSRequestHandler::GetTotalUnreadCountL()
|
|
776 |
// Get total unread count
|
|
777 |
// Synchronous
|
|
778 |
// -----------------------------------------------------------------------------
|
|
779 |
EXPORT_C TUint32 CCSRequestHandler::GetTotalUnreadCountL()
|
|
780 |
{
|
|
781 |
PRINT ( _L("Enter CCSRequestHandler::GetTotalUnreadCountL") );
|
|
782 |
|
|
783 |
// ------------------------- Results Buffer ---------------------
|
|
784 |
// Create a buffer to store the results.
|
|
785 |
if(iResultsBuffer)
|
|
786 |
{
|
|
787 |
delete iResultsBuffer;
|
|
788 |
iResultsBuffer = NULL;
|
|
789 |
}
|
|
790 |
iResultsBuffer = HBufC8::NewL(KBufferMaxLen);
|
|
791 |
|
|
792 |
// --------------------------------------------------------------
|
|
793 |
|
|
794 |
// Send the request
|
|
795 |
iSession.GetTotalUnreadCountL(iResultsBuffer->Des());
|
|
796 |
|
|
797 |
// Parse the results
|
|
798 |
RDesReadStream resultStream(iResultsBuffer->Des());
|
|
799 |
resultStream.PushL();
|
|
800 |
|
|
801 |
TUint32 unreadCount = resultStream.ReadUint32L();
|
|
802 |
|
|
803 |
// Cleanup
|
|
804 |
delete iResultsBuffer;
|
|
805 |
iResultsBuffer = NULL;
|
|
806 |
resultStream.Pop();
|
|
807 |
resultStream.Close();
|
|
808 |
|
|
809 |
PRINT( _L("End CCSRequestHandler::GetTotalUnreadCountL") );
|
|
810 |
return unreadCount;
|
|
811 |
}
|
|
812 |
|
|
813 |
// -----------------------------------------------------------------------------
|
|
814 |
// CCSRequestHandler::HandleAddConversationList()
|
|
815 |
// Process add conversation list event received from server
|
|
816 |
// -----------------------------------------------------------------------------
|
|
817 |
void CCSRequestHandler::HandleAddConversationList(HBufC8* aResultsBuffer)
|
|
818 |
{
|
|
819 |
PRINT( _L("Enter CCSRequestHandler::HandleAddConversationList") );
|
|
820 |
|
|
821 |
TInt error = KErrNone;
|
|
822 |
|
|
823 |
// perpare client conversation
|
|
824 |
CCsClientConversation* clientConversation = NULL;
|
|
825 |
RDesReadStream resultStream(aResultsBuffer->Des());
|
|
826 |
|
|
827 |
TRAP(error,
|
|
828 |
resultStream.PushL();
|
|
829 |
clientConversation = CCsClientConversation::NewL();
|
|
830 |
CleanupStack::PushL(clientConversation);
|
|
831 |
clientConversation->InternalizeL(resultStream);
|
|
832 |
CleanupStack::Pop(clientConversation);
|
|
833 |
resultStream.Pop());
|
|
834 |
|
|
835 |
if ( error != KErrNone )
|
|
836 |
{
|
|
837 |
// Ignore this conversation
|
|
838 |
}
|
|
839 |
|
|
840 |
// Cleanup
|
|
841 |
resultStream.Close();
|
|
842 |
|
|
843 |
// Pass the results to the observer
|
|
844 |
if ( iConversationListChangeObserver )
|
|
845 |
{
|
|
846 |
iConversationListChangeObserver->
|
|
847 |
AddConversationList(*clientConversation);
|
|
848 |
}
|
|
849 |
|
|
850 |
delete clientConversation;
|
|
851 |
|
|
852 |
PRINT( _L("End CCSRequestHandler::HandleAddConversationList") );
|
|
853 |
}
|
|
854 |
|
|
855 |
// -----------------------------------------------------------------------------
|
|
856 |
// CCSRequestHandler::HandleDeleteConversationList()
|
|
857 |
// Process delete conversation lsit event received from server
|
|
858 |
// -----------------------------------------------------------------------------
|
|
859 |
void CCSRequestHandler::HandleDeleteConversationList(HBufC8* aResultsBuffer)
|
|
860 |
{
|
|
861 |
PRINT( _L("Enter CCSRequestHandler::HandleDeleteConversationList") );
|
|
862 |
|
|
863 |
TInt error = KErrNone;
|
|
864 |
|
|
865 |
// perpare client conversation
|
|
866 |
CCsClientConversation* clientConversation = NULL;
|
|
867 |
RDesReadStream resultStream(aResultsBuffer->Des());
|
|
868 |
|
|
869 |
TRAP(error,
|
|
870 |
resultStream.PushL();
|
|
871 |
clientConversation = CCsClientConversation::NewL();
|
|
872 |
CleanupStack::PushL(clientConversation);
|
|
873 |
clientConversation->InternalizeL(resultStream);
|
|
874 |
CleanupStack::Pop(clientConversation);
|
|
875 |
resultStream.Pop());
|
|
876 |
|
|
877 |
if ( error != KErrNone )
|
|
878 |
{
|
|
879 |
// Ignore this conversation
|
|
880 |
}
|
|
881 |
|
|
882 |
// Cleanup
|
|
883 |
resultStream.Close();
|
|
884 |
|
|
885 |
// Pass the results to the observer
|
|
886 |
if ( iConversationListChangeObserver )
|
|
887 |
{
|
|
888 |
iConversationListChangeObserver->
|
|
889 |
DeleteConversationList(*clientConversation);
|
|
890 |
}
|
|
891 |
|
|
892 |
delete clientConversation;
|
|
893 |
|
|
894 |
PRINT( _L("End CCSRequestHandler::HandleDeleteConversationList") );
|
|
895 |
}
|
|
896 |
|
|
897 |
// -----------------------------------------------------------------------------
|
|
898 |
// CCSRequestHandler::HandleModifyConversationList
|
|
899 |
// Process modify conversation lsit event received from server
|
|
900 |
// -----------------------------------------------------------------------------
|
|
901 |
void CCSRequestHandler::HandleModifyConversationList(HBufC8* aResultsBuffer)
|
|
902 |
{
|
|
903 |
PRINT( _L("Enter CCSRequestHandler::HandleModifyConversationList") );
|
|
904 |
|
|
905 |
TInt error = KErrNone;
|
|
906 |
|
|
907 |
// perpare client conversation
|
|
908 |
CCsClientConversation* clientConversation = NULL;
|
|
909 |
RDesReadStream resultStream(aResultsBuffer->Des());
|
|
910 |
|
|
911 |
TRAP(error,
|
|
912 |
resultStream.PushL();
|
|
913 |
clientConversation = CCsClientConversation::NewL();
|
|
914 |
CleanupStack::PushL(clientConversation);
|
|
915 |
clientConversation->InternalizeL(resultStream);
|
|
916 |
CleanupStack::Pop(clientConversation);
|
|
917 |
resultStream.Pop());
|
|
918 |
|
|
919 |
if ( error != KErrNone )
|
|
920 |
{
|
|
921 |
// Ignore this conversation
|
|
922 |
}
|
|
923 |
|
|
924 |
// Cleanup
|
|
925 |
resultStream.Close();
|
|
926 |
|
|
927 |
// Pass the results to the observer
|
|
928 |
if ( iConversationListChangeObserver )
|
|
929 |
{
|
|
930 |
iConversationListChangeObserver->
|
|
931 |
ModifyConversationList(*clientConversation);
|
|
932 |
}
|
|
933 |
|
|
934 |
delete clientConversation;
|
|
935 |
|
|
936 |
PRINT( _L("End CCSRequestHandler::HandleModifyConversationList") );
|
|
937 |
}
|
|
938 |
|
|
939 |
// -----------------------------------------------------------------------------
|
|
940 |
// CCSRequestHandler::HandleAddConversation
|
|
941 |
// Process add conversation event received from server
|
|
942 |
// -----------------------------------------------------------------------------
|
|
943 |
void CCSRequestHandler::HandleAddConversation(HBufC8* aResultsBuffer)
|
|
944 |
{
|
|
945 |
PRINT( _L("Start CCSRequestHandler::HandleAddConversation") );
|
|
946 |
|
|
947 |
TInt error = KErrNone;
|
|
948 |
|
|
949 |
// perpare client conversation
|
|
950 |
CCsClientConversation* clientConversation = NULL;
|
|
951 |
RDesReadStream resultStream(aResultsBuffer->Des());
|
|
952 |
|
|
953 |
TRAP(error,
|
|
954 |
resultStream.PushL();
|
|
955 |
clientConversation = CCsClientConversation::NewL();
|
|
956 |
CleanupStack::PushL(clientConversation);
|
|
957 |
clientConversation->InternalizeL(resultStream);
|
|
958 |
CleanupStack::Pop(clientConversation);
|
|
959 |
resultStream.Pop());
|
|
960 |
|
|
961 |
if ( error != KErrNone )
|
|
962 |
{
|
|
963 |
// Ignore this conversation
|
|
964 |
}
|
|
965 |
|
|
966 |
// Cleanup
|
|
967 |
resultStream.Close();
|
|
968 |
|
|
969 |
// Pass the results to the observer
|
|
970 |
if ( iConversationChangeObserver )
|
|
971 |
{
|
|
972 |
MCsConversationChangeObserver* observer =
|
|
973 |
iConversationChangeObserver->ConversationChangeObserver();
|
|
974 |
observer->AddConversation(*(clientConversation->
|
|
975 |
GetConversationEntry()));
|
|
976 |
}
|
|
977 |
|
|
978 |
delete clientConversation;
|
|
979 |
|
|
980 |
PRINT( _L("End CCSRequestHandler::HandleAddConversation") );
|
|
981 |
}
|
|
982 |
|
|
983 |
// -----------------------------------------------------------------------------
|
|
984 |
// CCSRequestHandler::HandleDeleteConversation
|
|
985 |
// Process delete conversation event received from server
|
|
986 |
// -----------------------------------------------------------------------------
|
|
987 |
void CCSRequestHandler::HandleDeleteConversation(HBufC8* aResultsBuffer)
|
|
988 |
{
|
|
989 |
PRINT( _L("Start CCSRequestHandler::HandleDeleteConversation") );
|
|
990 |
|
|
991 |
TInt error = KErrNone;
|
|
992 |
|
|
993 |
// perpare client conversation
|
|
994 |
CCsClientConversation* clientConversation = NULL;
|
|
995 |
RDesReadStream resultStream(aResultsBuffer->Des());
|
|
996 |
|
|
997 |
TRAP(error,
|
|
998 |
resultStream.PushL();
|
|
999 |
clientConversation = CCsClientConversation::NewL();
|
|
1000 |
CleanupStack::PushL(clientConversation);
|
|
1001 |
clientConversation->InternalizeL(resultStream);
|
|
1002 |
CleanupStack::Pop(clientConversation);
|
|
1003 |
resultStream.Pop());
|
|
1004 |
|
|
1005 |
if ( error != KErrNone )
|
|
1006 |
{
|
|
1007 |
// Ignore this conversation
|
|
1008 |
}
|
|
1009 |
|
|
1010 |
// Cleanup
|
|
1011 |
resultStream.Close();
|
|
1012 |
|
|
1013 |
// Pass the results to the observer
|
|
1014 |
if ( iConversationChangeObserver )
|
|
1015 |
{
|
|
1016 |
MCsConversationChangeObserver* observer =
|
|
1017 |
iConversationChangeObserver->ConversationChangeObserver();
|
|
1018 |
observer->DeleteConversation(*(clientConversation->
|
|
1019 |
GetConversationEntry()));
|
|
1020 |
}
|
|
1021 |
|
|
1022 |
delete clientConversation;
|
|
1023 |
|
|
1024 |
PRINT( _L("End CCSRequestHandler::HandleDeleteConversation") );
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
// -----------------------------------------------------------------------------
|
|
1028 |
// CCSRequestHandler::HandleModifyConversation
|
|
1029 |
// Process Modify conversation event received from server
|
|
1030 |
// -----------------------------------------------------------------------------
|
|
1031 |
void CCSRequestHandler::HandleModifyConversation(HBufC8* aResultsBuffer)
|
|
1032 |
{
|
|
1033 |
PRINT( _L("Start CCSRequestHandler::HandleModifyConversation") );
|
|
1034 |
TInt error = KErrNone;
|
|
1035 |
|
|
1036 |
// perpare client conversation
|
|
1037 |
CCsClientConversation* clientConversation = NULL;
|
|
1038 |
RDesReadStream resultStream(aResultsBuffer->Des());
|
|
1039 |
|
|
1040 |
TRAP(error,
|
|
1041 |
resultStream.PushL();
|
|
1042 |
clientConversation = CCsClientConversation::NewL();
|
|
1043 |
CleanupStack::PushL(clientConversation);
|
|
1044 |
// Parse the results
|
|
1045 |
clientConversation->InternalizeL(resultStream);
|
|
1046 |
CleanupStack::Pop(clientConversation);
|
|
1047 |
resultStream.Pop());
|
|
1048 |
|
|
1049 |
if ( error != KErrNone )
|
|
1050 |
{
|
|
1051 |
// Ignore this conversation
|
|
1052 |
}
|
|
1053 |
|
|
1054 |
// Cleanup
|
|
1055 |
resultStream.Close();
|
|
1056 |
|
|
1057 |
// Pass the results to the observer
|
|
1058 |
if ( iConversationChangeObserver )
|
|
1059 |
{
|
|
1060 |
MCsConversationChangeObserver* observer =
|
|
1061 |
iConversationChangeObserver->ConversationChangeObserver();
|
|
1062 |
observer->ModifyConversation(*(clientConversation->
|
|
1063 |
GetConversationEntry()));
|
|
1064 |
}
|
|
1065 |
|
|
1066 |
delete clientConversation;
|
|
1067 |
|
|
1068 |
PRINT( _L("End CCSRequestHandler::HandleModifyConversation") );
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
// -----------------------------------------------------------------------------
|
|
1072 |
// CCSRequestHandler::HandleCachingStarted
|
|
1073 |
// Process caching started event received from server
|
|
1074 |
// -----------------------------------------------------------------------------
|
|
1075 |
void CCSRequestHandler::HandleCachingStarted(HBufC8* /*aResultsBuffer*/)
|
|
1076 |
{
|
|
1077 |
User::Leave(KErrNotSupported);
|
|
1078 |
}
|
|
1079 |
|
|
1080 |
// -----------------------------------------------------------------------------
|
|
1081 |
// CCSRequestHandler::HandleCachingCompleted
|
|
1082 |
// Process caching completed event received from server
|
|
1083 |
// -----------------------------------------------------------------------------
|
|
1084 |
void CCSRequestHandler::HandleCachingCompleted(HBufC8* /*aResultsBuffer*/)
|
|
1085 |
{
|
|
1086 |
User::Leave(KErrNotSupported);
|
|
1087 |
}
|
|
1088 |
|
|
1089 |
// -----------------------------------------------------------------------------
|
|
1090 |
// CCSRequestHandler::HandleCachingError
|
|
1091 |
// Process caching error event received from server
|
|
1092 |
// -----------------------------------------------------------------------------
|
|
1093 |
void CCSRequestHandler::HandleCachingError(HBufC8* /*aResultsBuffer*/)
|
|
1094 |
{
|
|
1095 |
User::Leave(KErrNotSupported);
|
|
1096 |
}
|
|
1097 |
|
|
1098 |
// -----------------------------------------------------------------------------
|
|
1099 |
// CCSRequestHandler::DeleteConversationL()
|
|
1100 |
// -----------------------------------------------------------------------------
|
|
1101 |
EXPORT_C void CCSRequestHandler::DeleteConversationL(TInt aConversationId)
|
|
1102 |
{
|
|
1103 |
PRINT( _L("Enter CCSRequestHandler::DeleteConversationL") );
|
|
1104 |
iSession.DeleteConversationL(aConversationId);
|
|
1105 |
PRINT( _L("End CCSRequestHandler::DeleteConversationL") );
|
|
1106 |
}
|
|
1107 |
|
|
1108 |
// -----------------------------------------------------------------------------
|
|
1109 |
// CCSRequestHandler::HandleRefreshConversationList
|
|
1110 |
// Process refresh from server
|
|
1111 |
// -----------------------------------------------------------------------------
|
|
1112 |
void CCSRequestHandler::HandleRefreshConversationList(HBufC8* /*aResultsBuffer*/)
|
|
1113 |
{
|
|
1114 |
// Pass the results to the observer
|
|
1115 |
if ( iConversationListChangeObserver )
|
|
1116 |
{
|
|
1117 |
iConversationListChangeObserver->RefreshConversationList();
|
|
1118 |
}
|
|
1119 |
}
|
|
1120 |
|
|
1121 |
// -----------------------------------------------------------------------------
|
|
1122 |
// Ccsrequesthandler::HandleRefreshConversationList
|
|
1123 |
// Process refresh from server
|
|
1124 |
// -----------------------------------------------------------------------------
|
|
1125 |
void CCSRequestHandler::HandleRefreshConversation(HBufC8* /*aResultsBuffer*/)
|
|
1126 |
{
|
|
1127 |
// Pass the results to the observer
|
|
1128 |
if ( iConversationChangeObserver )
|
|
1129 |
{
|
|
1130 |
MCsConversationChangeObserver* observer =
|
|
1131 |
iConversationChangeObserver->ConversationChangeObserver();
|
|
1132 |
observer->RefreshConversation();
|
|
1133 |
}
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
// -----------------------------------------------------------------------------
|
|
1137 |
// CCSRequestHandler::GetConversationIdL()
|
|
1138 |
// -----------------------------------------------------------------------------
|
|
1139 |
EXPORT_C TInt CCSRequestHandler::GetConversationIdL(TInt aContactId)
|
|
1140 |
{
|
|
1141 |
TInt conversationId = -1;
|
|
1142 |
|
|
1143 |
// Create a buffer to store the results.
|
|
1144 |
if(iResultsBuffer)
|
|
1145 |
{
|
|
1146 |
delete iResultsBuffer;
|
|
1147 |
iResultsBuffer = NULL;
|
|
1148 |
}
|
|
1149 |
iResultsBuffer = HBufC8::NewL(KSmallIpcBuffer);
|
|
1150 |
|
|
1151 |
// Send the request
|
|
1152 |
iSession.GetConversationIdL(aContactId, iResultsBuffer->Des());
|
|
1153 |
|
|
1154 |
// Parse the results
|
|
1155 |
RDesReadStream resultStream(iResultsBuffer->Des());
|
|
1156 |
resultStream.PushL();
|
|
1157 |
conversationId = resultStream.ReadInt32L();
|
|
1158 |
|
|
1159 |
// Cleanup
|
|
1160 |
delete iResultsBuffer;
|
|
1161 |
iResultsBuffer = NULL;
|
|
1162 |
resultStream.Pop();
|
|
1163 |
resultStream.Close();
|
|
1164 |
|
|
1165 |
return conversationId;
|
|
1166 |
}
|
|
1167 |
|
|
1168 |
// -----------------------------------------------------------------------------
|
|
1169 |
// CCSRequestHandler::GetConversationIdFromAddressL()
|
|
1170 |
// -----------------------------------------------------------------------------
|
|
1171 |
EXPORT_C TInt CCSRequestHandler::GetConversationIdFromAddressL(TDesC& aContactAddress)
|
|
1172 |
{
|
|
1173 |
TInt conversationId = -1;
|
|
1174 |
|
|
1175 |
// Create a buffer to store the results.
|
|
1176 |
if(iResultsBuffer)
|
|
1177 |
{
|
|
1178 |
delete iResultsBuffer;
|
|
1179 |
iResultsBuffer = NULL;
|
|
1180 |
}
|
|
1181 |
iResultsBuffer = HBufC8::NewL(KSmallIpcBuffer);
|
|
1182 |
|
|
1183 |
// Send the request
|
|
1184 |
iSession.GetConversationIdFromAddressL(aContactAddress,iResultsBuffer->Des());
|
|
1185 |
|
|
1186 |
// Parse the results
|
|
1187 |
RDesReadStream resultStream(iResultsBuffer->Des());
|
|
1188 |
resultStream.PushL();
|
|
1189 |
conversationId = resultStream.ReadInt32L();
|
|
1190 |
|
|
1191 |
// Cleanup
|
|
1192 |
delete iResultsBuffer;
|
|
1193 |
iResultsBuffer = NULL;
|
|
1194 |
resultStream.Pop();
|
|
1195 |
resultStream.Close();
|
|
1196 |
|
|
1197 |
return conversationId;
|
|
1198 |
}
|
|
1199 |
|
|
1200 |
// -----------------------------------------------------------------------------
|
|
1201 |
// CCSRequestHandler::GetConversationFromMessageIdL()
|
|
1202 |
// -----------------------------------------------------------------------------
|
|
1203 |
EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromMessageIdL(TInt aMessageId)
|
|
1204 |
{
|
|
1205 |
// Create a buffer to store the results.
|
|
1206 |
if(iResultsBuffer)
|
|
1207 |
{
|
|
1208 |
delete iResultsBuffer;
|
|
1209 |
iResultsBuffer = NULL;
|
|
1210 |
}
|
|
1211 |
iResultsBuffer = HBufC8::NewL(KBigIpcBuffer);
|
|
1212 |
|
|
1213 |
// Send the request
|
|
1214 |
iSession.GetConversationFromMessageIdL(aMessageId, iResultsBuffer->Des());
|
|
1215 |
|
|
1216 |
// Parse the results
|
|
1217 |
RDesReadStream resultStream(iResultsBuffer->Des());
|
|
1218 |
resultStream.PushL();
|
|
1219 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL();
|
|
1220 |
CleanupStack::PushL(clientConversation);
|
|
1221 |
clientConversation->InternalizeL(resultStream);
|
|
1222 |
CleanupStack::Pop(clientConversation);
|
|
1223 |
|
|
1224 |
// Cleanup
|
|
1225 |
delete iResultsBuffer;
|
|
1226 |
iResultsBuffer = NULL;
|
|
1227 |
resultStream.Pop();
|
|
1228 |
resultStream.Close();
|
|
1229 |
|
|
1230 |
return clientConversation;
|
|
1231 |
}
|
|
1232 |
|
|
1233 |
// -----------------------------------------------------------------------------
|
|
1234 |
// CCSRequestHandler::GetMessagingHistoryL()
|
|
1235 |
// -----------------------------------------------------------------------------
|
|
1236 |
EXPORT_C void CCSRequestHandler::GetMessagingHistoryL(TInt aContactId)
|
|
1237 |
{
|
|
1238 |
TInt conversationId = GetConversationIdL(aContactId);
|
|
1239 |
if ( conversationId == -1 )
|
|
1240 |
User::Leave(KErrNotFound);
|
|
1241 |
|
|
1242 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL();
|
|
1243 |
clientConversation->SetConversationEntryId(conversationId);
|
|
1244 |
//set dummy entry
|
|
1245 |
CCsConversationEntry *entry = CCsConversationEntry::NewL();
|
|
1246 |
clientConversation->SetConversationEntryL(entry);
|
|
1247 |
GetConversationsL(clientConversation);
|
|
1248 |
|
|
1249 |
//delete
|
|
1250 |
delete clientConversation;
|
|
1251 |
if( entry )
|
|
1252 |
delete entry;
|
|
1253 |
|
|
1254 |
return;
|
|
1255 |
}
|
|
1256 |
|
|
1257 |
// -----------------------------------------------------------------------------
|
|
1258 |
// CCSRequestHandler::GetConversationIdL()
|
|
1259 |
// -----------------------------------------------------------------------------
|
|
1260 |
EXPORT_C void CCSRequestHandler::ClearMessagingHistoryL(TInt aContactId)
|
|
1261 |
{
|
|
1262 |
TInt conversationId = GetConversationIdL(aContactId);
|
|
1263 |
if ( conversationId == -1 )
|
|
1264 |
User::Leave(KErrNotFound);
|
|
1265 |
|
|
1266 |
// Done in background
|
|
1267 |
DeleteConversationL(conversationId);
|
|
1268 |
return;
|
|
1269 |
}
|
|
1270 |
|
|
1271 |
// -----------------------------------------------------------------------------
|
|
1272 |
// CCSRequestHandler::MarkConversationReadL()
|
|
1273 |
// -----------------------------------------------------------------------------
|
|
1274 |
EXPORT_C void CCSRequestHandler::MarkConversationReadL(TInt aConversationId)
|
|
1275 |
{
|
|
1276 |
iSession.MarkConversationReadL(aConversationId);
|
|
1277 |
}
|
|
1278 |
|
|
1279 |
// -----------------------------------------------------------------------------
|
|
1280 |
// CCSRequestHandler::MarkMessagingHistoryReadL()
|
|
1281 |
// -----------------------------------------------------------------------------
|
|
1282 |
EXPORT_C void CCSRequestHandler::MarkMessagingHistoryReadL(TInt aContactId)
|
|
1283 |
{
|
|
1284 |
TInt conversationId = GetConversationIdL(aContactId);
|
|
1285 |
if ( conversationId == -1 )
|
|
1286 |
User::Leave(KErrNotFound);
|
|
1287 |
|
|
1288 |
MarkConversationReadL(conversationId);
|
|
1289 |
return;
|
|
1290 |
}
|
|
1291 |
|
|
1292 |
// End of File
|