69 TInt aEvent, TInt aMailbox, TInt aPluginId ,TInt /*aError*/ ) |
69 TInt aEvent, TInt aMailbox, TInt aPluginId ,TInt /*aError*/ ) |
70 { |
70 { |
71 FUNC_LOG; |
71 FUNC_LOG; |
72 if ( iPlugin.PluginId() == aPluginId && |
72 if ( iPlugin.PluginId() == aPluginId && |
73 ( aEvent == KIpsSosEmailSyncStarted || |
73 ( aEvent == KIpsSosEmailSyncStarted || |
74 aEvent == KIpsSosEmailSyncCompleted || |
74 aEvent == KIpsSosEmailSyncCompleted || |
75 aEvent == KIpsSosEmailSyncOnHold ) ) |
75 aEvent == KIpsSosEmailSyncOnHold ) ) |
76 { |
76 { |
77 AppendMailboxToSyncingMailbox( aMailbox, aEvent ); |
77 AppendMailboxToSyncingMailbox( aMailbox, aEvent ); |
78 } |
78 } |
79 } |
79 } |
80 |
80 |
87 TMsvEntry tEntry; |
87 TMsvEntry tEntry; |
88 TMsvId service; |
88 TMsvId service; |
89 |
89 |
90 TInt err = iSession.GetEntry( aMailboxId.Id(), service, tEntry ); |
90 TInt err = iSession.GetEntry( aMailboxId.Id(), service, tEntry ); |
91 |
91 |
92 if ( err != KErrNone || iOperationsRef.Count() == 0 ) |
92 if ( err != KErrNone || !tEntry.Connected() || iOperationsRef.Count() == 0 ) |
93 { |
93 { |
|
94 // no sync ongoing if not connected |
94 return Idle; |
95 return Idle; |
95 } |
96 } |
96 |
97 |
97 // If the mailbox is not online but it has some connection operation |
98 #ifndef RD_101_EMAIL |
98 // already running, it means that it will be synchronized when the mailbox |
99 // <cmail> RD_IPS_AO_PLUGIN flaf removed |
99 // goes online. So we need to check is there any connection operation |
|
100 // ongoing and return StartingSync in that case. |
|
101 if( !tEntry.Connected() ) |
|
102 { |
|
103 if( ConnOpRunning( aMailboxId ) ) |
|
104 { |
|
105 // Some connection operation already processing, so the sync |
|
106 // will start soon |
|
107 return StartingSync; |
|
108 } |
|
109 else |
|
110 { |
|
111 // no sync ongoing if not connected and no connection operations |
|
112 // started |
|
113 return Idle; |
|
114 } |
|
115 } |
|
116 |
|
117 RAlwaysOnlineClientSession aosession; |
100 RAlwaysOnlineClientSession aosession; |
118 |
101 |
119 err = aosession.Connect(); |
102 err = aosession.Connect(); |
120 if ( err == KErrNone ) |
103 if ( err == KErrNone ) |
121 { |
104 { |
131 { |
114 { |
132 return EmailSyncing; |
115 return EmailSyncing; |
133 } |
116 } |
134 } |
117 } |
135 aosession.Close(); |
118 aosession.Close(); |
|
119 #endif |
|
120 |
|
121 // </cmail> |
136 |
122 |
137 // found correct operation |
123 // found correct operation |
138 for ( TInt i = 0; i < iOperationsRef.Count(); i++ ) |
124 for ( TInt i = 0; i < iOperationsRef.Count(); i++ ) |
139 { |
125 { |
140 const CIpsPlgBaseOperation* baseOp = iOperationsRef[i]->BaseOperation(); |
126 const CIpsPlgBaseOperation* baseOp = iOperationsRef[i]->BaseOperation(); |
141 |
127 |
142 if ( baseOp && baseOp->FSMailboxId() == aMailboxId && |
128 if ( baseOp && baseOp->FSMailboxId() == aMailboxId && |
143 ( baseOp->IpsOpType() == EIpsOpTypePop3SyncOp || |
129 ( baseOp->IpsOpType() == EIpsOpTypePop3SyncOp |
144 baseOp->IpsOpType() == EIpsOpTypeImap4SyncOp || |
130 || baseOp->IpsOpType() == EIpsOpTypeImap4SyncOp |
145 baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) ) |
131 || baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) ) |
146 { |
132 { |
147 // Due to timing problems we might in some rare cases report |
133 // check syncing mailbox, to prevent sync icon running |
148 // EmailSyncing here even if the actual syncing is already |
134 // all the time |
149 // finsihed, because the operation is removed from the array |
135 if ( FindMailbox( aMailboxId.Id() ) == KIpsSosEmailSyncCompleted ) |
150 // with an async function call. HandlePropertyEventL events |
136 { |
151 // seem to be even more unreliable (sync start event comes with |
137 return Idle; |
152 // big delay), so we can't trust those either. Some kind of |
138 } |
153 // redesign is needed to get this sync state query more reliable. |
139 else |
154 return EmailSyncing; |
140 { |
|
141 return EmailSyncing; |
|
142 } |
155 } |
143 } |
156 } |
144 } |
157 return Idle; |
145 return Idle; |
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // --------------------------------------------------------------------------- |
|
162 TBool CIpsPlgSyncStateHandler::ConnOpRunning( const TFSMailMsgId& aMailBoxId ) |
|
163 { |
|
164 FUNC_LOG; |
|
165 for ( TInt i = 0; i < iOperationsRef.Count(); i++ ) |
|
166 { |
|
167 const CIpsPlgBaseOperation* baseOp = iOperationsRef[i]->BaseOperation(); |
|
168 |
|
169 if ( baseOp && baseOp->FSMailboxId() == aMailBoxId && |
|
170 ( baseOp->IpsOpType() == EIpsOpTypePop3SyncOp |
|
171 || baseOp->IpsOpType() == EIpsOpTypeImap4SyncOp |
|
172 || baseOp->IpsOpType() == EIpsOpTypeOnlineOp |
|
173 || baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) ) |
|
174 { |
|
175 // Due to timing problems we might in some rare cases report |
|
176 // EmailSyncing here even if the actual syncing is already |
|
177 // finsihed, because the operation is removed from the array |
|
178 // with an async function call. HandlePropertyEventL events |
|
179 // seem to be even more unreliable (sync start event comes with |
|
180 // big delay), so we can't trust those either. Some kind of |
|
181 // redesign is needed to get this sync state query more reliable. |
|
182 return ETrue; |
|
183 } |
|
184 } |
|
185 return EFalse; |
|
186 } |
146 } |
187 |
147 |
188 // --------------------------------------------------------------------------- |
148 // --------------------------------------------------------------------------- |
189 // --------------------------------------------------------------------------- |
149 // --------------------------------------------------------------------------- |
190 TInt CIpsPlgSyncStateHandler::FindSyncingMailbox( TMsvId aMailbox ) |
150 TInt CIpsPlgSyncStateHandler::FindSyncingMailbox( TMsvId aMailbox ) |
293 } |
253 } |
294 |
254 |
295 // --------------------------------------------------------------------------- |
255 // --------------------------------------------------------------------------- |
296 // --------------------------------------------------------------------------- |
256 // --------------------------------------------------------------------------- |
297 void CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( |
257 void CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( |
298 CMsvSession& aSession, TMsvId aService ) |
258 CMsvSession& /*aSession*/, TMsvId /*aService*/ ) |
299 { |
259 { |
300 FUNC_LOG; |
260 FUNC_LOG; |
301 TTime now; |
261 TTime now; |
302 now.HomeTime(); |
262 now.HomeTime(); |
303 CIpsSetDataExtension* extendedSettings = CIpsSetDataExtension::NewLC(); |
263 //CIpsSetDataExtension* extendedSettings = CIpsSetDataExtension::NewLC(); |
304 CIpsSetDataApi* dataApi = CIpsSetDataApi::NewL( aSession ); |
264 //CIpsSetDataApi* dataApi = CIpsSetDataApi::NewL( aSession ); |
305 CleanupStack::PushL( dataApi ); |
265 //CleanupStack::PushL( dataApi ); |
306 dataApi->LoadExtendedSettingsL( aService, *extendedSettings ); |
266 //dataApi->LoadExtendedSettingsL( aService, *extendedSettings ); |
307 TAOInfo info; |
267 //TAOInfo info; |
308 info.iLastSuccessfulUpdate = now; |
268 //info.iLastSuccessfulUpdate = now; |
309 info.iUpdateSuccessfulWithCurSettings = ETrue; |
269 //info.iUpdateSuccessfulWithCurSettings = ETrue; |
310 extendedSettings->SetLastUpdateInfo( info ); |
270 //extendedSettings->SetLastUpdateInfo( info ); |
311 // clear flag |
271 // clear flag |
312 extendedSettings->SetEmnReceivedButNotSyncedFlag( EFalse ); |
272 //extendedSettings->SetEmnReceivedButNotSyncedFlag( EFalse ); |
313 dataApi->SaveExtendedSettingsL( *extendedSettings ); |
273 //dataApi->SaveExtendedSettingsL( *extendedSettings ); |
314 CleanupStack::PopAndDestroy( 2, extendedSettings ); |
274 //CleanupStack::PopAndDestroy( 2, extendedSettings ); |
315 } |
275 } |
316 |
276 |
317 |
277 |
318 // End of file |
278 // End of file |
319 |
279 |