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