64 |
64 |
65 // Add to the active scheduler |
65 // Add to the active scheduler |
66 CActiveScheduler::Add(this); |
66 CActiveScheduler::Add(this); |
67 } |
67 } |
68 |
68 |
69 // NewL for Selection |
|
70 CImapUpdateFlagOperation* CImapUpdateFlagOperation::NewL(CImapSyncManager& aSyncManager, |
|
71 CMsvServerEntry& aServerEntry, |
|
72 CImapSettings& aImapSettings, |
|
73 const CMsvEntrySelection& aSourceSel , TBool aFlagChanged) |
|
74 |
|
75 { |
|
76 |
|
77 CImapUpdateFlagOperation* self = new (ELeave) CImapUpdateFlagOperation(aSyncManager, |
|
78 aServerEntry, |
|
79 aImapSettings); |
|
80 CleanupStack::PushL(self); |
|
81 self->ConstructL(aSourceSel,aFlagChanged); |
|
82 CleanupStack::Pop(self); |
|
83 return self; |
|
84 } |
|
85 //// ConstructL for Selection |
|
86 void CImapUpdateFlagOperation::ConstructL(const CMsvEntrySelection& aSourceSel, TBool aFlagChanged) |
|
87 { |
|
88 |
|
89 iSourceSel=new (ELeave) CMsvEntrySelection; |
|
90 CheckSelectionL(aSourceSel, iSourceSel, ETrue, EFalse, EFalse, ETrue); |
|
91 |
|
92 // Initialise the progress counters |
|
93 iProgressMsgsToDo=iSourceSel->Count(); |
|
94 iProgressMsgsDone=0; |
|
95 iMarkFlag = aFlagChanged; |
|
96 iEntrySelection = ETrue; |
|
97 // Add to the active scheduler |
|
98 CActiveScheduler::Add(this); |
|
99 } |
|
100 |
|
101 |
|
102 |
|
103 void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus, CImapSession& aSession) |
69 void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus, CImapSession& aSession) |
104 //void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus) |
70 //void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus) |
105 { |
71 { |
106 iSession = &aSession; |
72 iSession = &aSession; |
107 __LOG_TEXT(iSession->LogId(), "CImapUpdateFlagOperation::StartOperation()"); |
73 __LOG_TEXT(iSession->LogId(), "CImapUpdateFlagOperation::StartOperation()"); |
121 SetCurrentStep(); |
87 SetCurrentStep(); |
122 switch (iCurrentStep) |
88 switch (iCurrentStep) |
123 { |
89 { |
124 |
90 |
125 case EUpdateFlag: |
91 case EUpdateFlag: |
126 { |
92 { |
127 HBufC8* uidSeq = NULL; |
93 TMsvEmailEntry entry = iServerEntry.Entry(); |
128 if(!iEntrySelection) //Entry iMarkFlag is Flase |
94 TUint id = entry.UID(); |
129 { |
95 iMessageUids.AppendL(id); |
130 TMsvEmailEntry entry = iServerEntry.Entry(); |
96 if(entry.Unread()) |
131 TUint id = entry.UID(); |
97 { |
132 iMessageUids.AppendL(id); |
98 entry.SetSeenIMAP4Flag(EFalse); |
133 if(entry.Unread()) |
99 } |
134 { |
100 else |
135 entry.SetSeenIMAP4Flag(EFalse); |
101 { |
136 } |
102 entry.SetSeenIMAP4Flag(ETrue); |
137 else |
103 } |
138 { |
104 |
139 entry.SetSeenIMAP4Flag(ETrue); |
105 |
140 } |
106 User::LeaveIfError(iServerEntry.ChangeEntry(entry)); |
141 |
107 |
142 |
108 HBufC8* uidSeq = CImapSession::CreateSequenceSetLC(iMessageUids); |
143 User::LeaveIfError(iServerEntry.ChangeEntry(entry)); |
109 |
144 |
110 // finished with the UID array. Clear it. |
145 uidSeq = CImapSession::CreateSequenceSetLC(iMessageUids); |
111 iMessageUids.Reset(); |
146 |
112 if(entry.SeenIMAP4Flag()) |
147 // finished with the UID array. Clear it. |
113 { |
148 iMessageUids.Reset(); |
114 // issue the store command |
149 if(entry.SeenIMAP4Flag()) |
115 iSession->StoreL(iStatus, uidSeq->Des(), KImapAddFlags, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
150 { |
|
151 // issue the store command |
|
152 iSession->StoreL(iStatus, uidSeq->Des(), KImapAddFlags, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
|
153 |
|
154 } |
|
155 else |
|
156 { |
|
157 // issue the store command |
|
158 iSession->StoreL(iStatus, uidSeq->Des(), KStoreFlagsClearCommand, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
|
159 } |
|
160 } |
|
161 else //Selection iMarkFlag is Trure |
|
162 { |
|
163 TMsvEntry *aNewEntry1; |
|
164 |
116 |
165 TInt count = iSourceSel->Count(); |
117 } |
166 while (count--) |
118 else |
167 { |
119 { |
168 iServerEntry.GetEntryFromId(iSourceSel->At(count), aNewEntry1); |
120 // issue the store command |
169 TMsvEmailEntry entry(*aNewEntry1); |
121 iSession->StoreL(iStatus, uidSeq->Des(), KStoreFlagsClearCommand, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
170 iMessageUids.AppendL(entry.UID()); |
122 } |
171 |
|
172 if(iMarkFlag) // True means Unread |
|
173 { |
|
174 entry.SetSeenIMAP4Flag(EFalse); |
|
175 } |
|
176 else |
|
177 { |
|
178 entry.SetSeenIMAP4Flag(ETrue); |
|
179 } |
|
180 SetEntryL((*iSourceSel)[count]); |
|
181 User::LeaveIfError(iServerEntry.ChangeEntry(entry)); |
|
182 }// end of while |
|
183 |
|
184 uidSeq = CImapSession::CreateSequenceSetLC(iMessageUids); |
|
185 |
|
186 // finished with the UID array. Clear it. |
|
187 iMessageUids.Reset(); |
|
188 if(!iMarkFlag) //read |
|
189 { |
|
190 // issue the store command |
|
191 iSession->StoreL(iStatus, uidSeq->Des(), KImapAddFlags, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
|
192 } |
|
193 else //Unread |
|
194 { |
|
195 // issue the store command |
|
196 iSession->StoreL(iStatus, uidSeq->Des(), KStoreFlagsClearCommand, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
|
197 } |
|
198 } //End of else (Selection) |
|
199 |
123 |
200 iProgressState = TImap4GenericProgress::EBusy; |
124 iProgressState = TImap4GenericProgress::EBusy; |
201 CleanupStack::PopAndDestroy(uidSeq); |
125 CleanupStack::PopAndDestroy(uidSeq); |
202 iNextStep = EFinished; |
126 iNextStep = EFinished; |
203 break; |
127 break; |