diff -r 35b64624a9e7 -r 36f374c67aa8 messagingapp/msgappfw/client/src/ccsrequesthandler.cpp --- a/messagingapp/msgappfw/client/src/ccsrequesthandler.cpp Wed Jun 23 18:09:17 2010 +0300 +++ b/messagingapp/msgappfw/client/src/ccsrequesthandler.cpp Tue Jul 06 14:12:40 2010 +0300 @@ -178,6 +178,12 @@ //call panic } + // Speed up the allocation + if( listCount > 0 ) + { + clientConversationList.Reserve(listCount); + } + for (TInt iloop = 0 ; iloop < listCount; iloop++) { TRAP(error, @@ -240,7 +246,12 @@ { //call panic } - + // Speed up the allocation + if( conversationEntryCount > 0 ) + { + ConversationEntryList.Reserve(conversationEntryCount); + } + PRINT1 ( _L("Number of conversation entries = %d"), conversationEntryCount ); // conversation entries @@ -319,8 +330,11 @@ stream.Close(); // Delete and recreate the results buffer - delete iListResultsBuffer; - iListResultsBuffer = NULL; + if ( iListResultsBuffer) + { + delete iListResultsBuffer; + iListResultsBuffer = NULL; + } // Buffer created for the new size TRAP(error, @@ -370,8 +384,11 @@ stream.Close(); // Delete and recreate the results buffer - delete iConvResultsBuffer; - iConvResultsBuffer = NULL; + if ( iConvResultsBuffer ) + { + delete iConvResultsBuffer; + iConvResultsBuffer = NULL; + } // Buffer created for the new size TRAP(error, @@ -429,10 +446,14 @@ EXPORT_C void CCSRequestHandler::RemoveConversationListChangeEventL( MCsConversationListChangeObserver* /*aObserver*/) { - iConversationListChangeObserver = NULL; - - // De-register from the server - iNotificationHandler->RemoveConversationListChangeEventL(); + // Before removing observer, make sure it was added earlier. + if( iConversationListChangeObserver ) + { + iConversationListChangeObserver = NULL; + + // De-register from the server + iNotificationHandler->RemoveConversationListChangeEventL(); + } } // ----------------------------------------------------------------------------- @@ -466,11 +487,12 @@ { delete iConversationChangeObserver; iConversationChangeObserver = NULL; - } - - iNotificationHandler->RemoveConversationChangeEventL(aClientConversation); + if(aClientConversation) + { + iNotificationHandler->RemoveConversationChangeEventL(aClientConversation); + } + } } - // ----------------------------------------------------------------------------- // CCSRequestHandler::RequestCachingStatusEventL() // Add caching status Observer @@ -895,6 +917,50 @@ } // ----------------------------------------------------------------------------- +// CCSRequestHandler::HandlePartialDeleteConversationList() +// Process partial delete conversation lsit event received from server +// ----------------------------------------------------------------------------- + +void CCSRequestHandler::HandlePartialDeleteConversationList(HBufC8* aResultsBuffer) +{ + PRINT( _L("Enter CCSRequestHandler::HandlePartialDeleteConversationList") ); + + TInt error = KErrNone; + + // perpare client conversation + CCsClientConversation* clientConversation = NULL; + RDesReadStream resultStream(aResultsBuffer->Des()); + + TRAP(error, + resultStream.PushL(); + clientConversation = CCsClientConversation::NewL(); + CleanupStack::PushL(clientConversation); + clientConversation->InternalizeL(resultStream); + CleanupStack::Pop(clientConversation); + resultStream.Pop()); + + if ( error != KErrNone ) + { + // Ignore this conversation + } + + // Cleanup + resultStream.Close(); + + // Pass the results to the observer + if ( iConversationListChangeObserver ) + { + CleanupStack::PushL( clientConversation ); + iConversationListChangeObserver-> + PartialDeleteConversationList(*clientConversation); + } + + CleanupStack::PopAndDestroy();// clientConversation*/ + + PRINT( _L("End CCSRequestHandler::HandlePartialDeleteConversationList") ); +} + +// ----------------------------------------------------------------------------- // CCSRequestHandler::HandleModifyConversationList // Process modify conversation lsit event received from server // ----------------------------------------------------------------------------- @@ -1198,6 +1264,39 @@ } // ----------------------------------------------------------------------------- +// CCSRequestHandler::GetConversationFromConversationIdL() +// ----------------------------------------------------------------------------- +EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromConversationIdL(TInt aConversationId) +{ + // Create a buffer to store the results. + if(iResultsBuffer) + { + delete iResultsBuffer; + iResultsBuffer = NULL; + } + iResultsBuffer = HBufC8::NewL(KBigIpcBuffer); + + // Send the request + iSession.GetConversationFromConversationIdL(aConversationId, iResultsBuffer->Des()); + + // Parse the results + RDesReadStream resultStream(iResultsBuffer->Des()); + resultStream.PushL(); + CCsClientConversation* clientConversation = CCsClientConversation::NewL(); + CleanupStack::PushL(clientConversation); + clientConversation->InternalizeL(resultStream); + CleanupStack::Pop(clientConversation); + + // Cleanup + delete iResultsBuffer; + iResultsBuffer = NULL; + resultStream.Pop(); + resultStream.Close(); + + return clientConversation; +} + +// ----------------------------------------------------------------------------- // CCSRequestHandler::GetConversationFromMessageIdL() // ----------------------------------------------------------------------------- EXPORT_C CCsClientConversation* CCSRequestHandler::GetConversationFromMessageIdL(TInt aMessageId)