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