messagingapp/msgappfw/server/src/ccsconversationdeletehandler.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 44 36f374c67aa8
--- a/messagingapp/msgappfw/server/src/ccsconversationdeletehandler.cpp	Thu Jun 17 09:57:06 2010 +0100
+++ b/messagingapp/msgappfw/server/src/ccsconversationdeletehandler.cpp	Thu Jul 22 16:32:06 2010 +0100
@@ -39,7 +39,9 @@
 // Constructor
 // ----------------------------------------------------------------------------
 CCsConversationDeleteHandler::CCsConversationDeleteHandler():
-        CActive(CActive::EPriorityLow)
+        CActive(CActive::EPriorityLow),
+        iState(EIdle),
+        iConversationEntryList(NULL)
     {
     CActiveScheduler::Add( this );
     }
@@ -50,9 +52,6 @@
 void CCsConversationDeleteHandler::ConstructL(CCsConversationCache* aCache)
     {
     iCache = aCache;
-    iState = EIdle;
-     
-    iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> ();  
     iSession = CMsvSession::OpenSyncL(*this);
     }
 
@@ -61,6 +60,15 @@
 // ----------------------------------------------------------------------------
 CCsConversationDeleteHandler::~CCsConversationDeleteHandler()
 {
+    // Make sure Aync request cancel.
+    Cancel();
+    
+    if(iSession)
+        {
+        delete iSession;
+        iSession = NULL;
+        }
+    
     if (iConversationEntryList)
     {
         iConversationEntryList->ResetAndDestroy();
@@ -68,13 +76,7 @@
         delete iConversationEntryList;
         iConversationEntryList = NULL;
     }
-
-    if (iSession)
-    {
-        delete iSession;
-        iSession = NULL;
-        }
-    }
+}
 
 // ----------------------------------------------------------------------------
 // Delete set of messages
@@ -96,12 +98,16 @@
     CCsClientConversation* clientConversation = CCsClientConversation::NewL();
     clientConversation->SetConversationEntryId(iConversationId);
     CleanupStack::PushL(clientConversation);
-
+    
+    // Create entry list
+    iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> ();  
+    
     // Get conversationlist for given client conversation
     iCache->GetConversationsL (clientConversation, iConversationEntryList);
     iCache->MarkConversationAsDeleted(iConversationId, ETrue);
     
     iDeletedCount = 0;
+    iSendStateMsgs = 0;
     
     // Cleanup  
     CleanupStack::PopAndDestroy(clientConversation);
@@ -124,6 +130,10 @@
         {
         iSession->RemoveEntry(id);
         }
+    else
+        {
+        iSendStateMsgs++;
+        }
     }
 
 // ----------------------------------------------------------------------------
@@ -163,10 +173,7 @@
             break;
             
         case EDeleteComplete:
-            // Mark delete complete.
-            iCache->MarkConversationAsDeleted(iConversationId, EFalse);
-            // Done with the processing , cleanup the AO since this is the last 
-            //call to the delete handler.
+            iCache->MarkConversationAsDeleted(iConversationId, EFalse, iSendStateMsgs );
             delete this;
             break;
         }