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 "ccsconversationmarkreadhandler.h" |
21 #include "ccsconversationmarkreadhandler.h" |
22 #include "mcsconversationmarkreadobserver.h" |
|
23 #include <mmsconst.h> |
22 #include <mmsconst.h> |
24 |
23 |
25 // ---------------------------------------------------------------------------- |
24 // ---------------------------------------------------------------------------- |
26 // CCsConversationMarkReadHandler::NewL |
25 // CCsConversationMarkReadHandler::NewL |
27 // Two Phase Construction |
26 // Two Phase Construction |
28 // ---------------------------------------------------------------------------- |
27 // ---------------------------------------------------------------------------- |
29 CCsConversationMarkReadHandler* CCsConversationMarkReadHandler:: |
28 CCsConversationMarkReadHandler* CCsConversationMarkReadHandler:: |
30 NewL(CCsConversationCache* aCache, MCsConversationMarkReadObserver* aObserver) |
29 NewL(CCsConversationCache* aCache) |
31 { |
30 { |
32 CCsConversationMarkReadHandler* self = |
31 CCsConversationMarkReadHandler* self = |
33 new (ELeave) CCsConversationMarkReadHandler(); |
32 new (ELeave) CCsConversationMarkReadHandler(); |
34 CleanupStack::PushL(self); |
33 CleanupStack::PushL(self); |
35 self->ConstructL(aCache, aObserver); |
34 self->ConstructL(aCache); |
36 CleanupStack::Pop(self); // self |
35 CleanupStack::Pop(self); // self |
37 return self; |
36 return self; |
38 } |
37 } |
39 |
38 |
40 // ---------------------------------------------------------------------------- |
39 // ---------------------------------------------------------------------------- |
47 } |
46 } |
48 |
47 |
49 // ---------------------------------------------------------------------------- |
48 // ---------------------------------------------------------------------------- |
50 // Constructor |
49 // Constructor |
51 // ---------------------------------------------------------------------------- |
50 // ---------------------------------------------------------------------------- |
52 void CCsConversationMarkReadHandler::ConstructL(CCsConversationCache* aCache, |
51 void CCsConversationMarkReadHandler::ConstructL(CCsConversationCache* aCache) |
53 MCsConversationMarkReadObserver* aObserver) |
|
54 { |
52 { |
55 iCache = aCache; |
53 iCache = aCache; |
56 iState = EMarkReadIdle; |
54 iState = EMarkReadIdle; |
57 iObserver = aObserver; |
55 |
58 |
|
59 iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> (); |
56 iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> (); |
60 iSession = CMsvSession::OpenSyncL(*this); |
57 iSession = CMsvSession::OpenSyncL(*this); |
61 } |
58 } |
62 |
59 |
63 // ---------------------------------------------------------------------------- |
60 // ---------------------------------------------------------------------------- |
64 // Destructor |
61 // Destructor |
65 // ---------------------------------------------------------------------------- |
62 // ---------------------------------------------------------------------------- |
66 CCsConversationMarkReadHandler::~CCsConversationMarkReadHandler() |
63 CCsConversationMarkReadHandler::~CCsConversationMarkReadHandler() |
67 { |
64 { |
68 if(iSession) |
65 Cancel(); |
69 { |
66 if (iConversationEntryList) |
|
67 { |
|
68 iConversationEntryList->ResetAndDestroy(); |
|
69 iConversationEntryList->Close(); |
|
70 delete iConversationEntryList; |
|
71 iConversationEntryList = NULL; |
|
72 |
|
73 } |
|
74 |
|
75 if (iSession) |
|
76 { |
70 delete iSession; |
77 delete iSession; |
71 iSession = NULL; |
78 iSession = NULL; |
72 } |
79 } |
73 } |
80 } |
74 |
81 |
79 { |
86 { |
80 // Temp client conversation object |
87 // Temp client conversation object |
81 CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
88 CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
82 clientConversation->SetConversationEntryId(aConversationId); |
89 clientConversation->SetConversationEntryId(aConversationId); |
83 CleanupStack::PushL(clientConversation); |
90 CleanupStack::PushL(clientConversation); |
84 |
91 |
85 // Create entry list |
|
86 iConversationEntryList = new (ELeave)RPointerArray<CCsConversationEntry> (); |
|
87 |
|
88 // Get conversationlist for given client conversation |
92 // Get conversationlist for given client conversation |
89 iCache->GetConversationsL (clientConversation, iConversationEntryList); |
93 iCache->GetConversationsL (clientConversation, iConversationEntryList); |
90 |
94 |
91 iMarkReadCount = 0; |
95 iMarkReadCount = 0; |
92 |
96 |
165 IssueRequest(); |
169 IssueRequest(); |
166 } |
170 } |
167 break; |
171 break; |
168 |
172 |
169 case EMarkReadComplete: |
173 case EMarkReadComplete: |
170 // Cleanup |
174 // Cleanup, this is the last call RunL is not activated again. |
171 iMarkReadCount = 0; |
175 delete this; |
172 iConversationEntryList->ResetAndDestroy(); |
|
173 iConversationEntryList->Close(); |
|
174 delete iConversationEntryList; |
|
175 iConversationEntryList = NULL; |
|
176 |
|
177 // Notify observers |
|
178 iObserver->MarkReadComplete(this); |
|
179 break; |
176 break; |
180 } |
177 } |
181 } |
178 } |
182 |
179 |
183 TInt CCsConversationMarkReadHandler::RunError(TInt aError) |
180 TInt CCsConversationMarkReadHandler::RunError(TInt aError) |
184 { |
181 { |
185 iMarkReadCount = 0; |
182 // RunL left so stop processing the AO and clean it. |
186 iConversationEntryList->ResetAndDestroy(); |
183 delete this; |
187 iConversationEntryList->Close(); |
184 return KErrNone; |
188 delete iConversationEntryList; |
|
189 iConversationEntryList = NULL; |
|
190 |
|
191 // Notify observer |
|
192 iObserver->MarkReadComplete(this); |
|
193 return KErrNone; |
|
194 } |
185 } |
195 |
186 |
196 // ---------------------------------------------------------------------------- |
187 // ---------------------------------------------------------------------------- |
197 // DoCancel |
188 // DoCancel |
198 // ---------------------------------------------------------------------------- |
189 // ---------------------------------------------------------------------------- |