|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <msvids.h> |
|
17 #include <msventry.h> |
|
18 #include <msvschedulesettings.h> |
|
19 #include "pigeonservermtm.h" |
|
20 |
|
21 #include <msvoffpeaktime.h> |
|
22 #include <flogger.h> |
|
23 #include <msvuids.h> |
|
24 #include <msvsysagentaction.h> |
|
25 |
|
26 #include <tmsvschedulesettingsutils.h> |
|
27 #include <centralrepository.h> |
|
28 |
|
29 _LIT(KPigeonLogFile, "pigeon.txt"); |
|
30 |
|
31 CPigeonServerMtm::CPigeonServerMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aServerEntry) : CScheduleBaseServerMtm(aRegisteredMtmDll, aServerEntry) |
|
32 { |
|
33 } |
|
34 |
|
35 CPigeonServerMtm::~CPigeonServerMtm() |
|
36 { |
|
37 delete iScheduleSend; |
|
38 } |
|
39 |
|
40 void CPigeonServerMtm::ConstructL() |
|
41 { |
|
42 iScheduleSend = CPigeonScheduledSend::NewL(*iServerEntry); |
|
43 |
|
44 // Get the entry id for the pigeon service entry. |
|
45 User::LeaveIfError(iServerEntry->SetEntry(KMsvRootIndexEntryId)); |
|
46 CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection(); |
|
47 CleanupStack::PushL(sel); |
|
48 User::LeaveIfError(iServerEntry->GetChildrenWithMtm(KUidMsgTypePigeon, *sel)); |
|
49 TInt count = sel->Count(); |
|
50 if( count > 1 ) // should only be one service entry |
|
51 User::Leave(KErrCorrupt); |
|
52 if( count == 0 ) |
|
53 { |
|
54 // Create the settings |
|
55 TMsvEntry serviceEntry; |
|
56 serviceEntry.iType= KUidMsvServiceEntry; |
|
57 serviceEntry.iMtm = KUidMsgTypePigeon; |
|
58 |
|
59 User::LeaveIfError(iServerEntry->CreateEntry(serviceEntry)); |
|
60 iServiceId = serviceEntry.Id(); |
|
61 } |
|
62 else |
|
63 { |
|
64 iServiceId = sel->At(0); |
|
65 } |
|
66 CleanupStack::PopAndDestroy(sel); |
|
67 User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId)); |
|
68 iHeapFailure = EFalse; |
|
69 } |
|
70 |
|
71 EXPORT_C CPigeonServerMtm* CPigeonServerMtm::NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry& aServerEntry) |
|
72 { |
|
73 CPigeonServerMtm* self = new (ELeave) CPigeonServerMtm(aRegisteredMtmDll, &aServerEntry); |
|
74 CleanupStack::PushL(self); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop(self); |
|
77 return self; |
|
78 } |
|
79 |
|
80 const TDesC8& CPigeonServerMtm::Progress() |
|
81 { |
|
82 RFileLogger::Write(KSchSendLogDir, KPigeonLogFile, EFileLoggingModeAppend, |
|
83 _L("CPigeonServerMtm::Progress()")); |
|
84 |
|
85 return iProgress; |
|
86 } |
|
87 |
|
88 void CPigeonServerMtm::ScheduleL(CMsvEntrySelection& aSelection, const TBool /*aMove*/, const TDesC8& aParameter, TRequestStatus& /*aStatus*/) |
|
89 { |
|
90 TMsvSchedulePackage package; |
|
91 package.iCommandId = ESendScheduledL; |
|
92 package.iParameter = aParameter; |
|
93 iScheduleSend->ScheduleL(aSelection, package); |
|
94 } |
|
95 |
|
96 void CPigeonServerMtm::RestoreSettingsL() |
|
97 { |
|
98 // Restore the system agent actions/conditions and the pending conditions |
|
99 // timeout value - these are the only ones that pigeon clients can set. |
|
100 CRepository* repository = CRepository::NewLC(KUidMsgTypePigeon); |
|
101 iScheduleSend->LoadSysAgentActionsL(*repository); |
|
102 iScheduleSend->LoadPendingConditionsTimeoutL(*repository); |
|
103 CleanupStack::PopAndDestroy(repository); |
|
104 } |
|
105 |
|
106 void CPigeonServerMtm::SendScheduledL(CMsvEntrySelection& aSelection, const TBool /*aMove*/, const TDesC8& /*aParameter*/, TRequestStatus& /*aStatus*/) |
|
107 { |
|
108 TBool leave = EFalse; |
|
109 for ( TInt i = 0; i < aSelection.Count(); ++i ) |
|
110 { |
|
111 // Move message to the sent folder, and update sending state to Sent. |
|
112 TInt err = iServerEntry->SetEntry(aSelection[i]); |
|
113 TMsvEntry entry = iServerEntry->Entry(); |
|
114 |
|
115 // Check each message to see if it should be sent... |
|
116 if( entry.iError == KPigeonErrFailFirstSend ) |
|
117 { |
|
118 leave = ETrue; |
|
119 } |
|
120 else |
|
121 { |
|
122 entry.SetSendingState(KMsvSendStateSent); |
|
123 entry.iDetails.Set(KSchSendTestDetails); |
|
124 err = iServerEntry->ChangeEntry(entry); |
|
125 TMsvId id = entry.Id(); |
|
126 err = iServerEntry->SetEntry(KMsvSentEntryId); |
|
127 if(KErrNone == err) |
|
128 { |
|
129 err = iServerEntry->SetEntry(KMsvGlobalOutBoxIndexEntryId); |
|
130 if(KErrNone == err) |
|
131 { |
|
132 // Move it... |
|
133 err = iServerEntry->MoveEntryWithinService(id, KMsvSentEntryId); |
|
134 } |
|
135 } |
|
136 } |
|
137 } |
|
138 iServerEntry->SetEntry(KMsvNullIndexEntryId); |
|
139 |
|
140 if( leave ) |
|
141 User::Leave(KErrDisconnected); |
|
142 } |
|
143 |
|
144 void CPigeonServerMtm::SetFailFirstSendL(CMsvEntrySelection& aSelection) |
|
145 { |
|
146 for( TInt i = 0; i < aSelection.Count(); ++i ) |
|
147 { |
|
148 // Copy message to the sent folder, but update sending state to Sent. |
|
149 TInt err = iServerEntry->SetEntry(aSelection[i]); |
|
150 TMsvEntry entry = iServerEntry->Entry(); |
|
151 |
|
152 // Set the error... |
|
153 entry.iError = KPigeonErrFailFirstSend; |
|
154 err = iServerEntry->ChangeEntry(entry); |
|
155 } |
|
156 iServerEntry->SetEntry(KMsvNullIndexEntryId); |
|
157 } |
|
158 |
|
159 void CPigeonServerMtm::StartCommandL(CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter, TRequestStatus& aStatus) |
|
160 { |
|
161 RestoreSettingsL(); |
|
162 |
|
163 iProgress().SetCommand(aCommand); |
|
164 const TMsvId id = iServerEntry->Entry().Id(); |
|
165 |
|
166 RFileLogger::WriteFormat(KSchSendLogDir, KPigeonLogFile, EFileLoggingModeAppend, |
|
167 _L("CPigeonServerMtm::StartCommandL(aSelection.Count() == %d, aCommand == %d, aParamter.Length() == %d)"), |
|
168 aSelection.Count(), |
|
169 aCommand, |
|
170 aParameter.Length()); |
|
171 |
|
172 TRAP(iProgress().iError, DoStartCommandL(aSelection, iProgress().Command(), aParameter, aStatus)); |
|
173 |
|
174 TRequestStatus* bStatus = &aStatus; |
|
175 User::RequestComplete(bStatus, iProgress().iError); |
|
176 iServerEntry->SetEntry(id); //ignore error |
|
177 } |
|
178 |
|
179 void CPigeonServerMtm::DoStartCommandL(CMsvEntrySelection& aSelection, TSchSendTestOperation aCommand, const TDesC8& aParameter, TRequestStatus& aStatus) |
|
180 { |
|
181 |
|
182 if(iHeapFailure) |
|
183 __UHEAP_FAILNEXT(iNextFailure++); |
|
184 else |
|
185 __UHEAP_RESET; |
|
186 |
|
187 TMsvSchedulePackage package; |
|
188 package.iCommandId = ESendScheduledL; |
|
189 package.iParameter = aParameter; |
|
190 |
|
191 switch(aCommand) |
|
192 { |
|
193 case EOpFail: |
|
194 { |
|
195 TPckgC<TInt> pkg(0); |
|
196 pkg.Set(aParameter); |
|
197 User::Leave(pkg()); |
|
198 } |
|
199 break; |
|
200 case EScheduleOpFail: |
|
201 { |
|
202 package.iCommandId = EOpFail; |
|
203 //pass through |
|
204 } |
|
205 case EScheduleAllL: |
|
206 { |
|
207 iScheduleSend->ScheduleL(aSelection, package); |
|
208 UpdateProgressL(aSelection); |
|
209 } break; |
|
210 case EReScheduleRetryAllL: |
|
211 { |
|
212 // Change the iCommandId to do a re-schedule |
|
213 package.iCommandId = EReScheduleRetryAllL; |
|
214 iScheduleSend->ReScheduleL(aSelection, package); |
|
215 UpdateProgressL(aSelection); |
|
216 |
|
217 // Bit of a hack here!! Check the selection to see if the messages |
|
218 // have been re-scheduled. If they have not been re-scheduled, then |
|
219 // copy to the Sent folder... |
|
220 for( TInt i=0; i<aSelection.Count(); ++i ) |
|
221 { |
|
222 User::LeaveIfError(iServerEntry->SetEntry(aSelection[i])); |
|
223 TMsvEntry entry = iServerEntry->Entry(); |
|
224 |
|
225 if( entry.SendingState() == KMsvSendStateWaiting ) |
|
226 { |
|
227 User::LeaveIfError(iServerEntry->SetEntry(KMsvSentEntryId)); |
|
228 User::LeaveIfError(iServerEntry->CreateEntry(entry)); |
|
229 } |
|
230 } |
|
231 User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId)); |
|
232 } break; |
|
233 case EReScheduleAllL: |
|
234 { |
|
235 // Pass through action to be performed on reschedule. (Default is to do nothing.) |
|
236 TMsvSendErrorAction laterAction; |
|
237 laterAction.iAction = ESendActionRetryImmediately; |
|
238 laterAction.iRetries = ESendRetriesFixed; |
|
239 laterAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
240 |
|
241 iScheduleSend->ReScheduleL(aSelection, package, &laterAction); |
|
242 UpdateProgressL(aSelection); |
|
243 } break; |
|
244 case EDeleteScheduleL: |
|
245 { |
|
246 iScheduleSend->DeleteScheduleL(aSelection); |
|
247 } break; |
|
248 case ESendScheduledL: |
|
249 { |
|
250 SendScheduledL(aSelection, aCommand, aParameter, aStatus); |
|
251 } break; |
|
252 case ECheckScheduleL: |
|
253 { |
|
254 iScheduleSend->CheckScheduleL(aSelection); |
|
255 } break; |
|
256 case ESetRetryImmediately: |
|
257 case ESetRetryLater: |
|
258 case ESetRetryVariable: |
|
259 case ESetNoRetry: |
|
260 { |
|
261 iScheduleSend->SetupL(aCommand); |
|
262 |
|
263 CRepository* repository = CRepository::NewLC(KUidMsgTypePigeon); |
|
264 iScheduleSend->SaveSysAgentActionsL(*repository); |
|
265 CleanupStack::PopAndDestroy(repository); |
|
266 } break; |
|
267 case ESetNowOffPeak: |
|
268 case ESetNowNotOffPeak: |
|
269 case ESetFirstOffPeakBest: |
|
270 case ESetLastOffPeakBest: |
|
271 { |
|
272 iScheduleSend->SetupL(aCommand); |
|
273 } break; |
|
274 case ESetIncrementalHeapFailure: |
|
275 { |
|
276 iHeapFailure = ETrue; |
|
277 // drop through |
|
278 } |
|
279 case EResetIncrementalHeapFailure: |
|
280 { |
|
281 iNextFailure = 0; |
|
282 } break; |
|
283 case ENoIncrementalHeapFailure: |
|
284 { |
|
285 iHeapFailure = EFalse; |
|
286 __UHEAP_RESET; |
|
287 } break; |
|
288 case EScheduleFailFirstSend: |
|
289 { |
|
290 SetFailFirstSendL(aSelection); |
|
291 |
|
292 iScheduleSend->ScheduleL(aSelection, package); |
|
293 UpdateProgressL(aSelection); |
|
294 }break; |
|
295 default: |
|
296 User::Panic(_L("pigeon server"), 1); |
|
297 break; |
|
298 } |
|
299 |
|
300 if(iHeapFailure) |
|
301 { |
|
302 __UHEAP_RESET; |
|
303 } |
|
304 |
|
305 } |
|
306 |
|
307 void CPigeonServerMtm::UpdateProgressL(const CMsvEntrySelection& aSelection) |
|
308 { |
|
309 RFileLogger::WriteFormat(KSchSendLogDir, KPigeonLogFile, EFileLoggingModeAppend, |
|
310 _L("CPigeonServerMtm::UpdateProgressL(aSelection.Count() == %d)"), |
|
311 aSelection.Count()); |
|
312 |
|
313 //Uses Progess to return the time that the task scheduler |
|
314 //reports that the first message in the selection is scheduled for |
|
315 |
|
316 if (aSelection.Count()==0) return; |
|
317 |
|
318 //Make a big load of reference parameters |
|
319 TInt size = 0; |
|
320 |
|
321 RScheduler scheduler; |
|
322 User::LeaveIfError(scheduler.Connect()); |
|
323 CleanupClosePushL(scheduler); |
|
324 CMsvScheduledEntry* entry = ScheduledEntryLC(aSelection[0]); |
|
325 const TInt taskId = entry->iData.iTaskId; |
|
326 const TInt error = scheduler.GetTaskDataSize(taskId, size); |
|
327 |
|
328 if(error == KErrNone) |
|
329 { |
|
330 TTaskInfo info; |
|
331 HBufC* buf = HBufC::NewLC(size); |
|
332 TPtr ptr(buf->Des()); |
|
333 TSchedulerItemRef ref; |
|
334 TTime time; |
|
335 |
|
336 User::LeaveIfError(scheduler.GetTaskInfoL(taskId, info, ptr, ref, time)); |
|
337 |
|
338 iProgress().iTime = time; |
|
339 CleanupStack::PopAndDestroy(buf); |
|
340 } |
|
341 else if (error == KErrNotFound) |
|
342 { |
|
343 iProgress().iTime = entry->ScheduleDate(); |
|
344 } |
|
345 else |
|
346 User::Leave(error); |
|
347 |
|
348 CleanupStack::PopAndDestroy(2); //entry, scheduler |
|
349 |
|
350 } |
|
351 |
|
352 CMsvScheduledEntry* CPigeonServerMtm::ScheduledEntryLC(TMsvId aId) |
|
353 { |
|
354 CMsvScheduledEntry* entry = iScheduleSend->GetMessageL(aId); |
|
355 CleanupStack::PushL(entry); |
|
356 return entry; |
|
357 } |
|
358 |
|
359 CMsvStore* CPigeonServerMtm::GetServiceEntryEditStoreLC() |
|
360 { |
|
361 User::LeaveIfError(iServerEntry->SetEntry(iServiceId)); |
|
362 CMsvStore* store = iServerEntry->EditStoreL(); |
|
363 CleanupStack::PushL(store); |
|
364 User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId)); |
|
365 |
|
366 return store; |
|
367 } |
|
368 |
|
369 |
|
370 EXPORT_C CPigeonScheduledEntry* CPigeonScheduledEntry::NewL(const TMsvEntry& aMsvEntry) |
|
371 { |
|
372 CPigeonScheduledEntry* pse = new (ELeave) CPigeonScheduledEntry(aMsvEntry); |
|
373 CleanupStack::PushL(pse); |
|
374 pse->ConstructL(); |
|
375 CleanupStack::Pop(); |
|
376 return pse; |
|
377 } |
|
378 |
|
379 void CPigeonScheduledEntry::ConstructL() |
|
380 { |
|
381 |
|
382 } |
|
383 |
|
384 EXPORT_C CPigeonScheduledSend* CPigeonScheduledSend::NewL(CMsvServerEntry& aServerEntry) |
|
385 { |
|
386 CPigeonScheduledSend* ss = new (ELeave) CPigeonScheduledSend(aServerEntry); |
|
387 CleanupStack::PushL(ss); |
|
388 ss->ConstructL(); |
|
389 CleanupStack::Pop(); |
|
390 return ss; |
|
391 } |
|
392 |
|
393 void CPigeonScheduledSend::ConstructL() |
|
394 { |
|
395 CMsvScheduleSend::ConstructL(); |
|
396 |
|
397 //Lists of all the possible settings, actions and offpeak times |
|
398 //which can be set dynamically by Setup() |
|
399 PopulateErrorListL(); |
|
400 PopulateSettingsL(); |
|
401 iActionsList = new (ELeave) CArrayFixFlat<TMsvSendErrorAction>(20); |
|
402 PopulateActionsListL(); |
|
403 iOffPeakList = new (ELeave) CArrayFixFlat<TMsvOffPeakTime>(20); |
|
404 PopulateOffPeakListL(); |
|
405 } |
|
406 |
|
407 //Puts the existing settings and some new settings in the list of settings |
|
408 //Now both will be deleted on exit. |
|
409 void CPigeonScheduledSend::PopulateSettingsL() |
|
410 { |
|
411 delete iSettings; |
|
412 iSettings = NULL; |
|
413 |
|
414 //Make some shiny new settings instead |
|
415 iSettings = CMsvScheduleSettings::NewL(); |
|
416 iSettings->SetShortInterval(KShortInterval); |
|
417 iSettings->SetLongInterval(KLongInterval); |
|
418 |
|
419 CArrayFixFlat<TTimeIntervalSeconds>* intervals = new(ELeave)CArrayFixFlat<TTimeIntervalSeconds>(20); |
|
420 CleanupStack::PushL(intervals); |
|
421 intervals->AppendL(KFirstInterval); |
|
422 intervals->AppendL(KSecondInterval); |
|
423 intervals->AppendL(KThirdInterval); |
|
424 |
|
425 iSettings->SetVariableIntervalsL(*intervals); // copies intervals |
|
426 |
|
427 CleanupStack::PopAndDestroy(); //intervals |
|
428 // iSettingsList->AppendL(custom); |
|
429 } |
|
430 |
|
431 void CPigeonScheduledSend::PopulateActionsListL() |
|
432 { |
|
433 iActionsList->Reset(); |
|
434 iActionsList->AppendL(iErrorActions->Default()); |
|
435 |
|
436 TMsvSendErrorAction immediatelyAction; |
|
437 immediatelyAction.iAction = ESendActionRetryImmediately; |
|
438 immediatelyAction.iRetries = ESendRetriesFixed; |
|
439 immediatelyAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
440 |
|
441 iActionsList->AppendL(immediatelyAction); |
|
442 |
|
443 TMsvSendErrorAction laterAction; |
|
444 laterAction.iAction = ESendActionRetryLater; |
|
445 laterAction.iRetries = ESendRetriesFixed; |
|
446 laterAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
447 |
|
448 iActionsList->AppendL(laterAction); |
|
449 |
|
450 TMsvSendErrorAction variableAction; |
|
451 variableAction.iAction = ESendActionRetryLater; |
|
452 variableAction.iRetries = ESendRetriesFixed; |
|
453 variableAction.iRetrySpacing = ESendRetrySpacingVariable; |
|
454 |
|
455 iActionsList->AppendL(variableAction); |
|
456 |
|
457 TMsvSendErrorAction failAction; |
|
458 failAction.iAction = ESendActionFail; |
|
459 failAction.iRetries = ESendRetriesFixed; |
|
460 failAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
461 |
|
462 iActionsList->AppendL(failAction); |
|
463 } |
|
464 |
|
465 void CPigeonScheduledSend::PopulateErrorListL() |
|
466 { |
|
467 CMsvSendErrorActions* errorActions = CMsvSendErrorActions::NewL(); |
|
468 CleanupStack::PushL(errorActions); |
|
469 |
|
470 TMsvSendErrorAction immediatelyAction; |
|
471 immediatelyAction.iAction = ESendActionRetryImmediately; |
|
472 immediatelyAction.iRetries = ESendRetriesFixed; |
|
473 immediatelyAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
474 immediatelyAction.iError = KErrorActionImmediately; |
|
475 |
|
476 errorActions->AddSendErrorActionL(immediatelyAction); |
|
477 |
|
478 TMsvSendErrorAction laterAction; |
|
479 laterAction.iAction = ESendActionRetryLater; |
|
480 laterAction.iRetries = ESendRetriesFixed; |
|
481 laterAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
482 laterAction.iError = KErrorActionLater; |
|
483 |
|
484 errorActions->AddSendErrorActionL(laterAction); |
|
485 |
|
486 TMsvSendErrorAction variableAction; |
|
487 variableAction.iAction = ESendActionRetryLater; |
|
488 variableAction.iRetries = ESendRetriesFixed; |
|
489 variableAction.iRetrySpacing = ESendRetrySpacingVariable; |
|
490 variableAction.iError = KErrorActionVariable; |
|
491 |
|
492 errorActions->AddSendErrorActionL(variableAction); |
|
493 |
|
494 TMsvSendErrorAction failAction; |
|
495 failAction.iAction = ESendActionFail; |
|
496 failAction.iRetries = ESendRetriesFixed; |
|
497 failAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
498 failAction.iError = KErrorActionFail; |
|
499 |
|
500 errorActions->AddSendErrorActionL(failAction); |
|
501 |
|
502 TMsvSendErrorAction conditionsAction; |
|
503 conditionsAction.iAction = ESendActionRetryConditionMet; |
|
504 conditionsAction.iRetries = ESendRetriesFixed; |
|
505 conditionsAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
506 conditionsAction.iError = KErrorActionConditions; |
|
507 |
|
508 errorActions->AddSendErrorActionL(conditionsAction); |
|
509 |
|
510 TMsvSendErrorAction retryfailAction; |
|
511 retryfailAction.iAction = ESendActionRetryImmediately; |
|
512 retryfailAction.iRetries = ESendRetriesFixed; |
|
513 retryfailAction.iRetrySpacing = ESendRetrySpacingStatic; |
|
514 retryfailAction.iError = KErrorActionRetryFail; |
|
515 retryfailAction.SetMaxRetries(1); |
|
516 |
|
517 errorActions->AddSendErrorActionL(retryfailAction); |
|
518 |
|
519 delete iErrorActions; |
|
520 iErrorActions = errorActions; |
|
521 CleanupStack::Pop(errorActions); |
|
522 } |
|
523 |
|
524 void CPigeonScheduledSend::PopulateOffPeakListL() |
|
525 { |
|
526 //There are no existing off peak times set up |
|
527 //So no need to remember them |
|
528 iOffPeakList->Reset(); |
|
529 |
|
530 TTime t; |
|
531 TDateTime d; |
|
532 t.HomeTime(); |
|
533 t -= TTimeIntervalHours(1); |
|
534 d = t.DateTime(); |
|
535 |
|
536 TTimeIntervalMinutes twoHours = 120; |
|
537 |
|
538 TMsvOffPeakTime current(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours); |
|
539 iOffPeakList->AppendL(current); |
|
540 |
|
541 t -= TTimeIntervalDays(1); |
|
542 d = t.DateTime(); |
|
543 TMsvOffPeakTime yesterday(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours); |
|
544 iOffPeakList->AppendL(yesterday); |
|
545 |
|
546 t += TTimeIntervalDays(2); |
|
547 d = t.DateTime(); |
|
548 TMsvOffPeakTime tomorrow(t.DayNoInWeek(), d.Hour(), d.Minute(), twoHours); |
|
549 iOffPeakList->AppendL(tomorrow); |
|
550 } |
|
551 |
|
552 void CPigeonScheduledSend::SetupL(TSchSendTestOperation aOption) |
|
553 { |
|
554 if (aOption < 0) |
|
555 User::Panic(_L("Pigeon"), 23); |
|
556 switch(aOption) |
|
557 { |
|
558 case ESetRetryImmediately: |
|
559 SetActionL(EActionImmediately); |
|
560 break; |
|
561 case ESetRetryLater: |
|
562 SetActionL(EActionLater); |
|
563 break; |
|
564 case ESetRetryVariable: |
|
565 SetActionL(EActionVariable); |
|
566 break; |
|
567 case ESetNoRetry: |
|
568 SetActionL(EActionFail); |
|
569 break; |
|
570 case ESetNowOffPeak: |
|
571 { |
|
572 iOffPeakTimes->ResizeL(0); |
|
573 TMsvOffPeakTime opt = (*iOffPeakList)[EOffPeakCurrent]; |
|
574 iOffPeakTimes->AppendL(opt); |
|
575 break; |
|
576 } |
|
577 case ESetNowNotOffPeak: |
|
578 iOffPeakTimes->ResizeL(0); |
|
579 iOffPeakTimes->AppendL((*iOffPeakList)[EOffPeakFuture]); |
|
580 break; |
|
581 case ESetFirstOffPeakBest: |
|
582 iOffPeakTimes->ResizeL(0); |
|
583 iOffPeakTimes->AppendL((*iOffPeakList)[EOffPeakFuture]); |
|
584 iOffPeakTimes->AppendL((*iOffPeakList)[EOffPeakFinished]); |
|
585 break; |
|
586 case ESetLastOffPeakBest: |
|
587 iOffPeakTimes->ResizeL(0); |
|
588 iOffPeakTimes->AppendL((*iOffPeakList)[EOffPeakFinished]); |
|
589 iOffPeakTimes->AppendL((*iOffPeakList)[EOffPeakFuture]); |
|
590 break; |
|
591 default: |
|
592 User::Leave(KErrArgument); |
|
593 } |
|
594 } |
|
595 |
|
596 |
|
597 void CPigeonScheduledSend::SaveSysAgentActionsL(CRepository& aRepository) |
|
598 { |
|
599 TMsvScheduleSettingsUtils::SaveSysAgentSettingsL(*iAgentActions, aRepository); |
|
600 } |
|
601 |
|
602 void CPigeonScheduledSend::LoadSysAgentActionsL(CRepository& aRepository) |
|
603 { |
|
604 TMsvScheduleSettingsUtils::LoadSysAgentSettingsL(*iAgentActions, aRepository); |
|
605 } |
|
606 |
|
607 void CPigeonScheduledSend::LoadPendingConditionsTimeoutL(CRepository& aRepository) |
|
608 { |
|
609 // Just load the pending conditions timeout - don't care about anything else. |
|
610 CMsvScheduleSettings* settings = CMsvScheduleSettings::NewL(); |
|
611 CleanupStack::PushL(settings); |
|
612 TMsvScheduleSettingsUtils::LoadScheduleSettingsL(*settings, aRepository); |
|
613 iSettings->SetPendingConditionsTimeout(settings->PendingConditionsTimeout()); |
|
614 CleanupStack::PopAndDestroy(settings); |
|
615 } |
|
616 |
|
617 void CPigeonScheduledSend::SetActionL(TActions aAction) |
|
618 { |
|
619 iAgentActions->iDefault = (*iActionsList)[aAction]; |
|
620 } |
|
621 |
|
622 CPigeonScheduledSend::~CPigeonScheduledSend() |
|
623 { |
|
624 delete iActionsList; |
|
625 delete iOffPeakList; |
|
626 } |
|
627 |
|
628 CMsvScheduledEntry* CPigeonScheduledSend::GetMessageL(const TMsvId aId) const |
|
629 { |
|
630 const TMsvId id = iServerEntry.Entry().Id(); |
|
631 iServerEntry.SetEntry(aId); |
|
632 CPigeonScheduledEntry* entry = CPigeonScheduledEntry::NewL(iServerEntry.Entry()); |
|
633 CleanupStack::PushL(entry); |
|
634 |
|
635 if (iServerEntry.HasStoreL()) |
|
636 { |
|
637 CMsvStore* store = iServerEntry.ReadStoreL(); |
|
638 CleanupStack::PushL(store); |
|
639 |
|
640 //Restore the entry from the message's store. |
|
641 entry->RestoreL(*store); |
|
642 CleanupStack::PopAndDestroy(store); |
|
643 } |
|
644 |
|
645 CleanupStack::Pop(entry); |
|
646 iServerEntry.SetEntry(id); //ignore error |
|
647 return entry; |
|
648 } |
|
649 |
|
650 TBool CPigeonScheduledEntry::CanSendToAnyRecipients(const TMsvSendErrorAction& aAction) |
|
651 { |
|
652 return (iData.Retries() < aAction.MaxRetries()); |
|
653 } |
|
654 |
|
655 TBool CPigeonScheduledEntry::CanSendToAnyRecipients(const CMsvSendErrorActions& aErrorActions, TMsvSendErrorAction& aAction) |
|
656 { |
|
657 if( aErrorActions.GetSendErrorAction(Error(), aAction) != KErrNone ) |
|
658 { |
|
659 aAction = aErrorActions.Default(); |
|
660 } |
|
661 return (iData.Retries() < aAction.MaxRetries()); |
|
662 } |
|
663 |
|
664 TBool CPigeonScheduledEntry::RecipientsAllSent() const |
|
665 { |
|
666 if( Error() == KErrorActionFail || Error() == KErrorActionRetryFail ) |
|
667 return EFalse; |
|
668 return ETrue; |
|
669 } |