57 |
57 |
58 // ----------------------------------------------------------------------------- |
58 // ----------------------------------------------------------------------------- |
59 // CCSRequestHandler::NewLC() |
59 // CCSRequestHandler::NewLC() |
60 // Two-phased constructor. |
60 // Two-phased constructor. |
61 // ----------------------------------------------------------------------------- |
61 // ----------------------------------------------------------------------------- |
62 EXPORT_C CCSRequestHandler* CCSRequestHandler::NewLC(/*CVPbkContactManager* aVPbkContactManager*/) |
62 EXPORT_C CCSRequestHandler* CCSRequestHandler::NewLC() |
63 { |
63 { |
64 PRINT ( _L("Enter CCSRequestHandler::NewLC") ); |
64 PRINT ( _L("Enter CCSRequestHandler::NewLC") ); |
65 |
65 |
66 CCSRequestHandler* self = new ( ELeave ) CCSRequestHandler(); |
66 CCSRequestHandler* self = new ( ELeave ) CCSRequestHandler(); |
67 CleanupStack::PushL( self ); |
67 CleanupStack::PushL( self ); |
68 self->ConstructL(/*aVPbkContactManager*/); |
68 self->ConstructL(); |
69 |
69 |
70 PRINT ( _L("End CCSRequestHandler::NewLC") ); |
70 PRINT ( _L("End CCSRequestHandler::NewLC") ); |
71 |
71 |
72 return self; |
72 return self; |
73 } |
73 } |
317 } |
328 } |
318 |
329 |
319 stream.Close(); |
330 stream.Close(); |
320 |
331 |
321 // Delete and recreate the results buffer |
332 // Delete and recreate the results buffer |
322 delete iListResultsBuffer; |
333 if ( iListResultsBuffer) |
323 iListResultsBuffer = NULL; |
334 { |
|
335 delete iListResultsBuffer; |
|
336 iListResultsBuffer = NULL; |
|
337 } |
324 |
338 |
325 // Buffer created for the new size |
339 // Buffer created for the new size |
326 TRAP(error, |
340 TRAP(error, |
327 iListResultsBuffer = HBufC8::NewL(bufferSize); |
341 iListResultsBuffer = HBufC8::NewL(bufferSize); |
328 iSession.GetConversationListL(iListResultsBuffer->Des(),iStatus) |
342 iSession.GetConversationListL(iListResultsBuffer->Des(),iStatus) |
368 } |
382 } |
369 |
383 |
370 stream.Close(); |
384 stream.Close(); |
371 |
385 |
372 // Delete and recreate the results buffer |
386 // Delete and recreate the results buffer |
373 delete iConvResultsBuffer; |
387 if ( iConvResultsBuffer ) |
374 iConvResultsBuffer = NULL; |
388 { |
|
389 delete iConvResultsBuffer; |
|
390 iConvResultsBuffer = NULL; |
|
391 } |
375 |
392 |
376 // Buffer created for the new size |
393 // Buffer created for the new size |
377 TRAP(error, |
394 TRAP(error, |
378 iConvResultsBuffer = HBufC8::NewL(bufferSize); |
395 iConvResultsBuffer = HBufC8::NewL(bufferSize); |
379 iSession.SendNewBufferGetConversationL(iConvResultsBuffer->Des(),iStatus) |
396 iSession.SendNewBufferGetConversationL(iConvResultsBuffer->Des(),iStatus) |
427 // Remove conversation list change event Observer |
444 // Remove conversation list change event Observer |
428 // ----------------------------------------------------------------------------- |
445 // ----------------------------------------------------------------------------- |
429 EXPORT_C void CCSRequestHandler::RemoveConversationListChangeEventL( |
446 EXPORT_C void CCSRequestHandler::RemoveConversationListChangeEventL( |
430 MCsConversationListChangeObserver* /*aObserver*/) |
447 MCsConversationListChangeObserver* /*aObserver*/) |
431 { |
448 { |
432 iConversationListChangeObserver = NULL; |
449 // Before removing observer, make sure it was added earlier. |
433 |
450 if( iConversationListChangeObserver ) |
434 // De-register from the server |
451 { |
435 iNotificationHandler->RemoveConversationListChangeEventL(); |
452 iConversationListChangeObserver = NULL; |
|
453 |
|
454 // De-register from the server |
|
455 iNotificationHandler->RemoveConversationListChangeEventL(); |
|
456 } |
436 } |
457 } |
437 |
458 |
438 // ----------------------------------------------------------------------------- |
459 // ----------------------------------------------------------------------------- |
439 // CCSRequestHandler::RequestConversationChangeEventL() |
460 // CCSRequestHandler::RequestConversationChangeEventL() |
440 // Add conversation change event Observer |
461 // Add conversation change event Observer |
464 { |
485 { |
465 if ( iConversationChangeObserver ) |
486 if ( iConversationChangeObserver ) |
466 { |
487 { |
467 delete iConversationChangeObserver; |
488 delete iConversationChangeObserver; |
468 iConversationChangeObserver = NULL; |
489 iConversationChangeObserver = NULL; |
469 } |
490 if(aClientConversation) |
470 |
491 { |
471 iNotificationHandler->RemoveConversationChangeEventL(aClientConversation); |
492 iNotificationHandler->RemoveConversationChangeEventL(aClientConversation); |
472 } |
493 } |
473 |
494 } |
|
495 } |
474 // ----------------------------------------------------------------------------- |
496 // ----------------------------------------------------------------------------- |
475 // CCSRequestHandler::RequestCachingStatusEventL() |
497 // CCSRequestHandler::RequestCachingStatusEventL() |
476 // Add caching status Observer |
498 // Add caching status Observer |
477 // ----------------------------------------------------------------------------- |
499 // ----------------------------------------------------------------------------- |
478 EXPORT_C void CCSRequestHandler::RequestCachingStatusEventL( |
500 EXPORT_C void CCSRequestHandler::RequestCachingStatusEventL( |
891 |
913 |
892 delete clientConversation; |
914 delete clientConversation; |
893 |
915 |
894 PRINT( _L("End CCSRequestHandler::HandleDeleteConversationList") ); |
916 PRINT( _L("End CCSRequestHandler::HandleDeleteConversationList") ); |
895 } |
917 } |
|
918 |
|
919 // ----------------------------------------------------------------------------- |
|
920 // CCSRequestHandler::HandlePartialDeleteConversationList() |
|
921 // Process partial delete conversation lsit event received from server |
|
922 // ----------------------------------------------------------------------------- |
|
923 |
|
924 void CCSRequestHandler::HandlePartialDeleteConversationList(HBufC8* aResultsBuffer) |
|
925 { |
|
926 PRINT( _L("Enter CCSRequestHandler::HandlePartialDeleteConversationList") ); |
|
927 |
|
928 TInt error = KErrNone; |
|
929 |
|
930 // perpare client conversation |
|
931 CCsClientConversation* clientConversation = NULL; |
|
932 RDesReadStream resultStream(aResultsBuffer->Des()); |
|
933 |
|
934 TRAP(error, |
|
935 resultStream.PushL(); |
|
936 clientConversation = CCsClientConversation::NewL(); |
|
937 CleanupStack::PushL(clientConversation); |
|
938 clientConversation->InternalizeL(resultStream); |
|
939 CleanupStack::Pop(clientConversation); |
|
940 resultStream.Pop()); |
|
941 |
|
942 if ( error != KErrNone ) |
|
943 { |
|
944 // Ignore this conversation |
|
945 } |
|
946 |
|
947 // Cleanup |
|
948 resultStream.Close(); |
|
949 |
|
950 // Pass the results to the observer |
|
951 if ( iConversationListChangeObserver ) |
|
952 { |
|
953 CleanupStack::PushL( clientConversation ); |
|
954 iConversationListChangeObserver-> |
|
955 PartialDeleteConversationList(*clientConversation); |
|
956 } |
|
957 |
|
958 CleanupStack::PopAndDestroy();// clientConversation*/ |
|
959 |
|
960 PRINT( _L("End CCSRequestHandler::HandlePartialDeleteConversationList") ); |
|
961 } |
896 |
962 |
897 // ----------------------------------------------------------------------------- |
963 // ----------------------------------------------------------------------------- |
898 // CCSRequestHandler::HandleModifyConversationList |
964 // CCSRequestHandler::HandleModifyConversationList |
899 // Process modify conversation lsit event received from server |
965 // Process modify conversation lsit event received from server |
900 // ----------------------------------------------------------------------------- |
966 // ----------------------------------------------------------------------------- |
1196 |
1262 |
1197 return conversationId; |
1263 return conversationId; |
1198 } |
1264 } |
1199 |
1265 |
1200 // ----------------------------------------------------------------------------- |
1266 // ----------------------------------------------------------------------------- |
1201 // CCSRequestHandler::GetConversationFromMessageIdL() |
1267 // CCSRequestHandler::GetConversationFromConversationIdL() |
1202 // ----------------------------------------------------------------------------- |
1268 // ----------------------------------------------------------------------------- |
1203 EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromMessageIdL(TInt aMessageId) |
1269 EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromConversationIdL(TInt aConversationId) |
1204 { |
1270 { |
1205 // Create a buffer to store the results. |
1271 // Create a buffer to store the results. |
1206 if(iResultsBuffer) |
1272 if(iResultsBuffer) |
1207 { |
1273 { |
1208 delete iResultsBuffer; |
1274 delete iResultsBuffer; |
1209 iResultsBuffer = NULL; |
1275 iResultsBuffer = NULL; |
1210 } |
1276 } |
1211 iResultsBuffer = HBufC8::NewL(KBigIpcBuffer); |
1277 iResultsBuffer = HBufC8::NewL(KBigIpcBuffer); |
1212 |
1278 |
1213 // Send the request |
1279 // Send the request |
1214 iSession.GetConversationFromMessageIdL(aMessageId, iResultsBuffer->Des()); |
1280 iSession.GetConversationFromConversationIdL(aConversationId, iResultsBuffer->Des()); |
1215 |
1281 |
1216 // Parse the results |
1282 // Parse the results |
1217 RDesReadStream resultStream(iResultsBuffer->Des()); |
1283 RDesReadStream resultStream(iResultsBuffer->Des()); |
1218 resultStream.PushL(); |
1284 resultStream.PushL(); |
1219 CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
1285 CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
1220 CleanupStack::PushL(clientConversation); |
1286 CleanupStack::PushL(clientConversation); |
1221 clientConversation->InternalizeL(resultStream); |
1287 clientConversation->InternalizeL(resultStream); |
1222 CleanupStack::Pop(clientConversation); |
1288 CleanupStack::Pop(clientConversation); |
|
1289 |
|
1290 // Cleanup |
|
1291 delete iResultsBuffer; |
|
1292 iResultsBuffer = NULL; |
|
1293 resultStream.Pop(); |
|
1294 resultStream.Close(); |
|
1295 |
|
1296 return clientConversation; |
|
1297 } |
|
1298 |
|
1299 // ----------------------------------------------------------------------------- |
|
1300 // CCSRequestHandler::GetConversationFromMessageIdL() |
|
1301 // ----------------------------------------------------------------------------- |
|
1302 EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromMessageIdL(TInt aMessageId) |
|
1303 { |
|
1304 // Create a buffer to store the results. |
|
1305 if(iResultsBuffer) |
|
1306 { |
|
1307 delete iResultsBuffer; |
|
1308 iResultsBuffer = NULL; |
|
1309 } |
|
1310 iResultsBuffer = HBufC8::NewL(KBigIpcBuffer); |
|
1311 |
|
1312 // Send the request |
|
1313 iSession.GetConversationFromMessageIdL(aMessageId, iResultsBuffer->Des()); |
|
1314 |
|
1315 // Parse the results |
|
1316 RDesReadStream resultStream(iResultsBuffer->Des()); |
|
1317 resultStream.PushL(); |
|
1318 CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
|
1319 CleanupStack::PushL(clientConversation); |
|
1320 clientConversation->InternalizeL(resultStream); |
|
1321 CleanupStack::Pop(clientConversation); |
1223 |
1322 |
1224 // Cleanup |
1323 // Cleanup |
1225 delete iResultsBuffer; |
1324 delete iResultsBuffer; |
1226 iResultsBuffer = NULL; |
1325 iResultsBuffer = NULL; |
1227 resultStream.Pop(); |
1326 resultStream.Pop(); |