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 |
69 void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus, CImapSession& aSession) |
103 void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus, CImapSession& aSession) |
70 //void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus) |
104 //void CImapUpdateFlagOperation::StartOperation(TRequestStatus& aStatus) |
71 { |
105 { |
72 iSession = &aSession; |
106 iSession = &aSession; |
73 __LOG_TEXT(iSession->LogId(), "CImapUpdateFlagOperation::StartOperation()"); |
107 __LOG_TEXT(iSession->LogId(), "CImapUpdateFlagOperation::StartOperation()"); |
87 SetCurrentStep(); |
121 SetCurrentStep(); |
88 switch (iCurrentStep) |
122 switch (iCurrentStep) |
89 { |
123 { |
90 |
124 |
91 case EUpdateFlag: |
125 case EUpdateFlag: |
92 { |
126 { |
93 TMsvEmailEntry entry = iServerEntry.Entry(); |
127 HBufC8* uidSeq = NULL; |
94 TUint id = entry.UID(); |
128 if(!iEntrySelection) //Entry iMarkFlag is Flase |
95 iMessageUids.AppendL(id); |
129 { |
96 if(entry.Unread()) |
130 TMsvEmailEntry entry = iServerEntry.Entry(); |
97 { |
131 TUint id = entry.UID(); |
98 entry.SetSeenIMAP4Flag(EFalse); |
132 iMessageUids.AppendL(id); |
99 } |
133 if(entry.Unread()) |
100 else |
134 { |
101 { |
135 entry.SetSeenIMAP4Flag(EFalse); |
102 entry.SetSeenIMAP4Flag(ETrue); |
136 } |
103 } |
137 else |
104 |
138 { |
105 |
139 entry.SetSeenIMAP4Flag(ETrue); |
106 User::LeaveIfError(iServerEntry.ChangeEntry(entry)); |
140 } |
107 |
141 |
108 HBufC8* uidSeq = CImapSession::CreateSequenceSetLC(iMessageUids); |
142 |
109 |
143 User::LeaveIfError(iServerEntry.ChangeEntry(entry)); |
110 // finished with the UID array. Clear it. |
144 |
111 iMessageUids.Reset(); |
145 uidSeq = CImapSession::CreateSequenceSetLC(iMessageUids); |
112 if(entry.SeenIMAP4Flag()) |
146 |
113 { |
147 // finished with the UID array. Clear it. |
114 // issue the store command |
148 iMessageUids.Reset(); |
115 iSession->StoreL(iStatus, uidSeq->Des(), KImapAddFlags, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
149 if(entry.SeenIMAP4Flag()) |
|
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; |
116 |
164 |
117 } |
165 TInt count = iSourceSel->Count(); |
118 else |
166 while (count--) |
119 { |
167 { |
120 // issue the store command |
168 iServerEntry.GetEntryFromId(iSourceSel->At(count), aNewEntry1); |
121 iSession->StoreL(iStatus, uidSeq->Des(), KStoreFlagsClearCommand, KImapFlagSeen, ETrue, iFlagInfoResponseArray); |
169 TMsvEmailEntry entry(*aNewEntry1); |
122 } |
170 iMessageUids.AppendL(entry.UID()); |
|
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) |
123 |
199 |
124 iProgressState = TImap4GenericProgress::EBusy; |
200 iProgressState = TImap4GenericProgress::EBusy; |
125 CleanupStack::PopAndDestroy(uidSeq); |
201 CleanupStack::PopAndDestroy(uidSeq); |
126 iNextStep = EFinished; |
202 iNextStep = EFinished; |
127 break; |
203 break; |