First public contribution.
1 // Copyright (c) 2004-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 #include "SchLogger.h"
26 const TInt KSchedulerArrayGranularity = 1;
27 _LIT(KSchedulerPanic, "Task Scheduler");
29 void PanicClient(TInt aPanic, const RMessage2& aMessage)
34 //Note that panic also completes the message so don't complete anywhere else
35 aMessage.Panic(KSchedulerPanic,aPanic);
38 CSchSession::CSchSession(CTaskScheduler& aScheduler)
40 // C'Tor - must pass client to CSession
43 iTaskScheduler(&aScheduler),
48 CSchSession::~CSchSession()
53 if (!iClient->Users())
60 if(!iPendingNotification.IsNull())
61 iPendingNotification.Complete(KErrCancel);
64 void CSchSession::ServiceError(const RMessage2& aMessage,TInt aError)
66 // Handle an error or leave from CMySession::ServiceL()
67 // A bad descriptor error implies a badly programmed client, so panic it;
68 // otherwise use the default handling (report the error to the client)
71 if (aError==KErrBadDescriptor)
72 PanicClient(EPanicBadDescriptor,aMessage);
73 CSession2::ServiceError(aMessage,aError);
76 void CSchSession::ServiceL(const RMessage2& aMessage)
78 // Handle messages for this session.
79 // all API functions are synchronous so complete here too
83 iClientMessage = BSUL::CClientMessage::NewL(aMessage);
85 //Validate the message
86 TRAPD(error, iClientMessage->ValidateL());
90 TRAP(error, DoServiceL());
93 // don't complete message if we have paniced client (ie message is NULL)
94 iClientMessage->CompleteRequestL(error);
96 delete iClientMessage;
97 iClientMessage = NULL;
100 void CSchSession::DoServiceL()
102 // Handle messages for this session.
103 // all API functions are synchronous so complete here too
106 switch (iClientMessage->Function())
109 case ESchDbgMarkHeap:
112 case ESchDbgCheckHeap:
113 __UHEAP_CHECK(iClientMessage->GetIntL(0));
117 TInt count = iClientMessage->GetIntL(0);
119 //Three allocations are made for this message so add 3 to count
120 //CClientMessage::NewL
121 //CIntParameter::NewL
122 //RPointerArray::AppendL
123 __UHEAP_MARKENDC(count + 3);
126 case ESchDbgFailNext:
127 __UHEAP_FAILNEXT(iClientMessage->GetIntL(0));
129 case ESchDbgResetHeap:
132 case ESchFaultServer:
134 // make sure we complete the message first before Killing this server
135 iClientMessage->CompleteRequestL(KErrNone);
140 case ERegisterClient:
143 case ECreateTimeSchedule:
144 CreateTimeScheduleL();
146 case ECreateConditionSchedule:
147 CreateConditionScheduleL();
155 case EDeleteSchedule:
157 CSchedule* schedule = iTaskScheduler->FindL(iClientMessage->GetIntL(0));
158 CheckPersistsInBackupL(*schedule);
159 //check that user has permission to delete this schedule.
160 schedule->CheckAccessAllowedL(iClientMessage->Message());
161 iTaskScheduler->RemoveScheduleL(iClientMessage->GetIntL(0));
164 case EDisableSchedule:
166 CSchedule* schedule = iTaskScheduler->FindL(iClientMessage->GetIntL(0));
167 CheckPersistsInBackupL(*schedule);
168 //check that user has permission to disable this schedule.
169 schedule->CheckAccessAllowedL(iClientMessage->Message());
170 iTaskScheduler->DisableScheduleL(iClientMessage->GetIntL(0));
173 case EEnableSchedule:
175 CSchedule* schedule = iTaskScheduler->FindL(iClientMessage->GetIntL(0));
176 CheckPersistsInBackupL(*schedule);
177 //check that user has permission to enable this schedule.
178 schedule->CheckAccessAllowedL(iClientMessage->Message());
179 iTaskScheduler->EnableScheduleL(iClientMessage->GetIntL(0));
182 case EEditTimeSchedule:
185 case EEditConditionSchedule:
186 EditConditionScheduleL();
188 case EGetScheduleRefs:
191 case ECountSchedules:
194 case EGetScheduleInfo:
197 case EGetTimeScheduleData:
198 GetTimeScheduleDataL();
200 case EGetConditionScheduleData:
201 GetConditionScheduleDataL();
215 case EGetSchedulerItemRefAndNextDueTime:
216 GetScheduleItemRefAndDueTimeL();
218 case EGetTaskDataSize:
221 case EGetScheduleType:
225 User::Leave(EPanicIllegalFunction);
233 void CSchSession::RegisterClientL()
237 iClientMessage->ReadL(0,writeBuf);
239 // should return existing client if there is one
240 CClientProxy* client = iTaskScheduler->AddClientL(writeBuf, iClientMessage->GetIntL(1));
245 if (!iClient->Users())
247 LOGSTRING2("CSchSession::RegisterClientL - removing existing client %S", &iClient->ExecutorFileName());
255 void CSchSession::CreateTimeScheduleL()
258 TScheduleSettings2 settings;
259 TPScheduleSettings pS(settings);
260 iClientMessage->ReadL(0, pS);
262 //WriteDeviceData needed to create persistent schedules
263 if(settings.iPersists)
265 // backup or restore in progress, so don't allow functions that might write to store
266 if (iTaskScheduler->BUROperationInProgress() != EBUROperationNoActivity)
268 User::Leave(KErrServerBusy);
274 //Verify that the length of the condition list passed in is as expected
275 if(iClientMessage->GetDesLengthL(1) !=
276 (settings.iEntryCount * sizeof(TScheduleEntryInfo2)))
278 User::Leave(KErrBadDescriptor);
282 CArrayFixFlat<TScheduleEntryInfo2>* entries
283 = new(ELeave) CArrayFixFlat<TScheduleEntryInfo2>(settings.iEntryCount);
284 CleanupStack::PushL(entries);
285 entries->ResizeL(settings.iEntryCount);
286 TPtr8 entriesPtr(REINTERPRET_CAST(TUint8*,&(entries->At(0))), settings.iEntryCount * sizeof(TScheduleEntryInfo2));
287 iClientMessage->ReadL(1, entriesPtr);
290 const TInt handle = iTaskScheduler->GenerateId();
291 if (handle == KErrOverflow)
292 User::Leave(KErrOverflow);
296 iClientMessage->WriteL(2,id);
299 TSecurityInfo securityInfo(iClientMessage->Message());
301 // Create schedule and add to scheduler
302 CSchedule* newschedule = CSchedule::NewLC(handle,
307 iTaskScheduler->AddScheduleL(*newschedule);
308 CleanupStack::Pop(newschedule);
309 CleanupStack::PopAndDestroy(entries);
312 void CSchSession::CreateConditionScheduleL()
315 TScheduleSettings2 settings;
316 TPScheduleSettings pS(settings);
317 iClientMessage->ReadL(0, pS);
319 //WriteDeviceData needed to create persistent schedules
320 if(settings.iPersists)
322 // backup or restore in progress, so don't allow functions that might write to store
323 if (iTaskScheduler->BUROperationInProgress() != EBUROperationNoActivity)
325 User::Leave(KErrServerBusy);
331 //Verify that the length of the condition list passed in is as expected
332 if(iClientMessage->GetDesLengthL(1) !=
333 (settings.iEntryCount * sizeof(TTaskSchedulerCondition)))
335 User::Leave(KErrBadDescriptor);
339 CArrayFixFlat<TTaskSchedulerCondition>* entries
340 = new(ELeave) CArrayFixFlat<TTaskSchedulerCondition>(settings.iEntryCount);
341 CleanupStack::PushL(entries);
342 entries->ResizeL(settings.iEntryCount);
343 TPtr8 entriesPtr(REINTERPRET_CAST(TUint8*,&(entries->At(0))), settings.iEntryCount * sizeof(TTaskSchedulerCondition));
344 iClientMessage->ReadL(1, entriesPtr);
347 TTsTime defaultRunTime;
348 TPckg<TTsTime> pTime(defaultRunTime);
349 iClientMessage->ReadL(2, pTime);
352 const TInt handle = iTaskScheduler->GenerateId();
353 if (handle == KErrOverflow)
354 User::Leave(KErrOverflow);
358 iClientMessage->WriteL(3,id);
361 TSecurityInfo securityInfo(iClientMessage->Message());
363 // Create schedule and add to scheduler
364 CSchedule* newschedule
365 = CSchedule::NewLC(handle,
371 iTaskScheduler->AddScheduleL(*newschedule);
372 CleanupStack::Pop(newschedule);
373 CleanupStack::PopAndDestroy(entries);
376 void CSchSession::EditTimeScheduleL()
378 CSchedule* schedule = iTaskScheduler->FindL(iClientMessage->GetIntL(1));
380 CheckPersistsInBackupL(*schedule);
381 //check that user has permission to edit this schedule.
382 schedule->CheckAccessAllowedL(iClientMessage->Message());
384 //check that this is a time schedule!
385 if(schedule->Type() != ETimeSchedule)
386 User::Leave(KErrArgument);
389 const TInt count = iClientMessage->GetIntL(0);
391 //Verify that the length of the condition list passed in is as expected
392 if(iClientMessage->GetDesLengthL(2) != (count * sizeof(TScheduleEntryInfo2)))
394 User::Leave(KErrBadDescriptor);
397 // Get new entry list
398 CArrayFixFlat<TScheduleEntryInfo2>* entries
399 = new(ELeave) CArrayFixFlat<TScheduleEntryInfo2> (KSchedulerArrayGranularity);
400 CleanupStack::PushL(entries);
401 entries->ResizeL(count);
402 TPtr8 entriesPtr(REINTERPRET_CAST(TUint8*, &(entries->At(0))), count*sizeof(TScheduleEntryInfo2));
404 iClientMessage->ReadL(2, entriesPtr);
406 // Give it to scheduler along with schedule id
407 iTaskScheduler->EditScheduleL(iClientMessage->GetIntL(1), *entries);
408 CleanupStack::PopAndDestroy(entries);
411 void CSchSession::EditConditionScheduleL()
413 CSchedule* schedule = iTaskScheduler->FindL(iClientMessage->GetIntL(1));
415 CheckPersistsInBackupL(*schedule);
416 //check that user has permission to edit this schedule.
417 schedule->CheckAccessAllowedL(iClientMessage->Message());
419 //check that this is a condition schedule!
420 if(schedule->Type() != EConditionSchedule)
421 User::Leave(KErrArgument);
424 const TInt count = iClientMessage->GetIntL(0);
426 //Verify that the length of the condition list passed in is as expected
427 if(iClientMessage->GetDesLengthL(2) != (count * sizeof(TTaskSchedulerCondition)))
429 User::Leave(KErrBadDescriptor);
432 // Get new entry list
433 CArrayFixFlat<TTaskSchedulerCondition>* entries
434 = new(ELeave) CArrayFixFlat<TTaskSchedulerCondition> (KSchedulerArrayGranularity);
435 CleanupStack::PushL(entries);
436 entries->ResizeL(count);
437 TPtr8 entriesPtr(REINTERPRET_CAST(TUint8*, &(entries->At(0))), count*sizeof(TTaskSchedulerCondition));
438 iClientMessage->ReadL(2, entriesPtr);
441 TTsTime defaultRunTime;
442 TPckg<TTsTime> pTime(defaultRunTime);
443 iClientMessage->ReadL(3, pTime);
445 // Give it to scheduler along with schedule id
446 iTaskScheduler->EditScheduleL(iClientMessage->GetIntL(1), *entries, defaultRunTime);
447 CleanupStack::PopAndDestroy(entries);
450 void CSchSession::ScheduleTaskL()
452 // If client is registered, it is allowed to schedule tasks
456 TPTaskInfo pI(taskInfo);
457 iClientMessage->ReadL(0, pI);
459 CSchedule* schedule = iTaskScheduler->FindL(iClientMessage->GetIntL(1));
461 CheckPersistsInBackupL(*schedule);
463 //check that user has permission to schedule a task using this schedule.
464 schedule->CheckAccessAllowedL(iClientMessage->Message());
466 taskInfo.iTaskId = schedule->GenerateTaskId();
468 if (taskInfo.iTaskId == KErrOverflow)
470 User::Leave(KErrOverflow);
472 // panic client if this is a condition schedule and client is asking for
473 // repeats. This doesnt make sense.
474 if (schedule->Type() == EConditionSchedule && taskInfo.iRepeat != 0)
475 User::Leave(KErrArgument);
477 // Create a new scheduled task with associated task data
478 TInt len = iClientMessage->GetDesLengthL(3);
479 HBufC* taskdata = HBufC::NewLC(len);
481 TPtr pData(taskdata->Des());
482 iClientMessage->ReadL(3, pData);
484 CScheduledTask* newTask = new(ELeave) CScheduledTask(taskInfo,
487 schedule->SecurityInfo());
488 CleanupStack::Pop(taskdata); //taskdata now owned by newTask
489 CleanupStack::PushL(newTask);
490 // Have to store the associated task, so that in the case where the
491 // tasks need to be restored from a backup, we can ensure that the
492 // task is associated with the correct schedule.
493 newTask->SetScheduleId(schedule->Id());
495 //If the schedule that the task is associated with is persistent then set the flag
496 if(schedule->Persists())
498 newTask->SetPersists();
500 LOGSTRING("CSchSession::ScheduleTaskL - writing back task id to client");
501 TPInt id(taskInfo.iTaskId);
502 iClientMessage->WriteL(2,id);
504 TScheduledTask* task = new(ELeave) TScheduledTask(*newTask,*iClient);
506 // Now that task has been created sucessfully, we can add newTask to Client
507 iClient->AddTask(*newTask); // task info is owned by client: schedule just keeps a reference
508 CleanupStack::Pop(newTask);
510 schedule->AddTask(*task); //add new task - its now owned by schedule
512 LOGSTRING("CSchSession::ScheduleTaskL - scheduling task with task scheduler");
513 // If this leaves we need to still remove task from client and schedule.
514 // No easy way to do this via CleanupStack
515 TRAPD(err, iTaskScheduler->ScheduleTaskL(*schedule, *iClient));
518 schedule->RemoveTask(task);
519 iClient->RemoveTask(newTask);
524 //Client hasnt been registered so it isn't allowed to schedule task, panic client
526 iClientMessage->PanicClient(KSchedulerPanic,EPanicNotRegistered);
530 void CSchSession::DeleteTaskL()
532 const TInt taskId = iClientMessage->GetIntL(0);
534 const TInt scheduleId = (taskId/KScheduleIdDifferential)*KScheduleIdDifferential;
536 //check that user has permission to delete a task using this schedule.
537 CSchedule* schedule = iTaskScheduler->FindL(scheduleId);
538 CheckPersistsInBackupL(*schedule);
539 schedule->CheckAccessAllowedL(iClientMessage->Message());
541 iTaskScheduler->DeleteTaskL(scheduleId, taskId);
544 //retrieval functions
545 void CSchSession::CountSchedulesL()
547 TScheduleFilter filter = STATIC_CAST(TScheduleFilter, iClientMessage->GetIntL(1));
548 //GetScheduleRefs filters on clients schedule permssion as well.
549 TInt count = iTaskScheduler->GetScheduleRefsL(NULL,filter, iClientMessage->Message());
551 iClientMessage->WriteL(0,pCount);
554 void CSchSession::GetScheduleRefsL()
556 //client calls CountSchedules() first to get expected count. still
557 //need to check it's valid though...
559 const TInt expectedCount = iClientMessage->GetIntL(0);
560 TScheduleFilter filter = STATIC_CAST(TScheduleFilter, iClientMessage->GetIntL(1));
562 CArrayFixFlat<TSchedulerItemRef>* refArray
563 = new(ELeave) CArrayFixFlat<TSchedulerItemRef>(KSchedulerArrayGranularity);
564 CleanupStack::PushL(refArray);
566 //GetScheduleRefs filters on clients schedule permssion as well.
567 TInt count = iTaskScheduler->GetScheduleRefsL(refArray, filter, iClientMessage->Message());
568 if ((expectedCount<count) || (count == 0))
569 User::Leave(KErrArgument);
571 TPtrC8 pS(REINTERPRET_CAST(TUint8*, &refArray->At(0)),sizeof(TSchedulerItemRef)*expectedCount);
572 iClientMessage->WriteL(2, pS);
573 CleanupStack::PopAndDestroy();//info array
576 void CSchSession::GetTimeScheduleDataL()
578 //client input:handle at info at aMessage.Int0()
579 //info at aMessage.Ptr1()
580 //info contains: exepcted entry count
581 //scheduler output: entries at aM.Ptr2()
582 TInt handle = iClientMessage->GetIntL(0);
585 TPScheduleInfo pS(info);
586 iClientMessage->ReadL(1, pS);
588 CSchedule* schedule = iTaskScheduler->FindL(handle);
590 //check that user has permission to get this schedules info.
591 schedule->CheckAccessAllowedL(iClientMessage->Message());
593 if (schedule->Type() != ETimeSchedule)
594 User::Leave(KErrArgument); //calling wrong API
596 CArrayFixFlat<TScheduleEntryInfo2>* entries
597 = new(ELeave) CArrayFixFlat<TScheduleEntryInfo2> (KSchedulerArrayGranularity);
598 CleanupStack::PushL(entries);
599 schedule->EntriesL(*entries);
600 if ((entries->Count())!=info.iEntryCount)
601 User::Leave(KErrArgument);
603 TPtrC8 pE(REINTERPRET_CAST(TUint8*, &entries->At(0)),sizeof(TScheduleEntryInfo2)*info.iEntryCount);
604 iClientMessage->WriteL(2, pE);
606 CleanupStack::PopAndDestroy(entries);//entry array
609 void CSchSession::GetConditionScheduleDataL()
611 //client input:handle at info at aMessage.Int0()
612 //info at aMessage.Ptr1()
613 //info contains: exepcted entry count
614 //scheduler output: entries at aM.Ptr2()
615 TInt handle = iClientMessage->GetIntL(0);
618 TPScheduleInfo pS(info);
619 iClientMessage->ReadL(1, pS);
621 CSchedule* schedule = iTaskScheduler->FindL(handle);
623 //check that user has permission to get this schedules info.
624 schedule->CheckAccessAllowedL(iClientMessage->Message());
626 if (schedule->Type() != EConditionSchedule)
627 User::Leave(KErrArgument); //calling wrong API
629 CArrayFixFlat<TTaskSchedulerCondition>* conditions
630 = new(ELeave) CArrayFixFlat<TTaskSchedulerCondition> (KSchedulerArrayGranularity);
631 CleanupStack::PushL(conditions);
632 schedule->ConditionsL(*conditions);
633 if ((conditions->Count())!=info.iEntryCount)
634 User::Leave(KErrArgument);
636 TPtrC8 pE(REINTERPRET_CAST(TUint8*, &conditions->At(0)),sizeof(TTaskSchedulerCondition)*info.iEntryCount);
637 iClientMessage->WriteL(2, pE);
640 TTsTime defaultTime(schedule->DefaultRunTimeL());
641 TPBTime pDefaultTime(defaultTime);
642 iClientMessage->WriteL(3, pDefaultTime);
644 CleanupStack::PopAndDestroy(conditions);//condition array
647 void CSchSession::GetScheduleTypeL()
650 TInt handle = iClientMessage->GetIntL(0);
651 CSchedule* schedule = iTaskScheduler->FindL(handle);
653 //check that user has permission to get this schedules info.
654 schedule->CheckAccessAllowedL(iClientMessage->Message());
656 type = schedule->Type();
658 iClientMessage->WriteL(1,pType);
661 void CSchSession::GetTaskDataL()
662 {//client input:handle at info at aMessage.Int0()
663 //info at aMessage.Ptr1()
664 //info contains: exepcted entry count, expected task count
665 //scheduler output: tasks at aM.Ptr2()
666 TInt handle = iClientMessage->GetIntL(0);
669 TPScheduleInfo pS(info);
670 iClientMessage->ReadL(1, pS);
672 CSchedule* schedule = iTaskScheduler->FindL(handle);
674 //check that user has permission to get this task info (based on owning
676 schedule->CheckAccessAllowedL(iClientMessage->Message());
678 CArrayFixFlat<TTaskInfo>* tasks
679 = new(ELeave) CArrayFixFlat<TTaskInfo> (KSchedulerArrayGranularity);
680 CleanupStack::PushL(tasks);
681 schedule->TasksL(*tasks);
682 if ((tasks->Count())!=info.iTaskCount)
683 User::Leave(KErrArgument);
684 //write tasks if there are any
685 if (info.iTaskCount>0)
687 TPtrC8 pT(REINTERPRET_CAST(TUint8*, &tasks->At(0)),sizeof(TTaskInfo)*info.iTaskCount);
688 iClientMessage->WriteL(2, pT);
690 CleanupStack::PopAndDestroy(tasks);//task array
693 void CSchSession::GetScheduleInfoL()
695 CSchedule* schedule = iTaskScheduler->FindL(iClientMessage->GetIntL(0));
697 //check that user has permission to get this schedules info.
698 schedule->CheckAccessAllowedL(iClientMessage->Message());
701 if (schedule->Type() == ETimeSchedule)
702 schedule->GetInfo(info, EFalse);
704 schedule->GetInfo(info, ETrue);
706 TPBScheduleInfo pInfo(info);
707 iClientMessage->WriteL(1, pInfo);
708 TTsTime dueTime(schedule->DueTime());
709 TPBTime pDueTime(dueTime);
710 iClientMessage->WriteL(2, pDueTime);
713 void CSchSession::GetTaskRefsL()
716 //or just the ones I scheduled,
717 //or just the pending ones,
718 //or just the pending ones I scheduled
720 TInt expectedCount = iClientMessage->GetIntL(0);
721 TScheduleFilter sFilter = STATIC_CAST(TScheduleFilter, iClientMessage->GetIntL(1));
722 TTaskFilter tFilter = STATIC_CAST(TTaskFilter, iClientMessage->GetIntL(2));
723 CArrayFixFlat<TSchedulerItemRef>* refs
724 = new (ELeave) CArrayFixFlat<TSchedulerItemRef> (KSchedulerArrayGranularity);
725 CleanupStack::PushL(refs);
727 //GetTaskRefs filters on clients schedule permssion as well.
728 TInt actualCount = iTaskScheduler->GetTaskRefsL(refs, sFilter, tFilter,iClient, iClientMessage->Message());
730 // Must find enough tasks.
731 if((actualCount != expectedCount) || (refs->Count() == 0))
732 User::Leave(KErrArgument);
734 // Write array back to client
735 TPtrC8 pR(REINTERPRET_CAST(TUint8*,&refs->At(0)),sizeof(TSchedulerItemRef)*expectedCount);
736 iClientMessage->WriteL(3, pR);
737 CleanupStack::PopAndDestroy();//refs
740 void CSchSession::CountTasksL()
742 //count either all of 'em or just mine
744 TScheduleFilter sFilter = STATIC_CAST(TScheduleFilter, iClientMessage->GetIntL(1));
745 TTaskFilter tFilter = STATIC_CAST(TTaskFilter, iClientMessage->GetIntL(2));
747 //GetTaskRefs filters on clients schedule permssion as well.
748 TInt count = iTaskScheduler->GetTaskRefsL(NULL, sFilter, tFilter,iClient, iClientMessage->Message());
751 iClientMessage->WriteL(0,pCount);
754 void CSchSession::GetTaskInfoL()
757 TInt taskId = iClientMessage->GetIntL(0);
758 TInt scheduleId = (taskId/KScheduleIdDifferential)*KScheduleIdDifferential;
759 CSchedule* schedule = iTaskScheduler->FindL(scheduleId);
761 //check that user has permission to get this task info (based on owning
763 schedule->CheckAccessAllowedL(iClientMessage->Message());
765 TScheduledTask* task = schedule->Task(taskId);
767 User::Leave(KErrNotFound);
769 TPBTaskInfo pI(task->Info());
771 iClientMessage->WriteL(1, pI);//write info
773 // If there isn't enough room to hold the task data in the client buffer then
774 // indicate by returning KErrArgument
775 TInt clientBufferSize = iClientMessage->GetIntL(2);
776 if (clientBufferSize < task->Data().Length())
777 User::Leave(KErrArgument);
778 iClientMessage->WriteL(3, task->Data());
781 void CSchSession::GetScheduleItemRefAndDueTimeL()
783 // Get CSchedule object
784 TInt taskId = iClientMessage->GetIntL(0);
785 TInt scheduleId = (taskId/KScheduleIdDifferential)*KScheduleIdDifferential;
786 CSchedule* schedule = iTaskScheduler->FindL(scheduleId);
788 //check that user has permission to get this schedules info.
789 schedule->CheckAccessAllowedL(iClientMessage->Message());
791 TSchedulerItemRef ref;
792 ref.iHandle = schedule->Id();
793 ref.iName = schedule->Name();
795 TPBSchedulerItemRef pRef(ref);
796 iClientMessage->WriteL(1, pRef);
798 TTsTime dueTime(schedule->DueTime());
799 TPBTime pDueTime(dueTime);
800 iClientMessage->WriteL(2, pDueTime);
803 void CSchSession::GetTaskDataSizeL()
805 TInt taskId = iClientMessage->GetIntL(0);
806 TInt scheduleId = (taskId/KScheduleIdDifferential)*KScheduleIdDifferential;
807 CSchedule* schedule = iTaskScheduler->FindL(scheduleId);
809 //check that user has permission to get this task info (based on owning
811 schedule->CheckAccessAllowedL(iClientMessage->Message());
813 TScheduledTask* task = schedule->Task(taskId);
815 User::Leave(KErrNotFound);
817 TInt size = task->Data().Length();
819 iClientMessage->WriteL(1,pSize);
822 void CSchSession::CheckCapabilityL()
824 if( !( iClientMessage->Message().HasCapability(ECapabilityWriteDeviceData)
825 || (PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)==0 ))) // Enforcement off
826 User::Leave(KErrPermissionDenied);
829 void CSchSession::CheckPersistsInBackupL(const CSchedule& aSchedule)
831 // backup or restore in progress, so don't allow functions that might write to store
832 if ((iTaskScheduler->BUROperationInProgress() != EBUROperationNoActivity) && (aSchedule.Persists()))
834 User::Leave(KErrServerBusy);