17 // INCLUDES |
17 // INCLUDES |
18 #include <ccsclientconversation.h> |
18 #include <ccsclientconversation.h> |
19 #include <ccsconversationentry.h> |
19 #include <ccsconversationentry.h> |
20 #include "ccsconversationcache.h" |
20 #include "ccsconversationcache.h" |
21 #include "ccsconversationdeletehandler.h" |
21 #include "ccsconversationdeletehandler.h" |
22 #include "mcsconversationdeleteobserver.h" |
|
23 |
22 |
24 // ---------------------------------------------------------------------------- |
23 // ---------------------------------------------------------------------------- |
25 // CCsConversationDeleteHandler::NewL |
24 // CCsConversationDeleteHandler::NewL |
26 // Two Phase Construction |
25 // Two Phase Construction |
27 // ---------------------------------------------------------------------------- |
26 // ---------------------------------------------------------------------------- |
28 CCsConversationDeleteHandler* CCsConversationDeleteHandler:: |
27 CCsConversationDeleteHandler* CCsConversationDeleteHandler:: |
29 NewL(CCsConversationCache* aCache, MCsConversationDeleteObserver* aObserver) |
28 NewL(CCsConversationCache* aCache) |
30 { |
29 { |
31 CCsConversationDeleteHandler* self = |
30 CCsConversationDeleteHandler* self = |
32 new (ELeave) CCsConversationDeleteHandler(); |
31 new (ELeave) CCsConversationDeleteHandler(); |
33 CleanupStack::PushL(self); |
32 CleanupStack::PushL(self); |
34 self->ConstructL(aCache, aObserver); |
33 self->ConstructL(aCache); |
35 CleanupStack::Pop(self); // self |
34 CleanupStack::Pop(self); // self |
36 return self; |
35 return self; |
37 } |
36 } |
38 |
37 |
39 // ---------------------------------------------------------------------------- |
38 // ---------------------------------------------------------------------------- |
46 } |
45 } |
47 |
46 |
48 // ---------------------------------------------------------------------------- |
47 // ---------------------------------------------------------------------------- |
49 // Constructor |
48 // Constructor |
50 // ---------------------------------------------------------------------------- |
49 // ---------------------------------------------------------------------------- |
51 void CCsConversationDeleteHandler::ConstructL(CCsConversationCache* aCache, |
50 void CCsConversationDeleteHandler::ConstructL(CCsConversationCache* aCache) |
52 MCsConversationDeleteObserver* aObserver) |
|
53 { |
51 { |
54 iCache = aCache; |
52 iCache = aCache; |
55 iState = EIdle; |
53 iState = EIdle; |
56 iObserver = aObserver; |
54 |
57 |
|
58 iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> (); |
55 iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> (); |
59 iSession = CMsvSession::OpenSyncL(*this); |
56 iSession = CMsvSession::OpenSyncL(*this); |
60 } |
57 } |
61 |
58 |
62 // ---------------------------------------------------------------------------- |
59 // ---------------------------------------------------------------------------- |
63 // Destructor |
60 // Destructor |
64 // ---------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------- |
65 CCsConversationDeleteHandler::~CCsConversationDeleteHandler() |
62 CCsConversationDeleteHandler::~CCsConversationDeleteHandler() |
|
63 { |
|
64 if (iConversationEntryList) |
66 { |
65 { |
67 if(iSession) |
66 iConversationEntryList->ResetAndDestroy(); |
68 { |
67 iConversationEntryList->Close(); |
|
68 delete iConversationEntryList; |
|
69 iConversationEntryList = NULL; |
|
70 } |
|
71 |
|
72 if (iSession) |
|
73 { |
69 delete iSession; |
74 delete iSession; |
70 iSession = NULL; |
75 iSession = NULL; |
71 } |
76 } |
72 } |
77 } |
73 |
78 |
77 void CCsConversationDeleteHandler::DeleteL(TInt aConversationId) |
82 void CCsConversationDeleteHandler::DeleteL(TInt aConversationId) |
78 { |
83 { |
79 // Check if delete in progress |
84 // Check if delete in progress |
80 if ( iCache->IsDeleted(aConversationId) ) |
85 if ( iCache->IsDeleted(aConversationId) ) |
81 { |
86 { |
82 iObserver->DeleteInProgress(this); |
87 // Deletion is in progress for this conversation, so clean up this AO |
|
88 delete this; |
83 return; |
89 return; |
84 } |
90 } |
85 |
91 |
86 // Store conversationId currently being deleted. |
92 // Store conversationId currently being deleted. |
87 iConversationId = aConversationId; |
93 iConversationId = aConversationId; |
88 |
94 |
89 // Temp client conversation object |
95 // Temp client conversation object |
90 CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
96 CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
91 clientConversation->SetConversationEntryId(iConversationId); |
97 clientConversation->SetConversationEntryId(iConversationId); |
92 CleanupStack::PushL(clientConversation); |
98 CleanupStack::PushL(clientConversation); |
93 |
99 |
94 // Create entry list |
|
95 iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> (); |
|
96 |
|
97 // Get conversationlist for given client conversation |
100 // Get conversationlist for given client conversation |
98 iCache->GetConversationsL (clientConversation, iConversationEntryList); |
101 iCache->GetConversationsL (clientConversation, iConversationEntryList); |
99 iCache->MarkConversationAsDeleted(iConversationId, ETrue); |
102 iCache->MarkConversationAsDeleted(iConversationId, ETrue); |
100 |
103 |
101 iDeletedCount = 0; |
104 iDeletedCount = 0; |
160 break; |
163 break; |
161 |
164 |
162 case EDeleteComplete: |
165 case EDeleteComplete: |
163 // Mark delete complete. |
166 // Mark delete complete. |
164 iCache->MarkConversationAsDeleted(iConversationId, EFalse); |
167 iCache->MarkConversationAsDeleted(iConversationId, EFalse); |
165 // Cleanup |
168 // Done with the processing , cleanup the AO since this is the last |
166 iDeletedCount = 0; |
169 //call to the delete handler. |
167 iConversationEntryList->ResetAndDestroy(); |
170 delete this; |
168 iConversationEntryList->Close(); |
|
169 delete iConversationEntryList; |
|
170 iConversationEntryList = NULL; |
|
171 |
|
172 // Notify observers |
|
173 iObserver->DeleteComplete(this); |
|
174 break; |
171 break; |
175 } |
172 } |
176 } |
173 } |
177 |
174 |
178 // ---------------------------------------------------------------------------- |
175 // ---------------------------------------------------------------------------- |