messagingapp/msgappfw/server/src/ccsconversationdeletehandler.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 44 36f374c67aa8
equal deleted inserted replaced
35:a32b19fb291e 47:5b14749788d7
    37 
    37 
    38 // ----------------------------------------------------------------------------
    38 // ----------------------------------------------------------------------------
    39 // Constructor
    39 // Constructor
    40 // ----------------------------------------------------------------------------
    40 // ----------------------------------------------------------------------------
    41 CCsConversationDeleteHandler::CCsConversationDeleteHandler():
    41 CCsConversationDeleteHandler::CCsConversationDeleteHandler():
    42         CActive(CActive::EPriorityLow)
    42         CActive(CActive::EPriorityLow),
       
    43         iState(EIdle),
       
    44         iConversationEntryList(NULL)
    43     {
    45     {
    44     CActiveScheduler::Add( this );
    46     CActiveScheduler::Add( this );
    45     }
    47     }
    46 
    48 
    47 // ----------------------------------------------------------------------------
    49 // ----------------------------------------------------------------------------
    48 // Constructor
    50 // Constructor
    49 // ----------------------------------------------------------------------------
    51 // ----------------------------------------------------------------------------
    50 void CCsConversationDeleteHandler::ConstructL(CCsConversationCache* aCache)
    52 void CCsConversationDeleteHandler::ConstructL(CCsConversationCache* aCache)
    51     {
    53     {
    52     iCache = aCache;
    54     iCache = aCache;
    53     iState = EIdle;
       
    54      
       
    55     iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> ();  
       
    56     iSession = CMsvSession::OpenSyncL(*this);
    55     iSession = CMsvSession::OpenSyncL(*this);
    57     }
    56     }
    58 
    57 
    59 // ----------------------------------------------------------------------------
    58 // ----------------------------------------------------------------------------
    60 // Destructor
    59 // Destructor
    61 // ----------------------------------------------------------------------------
    60 // ----------------------------------------------------------------------------
    62 CCsConversationDeleteHandler::~CCsConversationDeleteHandler()
    61 CCsConversationDeleteHandler::~CCsConversationDeleteHandler()
    63 {
    62 {
       
    63     // Make sure Aync request cancel.
       
    64     Cancel();
       
    65     
       
    66     if(iSession)
       
    67         {
       
    68         delete iSession;
       
    69         iSession = NULL;
       
    70         }
       
    71     
    64     if (iConversationEntryList)
    72     if (iConversationEntryList)
    65     {
    73     {
    66         iConversationEntryList->ResetAndDestroy();
    74         iConversationEntryList->ResetAndDestroy();
    67         iConversationEntryList->Close();
    75         iConversationEntryList->Close();
    68         delete iConversationEntryList;
    76         delete iConversationEntryList;
    69         iConversationEntryList = NULL;
    77         iConversationEntryList = NULL;
    70     }
    78     }
    71 
    79 }
    72     if (iSession)
       
    73     {
       
    74         delete iSession;
       
    75         iSession = NULL;
       
    76         }
       
    77     }
       
    78 
    80 
    79 // ----------------------------------------------------------------------------
    81 // ----------------------------------------------------------------------------
    80 // Delete set of messages
    82 // Delete set of messages
    81 // ----------------------------------------------------------------------------
    83 // ----------------------------------------------------------------------------
    82 void CCsConversationDeleteHandler::DeleteL(TInt aConversationId)
    84 void CCsConversationDeleteHandler::DeleteL(TInt aConversationId)
    94 
    96 
    95     // Temp client conversation object
    97     // Temp client conversation object
    96     CCsClientConversation* clientConversation = CCsClientConversation::NewL();
    98     CCsClientConversation* clientConversation = CCsClientConversation::NewL();
    97     clientConversation->SetConversationEntryId(iConversationId);
    99     clientConversation->SetConversationEntryId(iConversationId);
    98     CleanupStack::PushL(clientConversation);
   100     CleanupStack::PushL(clientConversation);
    99 
   101     
       
   102     // Create entry list
       
   103     iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> ();  
       
   104     
   100     // Get conversationlist for given client conversation
   105     // Get conversationlist for given client conversation
   101     iCache->GetConversationsL (clientConversation, iConversationEntryList);
   106     iCache->GetConversationsL (clientConversation, iConversationEntryList);
   102     iCache->MarkConversationAsDeleted(iConversationId, ETrue);
   107     iCache->MarkConversationAsDeleted(iConversationId, ETrue);
   103     
   108     
   104     iDeletedCount = 0;
   109     iDeletedCount = 0;
       
   110     iSendStateMsgs = 0;
   105     
   111     
   106     // Cleanup  
   112     // Cleanup  
   107     CleanupStack::PopAndDestroy(clientConversation);
   113     CleanupStack::PopAndDestroy(clientConversation);
   108         
   114         
   109     iState = EDeleteStart;
   115     iState = EDeleteStart;
   121     TInt id = entry->EntryId();
   127     TInt id = entry->EntryId();
   122     
   128     
   123     if ( ECsSendStateSending != entry->GetSendState() )
   129     if ( ECsSendStateSending != entry->GetSendState() )
   124         {
   130         {
   125         iSession->RemoveEntry(id);
   131         iSession->RemoveEntry(id);
       
   132         }
       
   133     else
       
   134         {
       
   135         iSendStateMsgs++;
   126         }
   136         }
   127     }
   137     }
   128 
   138 
   129 // ----------------------------------------------------------------------------
   139 // ----------------------------------------------------------------------------
   130 // RunL
   140 // RunL
   161                 IssueRequest();
   171                 IssueRequest();
   162                 }
   172                 }
   163             break;
   173             break;
   164             
   174             
   165         case EDeleteComplete:
   175         case EDeleteComplete:
   166             // Mark delete complete.
   176             iCache->MarkConversationAsDeleted(iConversationId, EFalse, iSendStateMsgs );
   167             iCache->MarkConversationAsDeleted(iConversationId, EFalse);
       
   168             // Done with the processing , cleanup the AO since this is the last 
       
   169             //call to the delete handler.
       
   170             delete this;
   177             delete this;
   171             break;
   178             break;
   172         }
   179         }
   173     }
   180     }
   174 
   181