sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "Thelpers.h" sl@0: sl@0: // System includes sl@0: #include sl@0: #include sl@0: sl@0: _LIT(KPauseMessage, "=== Pausing for %d seconds ===\n"); sl@0: sl@0: // sl@0: // Helper class for Scheduler Server test code sl@0: // sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsTimeTheSame(const TTime& aTime1, const TTime& aTime2) sl@0: { sl@0: // Just compares the time, not the date sl@0: TDateTime time1 = aTime1.DateTime(); sl@0: TDateTime time2 = aTime2.DateTime(); sl@0: return ((time1.Hour() == time2.Hour()) && (time1.Minute() == time2.Minute()) && (time1.Second() == time2.Second())); sl@0: } sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsDateTheSame(const TTime& aTime1, const TTime& aTime2) sl@0: { sl@0: // Just compares the date not the time sl@0: TDateTime time1 = aTime1.DateTime(); sl@0: TDateTime time2 = aTime2.DateTime(); sl@0: return ((time1.Day() == time2.Day()) && (time1.Month() == time2.Month()) && (time1.Year() == time2.Year())); sl@0: } sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsTaskInfoTheSame(const TTaskInfo& aTaskInfo1, const TTaskInfo& aTaskInfo2) sl@0: { sl@0: if ( aTaskInfo1.iRepeat == aTaskInfo2.iRepeat && aTaskInfo1.iTaskId == aTaskInfo2.iTaskId sl@0: && aTaskInfo1.iName == aTaskInfo2.iName && aTaskInfo1.iPriority == aTaskInfo2.iPriority) sl@0: return ETrue; sl@0: return EFalse; sl@0: } sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsItemRefTheSame(const TSchedulerItemRef& aItemRef1, const TSchedulerItemRef& aItemRef2) sl@0: { sl@0: if (aItemRef1.iHandle == aItemRef2.iHandle && aItemRef1.iName == aItemRef2.iName) sl@0: return ETrue; sl@0: return EFalse; sl@0: } sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsScheduleStateTheSame(const TScheduleState& aScheduleState1, const TScheduleState& aScheduleState2) sl@0: { sl@0: if ( aScheduleState1.iDueTime == aScheduleState2.iDueTime && aScheduleState1.iPersists == aScheduleState2.iPersists sl@0: && aScheduleState1.iName == aScheduleState2.iName && aScheduleState1.iEnabled == aScheduleState2.iEnabled) sl@0: return ETrue; sl@0: return EFalse; sl@0: } sl@0: sl@0: EXPORT_C TScheduleEntryInfo SchSvrHelpers::RandomScheduleEntryInfo(TInt64& aSeed) sl@0: { sl@0: TScheduleEntryInfo entryInfo; sl@0: entryInfo.iIntervalType = STATIC_CAST(TIntervalType, Rand(EHourly, EYearly, aSeed)); sl@0: entryInfo.iStartTime = TimeBasedOnOffset(Rand(0, 59, aSeed), Rand(0, 10, aSeed), Rand(0, 1, aSeed)); sl@0: entryInfo.iInterval = Rand(1, 100, aSeed); sl@0: entryInfo.iValidityPeriod = Rand(1, 100, aSeed); sl@0: return entryInfo; sl@0: } sl@0: sl@0: EXPORT_C TScheduleEntryInfo SchSvrHelpers::ScheduleEntryInfo(TIntervalType aType, const TTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod) sl@0: { sl@0: TScheduleEntryInfo info; sl@0: info.iIntervalType = aType; sl@0: info.iStartTime = aStartTime; sl@0: info.iInterval = aInterval; sl@0: info.iValidityPeriod = aValidPeriod; sl@0: return info; sl@0: } sl@0: sl@0: EXPORT_C TTaskInfo SchSvrHelpers::TaskInfo(const TDesC& aName, TInt aPriority, TInt aRepeat) sl@0: { sl@0: TName name(aName); sl@0: return TTaskInfo(0, name, aPriority, aRepeat); // zero the id for now (returned by server) sl@0: } sl@0: sl@0: // Generate a random number based upon a seed and a range sl@0: EXPORT_C TInt SchSvrHelpers::Rand(const TInt aLow, const TInt aHigh, TInt64& aSeed) sl@0: { sl@0: TReal initialRand = (Math::FRand(aSeed) * (aHigh - aLow)); sl@0: TInt32 rand; sl@0: sl@0: // Round to 0 decimal places, ie. the nearest whole numer sl@0: Math::Round(initialRand, initialRand, 0); sl@0: Math::Int(rand, initialRand); sl@0: sl@0: //aSeed = seed; sl@0: return (aLow + rand); sl@0: } sl@0: sl@0: // Pause execution for the specified number of seconds sl@0: EXPORT_C void SchSvrHelpers::Pause(RTest& aTest, TInt aPauseAmount) sl@0: { sl@0: aTest.Printf(KPauseMessage, aPauseAmount); sl@0: User::After(KOneSecond * aPauseAmount); // default is 2 seconds sl@0: } sl@0: sl@0: // To be used by Hometime based schedules sl@0: EXPORT_C TDateTime SchSvrHelpers::TimeBasedOnOffset(TInt aSeconds, TInt aMinutes, TInt aHours, TInt aDays, TInt aMonths, TInt aYears) sl@0: { sl@0: TTime now; sl@0: now.HomeTime(); sl@0: now += TTimeIntervalSeconds(aSeconds); sl@0: now += TTimeIntervalMinutes(aMinutes); sl@0: now += TTimeIntervalHours(aHours); sl@0: now += TTimeIntervalDays(aDays); sl@0: now += TTimeIntervalMonths(aMonths); sl@0: now += TTimeIntervalYears(aYears); sl@0: return now.DateTime(); sl@0: } sl@0: sl@0: // To be used by UTC time based schedules sl@0: EXPORT_C TDateTime SchSvrHelpers::UtcTimeBasedOnOffset(TInt aSeconds, TInt aMinutes, TInt aHours, TInt aDays, TInt aMonths, TInt aYears) sl@0: { sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: now += TTimeIntervalSeconds(aSeconds); sl@0: now += TTimeIntervalMinutes(aMinutes); sl@0: now += TTimeIntervalHours(aHours); sl@0: now += TTimeIntervalDays(aDays); sl@0: now += TTimeIntervalMonths(aMonths); sl@0: now += TTimeIntervalYears(aYears); sl@0: return now.DateTime(); sl@0: } sl@0: sl@0: // Check task file left sl@0: // It creates a separate process to do this as file to access in in private sl@0: // data cage which requires all files capability sl@0: EXPORT_C TInt SchSvrHelpers::CheckTaskFilesL() sl@0: { sl@0: _LIT(KTaskFileChecker, "TTaskFileChecker"); sl@0: TRequestStatus stat; sl@0: RProcess p; sl@0: User::LeaveIfError(p.Create(KTaskFileChecker, KNullDesC)); sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: TInt exitReason = p.ExitReason(); sl@0: p.Close(); sl@0: sl@0: // return exit reasons as checking result sl@0: return exitReason; sl@0: } sl@0: sl@0: sl@0: // Create task files for testing sl@0: // It creates a separate process to do this as file to access in in private sl@0: // data cage which requires all files capability sl@0: EXPORT_C TInt SchSvrHelpers::CreateTaskFilesL() sl@0: { sl@0: _LIT(KTaskFileCreator, "TTaskFileCreator"); sl@0: TRequestStatus stat; sl@0: RProcess p; sl@0: User::LeaveIfError(p.Create(KTaskFileCreator, KNullDesC)); sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: TInt exitReason = p.ExitReason(); sl@0: p.Close(); sl@0: sl@0: // return exit reasons as checking result sl@0: return exitReason; sl@0: } sl@0: sl@0: // Start Task Scheduler sl@0: // It creates a separate process to do this as need to set appropriate SID sl@0: // to enable task scheduler to be started sl@0: EXPORT_C TInt SchSvrHelpers::LaunchTaskSchedulerL() sl@0: { sl@0: _LIT(KTaskSchedulerLauncher, "TTaskSchedulerLauncher"); sl@0: TRequestStatus stat; sl@0: RProcess p; sl@0: User::LeaveIfError(p.Create(KTaskSchedulerLauncher, KNullDesC)); sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: TInt exitReason = p.ExitReason(); sl@0: p.Close(); sl@0: sl@0: // return exit reasons as checking result sl@0: return exitReason; sl@0: } sl@0: sl@0: sl@0: // sl@0: // PREQ234 support // sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsTimeTheSame(const TTsTime& aTime1, const TTsTime& aTime2) sl@0: { sl@0: // Just compares the time, not the date sl@0: TBool ret = EFalse; sl@0: sl@0: if (aTime1.IsUtc() && aTime2.IsUtc()) sl@0: { sl@0: TDateTime time1 = aTime1.GetUtcTime().DateTime(); sl@0: TDateTime time2 = aTime2.GetUtcTime().DateTime(); sl@0: ret = ((time1.Hour() == time2.Hour()) && (time1.Minute() == time2.Minute()) && (time1.Second() == time2.Second())); sl@0: } sl@0: if (!aTime1.IsUtc() && !aTime2.IsUtc()) sl@0: { sl@0: TDateTime time1 = aTime1.GetLocalTime().DateTime(); sl@0: TDateTime time2 = aTime2.GetLocalTime().DateTime(); sl@0: ret = ((time1.Hour() == time2.Hour()) && (time1.Minute() == time2.Minute()) && (time1.Second() == time2.Second())); sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsTimeTheSameNoSeconds(const TTsTime& aTime1, const TTsTime& aTime2) sl@0: { sl@0: // Just compares the time up to hours and minutes sl@0: TBool ret = EFalse; sl@0: sl@0: if (aTime1.IsUtc() && aTime2.IsUtc()) sl@0: { sl@0: TDateTime time1 = aTime1.GetUtcTime().DateTime(); sl@0: TDateTime time2 = aTime2.GetUtcTime().DateTime(); sl@0: ret = ((time1.Hour() == time2.Hour()) && (time1.Minute() == time2.Minute())); sl@0: } sl@0: if (!aTime1.IsUtc() && !aTime2.IsUtc()) sl@0: { sl@0: TDateTime time1 = aTime1.GetLocalTime().DateTime(); sl@0: TDateTime time2 = aTime2.GetLocalTime().DateTime(); sl@0: ret = ((time1.Hour() == time2.Hour()) && (time1.Minute() == time2.Minute())); sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsDateTheSame(const TTsTime& aTime1, const TTsTime& aTime2) sl@0: { sl@0: // Just compares the date not the time sl@0: TBool ret = EFalse; sl@0: sl@0: if (aTime1.IsUtc() && aTime2.IsUtc()) sl@0: { sl@0: TDateTime time1 = aTime1.GetUtcTime().DateTime(); sl@0: TDateTime time2 = aTime2.GetUtcTime().DateTime(); sl@0: ret = ((time1.Day() == time2.Day()) && (time1.Month() == time2.Month()) && (time1.Year() == time2.Year())); sl@0: } sl@0: if (!aTime1.IsUtc() && !aTime2.IsUtc()) sl@0: { sl@0: TDateTime time1 = aTime1.GetLocalTime().DateTime(); sl@0: TDateTime time2 = aTime2.GetLocalTime().DateTime(); sl@0: ret = ((time1.Day() == time2.Day()) && (time1.Month() == time2.Month()) && (time1.Year() == time2.Year())); sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: EXPORT_C TBool SchSvrHelpers::IsScheduleStateTheSame(const TScheduleState2& aScheduleState1, const TScheduleState2& aScheduleState2) sl@0: { sl@0: if (aScheduleState1.DueTime().IsUtc() && aScheduleState2.DueTime().IsUtc()) sl@0: { sl@0: TTime dueTime1 = aScheduleState1.DueTime().GetUtcTime(); sl@0: TTime dueTime2 = aScheduleState2.DueTime().GetUtcTime(); sl@0: sl@0: if (aScheduleState1.Persists() == aScheduleState2.Persists() && aScheduleState1.Name() == aScheduleState2.Name() sl@0: && aScheduleState1.Enabled() == aScheduleState2.Enabled() && dueTime1 == dueTime2) sl@0: return ETrue; sl@0: } sl@0: sl@0: if (!aScheduleState1.DueTime().IsUtc() && !aScheduleState2.DueTime().IsUtc()) sl@0: { sl@0: TTime dueTime1 = aScheduleState1.DueTime().GetLocalTime(); sl@0: TTime dueTime2 = aScheduleState2.DueTime().GetLocalTime(); sl@0: sl@0: if (aScheduleState1.Persists() == aScheduleState2.Persists() && aScheduleState1.Name() == aScheduleState2.Name() sl@0: && aScheduleState1.Enabled() == aScheduleState2.Enabled() && dueTime1 == dueTime2) sl@0: return ETrue; sl@0: } sl@0: sl@0: return EFalse; sl@0: } sl@0: sl@0: EXPORT_C TScheduleEntryInfo2 SchSvrHelpers::RandomScheduleEntryInfoHometime(TInt64& aSeed) sl@0: { sl@0: TScheduleEntryInfo2 entryInfo; sl@0: entryInfo.SetIntervalType(STATIC_CAST(TIntervalType, Rand(EHourly, EYearly, aSeed))); sl@0: entryInfo.SetStartTime(TTsTime (TTime(TimeBasedOnOffset(Rand(0, 59, aSeed), Rand(0, 10, aSeed), Rand(0, 1, aSeed))), ETrue)); sl@0: entryInfo.SetInterval(Rand(1, 100, aSeed)); sl@0: entryInfo.SetValidityPeriod(Rand(1, 100, aSeed)); sl@0: return entryInfo; sl@0: } sl@0: sl@0: EXPORT_C TScheduleEntryInfo2 SchSvrHelpers::RandomScheduleEntryInfoUtc(TInt64& aSeed) sl@0: { sl@0: TScheduleEntryInfo2 entryInfo; sl@0: entryInfo.SetIntervalType(STATIC_CAST(TIntervalType, Rand(EHourly, EYearly, aSeed))); sl@0: entryInfo.SetStartTime(TTsTime(TTime(TimeBasedOnOffset(Rand(0, 59, aSeed), Rand(0, 10, aSeed), Rand(0, 1, aSeed))), ETrue)); sl@0: entryInfo.SetInterval(Rand(1, 100, aSeed)); sl@0: entryInfo.SetValidityPeriod(Rand(1, 100, aSeed)); sl@0: return entryInfo; sl@0: } sl@0: sl@0: EXPORT_C TScheduleEntryInfo2 SchSvrHelpers::ScheduleEntryInfo(TIntervalType aType, const TTsTime& aStartTime, TInt aInterval, TTimeIntervalMinutes aValidPeriod) sl@0: { sl@0: TScheduleEntryInfo2 info (aStartTime, aType, aInterval, aValidPeriod); sl@0: return info; sl@0: } sl@0: sl@0: // Pause execution for the specified number of seconds sl@0: EXPORT_C void SchSvrHelpers::Pause(TInt aPauseAmount) sl@0: { sl@0: //aTest.Printf(KPauseMessage, aPauseAmount); sl@0: User::After(KOneSecond * aPauseAmount); // default is 2 seconds sl@0: } sl@0: sl@0: // PREQ234 support // sl@0: // sl@0: sl@0: EXPORT_C void SchSvrHelpers::DeleteAllSchedulesL(RScheduler& aScheduler) sl@0: { sl@0: // First fetch task references so that we can delete all the tasks. sl@0: CArrayFixFlat* refs = new (ELeave) CArrayFixFlat(3); sl@0: CleanupStack::PushL(refs); sl@0: sl@0: { sl@0: User::LeaveIfError(aScheduler.GetTaskRefsL(*refs, EAllSchedules, EAllTasks)); sl@0: const TInt count = refs->Count(); sl@0: // Delete all tasks sl@0: for(TInt i=0; iAt(i); sl@0: User::LeaveIfError(aScheduler.DeleteTask(ref.iHandle)); sl@0: } sl@0: } sl@0: refs->Reset(); sl@0: { sl@0: User::LeaveIfError(aScheduler.GetScheduleRefsL(*refs, EAllSchedules)); sl@0: // Delete all schedules sl@0: const TInt count = refs->Count(); sl@0: for(TInt i=0; iAt(i); sl@0: User::LeaveIfError(aScheduler.DeleteSchedule(ref.iHandle)); sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(refs); sl@0: } sl@0: sl@0: // Deletes the task scheduler persisted files. sl@0: // It creates a separate process to do this as file to delete in in private sl@0: // data cage which requires all files capability which we don't want to sl@0: // grant to all test exes. sl@0: EXPORT_C void SchSvrHelpers::DeleteScheduleFilesL() sl@0: { sl@0: _LIT(KScheduleDeleter, "TScheduleDeleter"); sl@0: TRequestStatus stat; sl@0: RProcess p; sl@0: User::LeaveIfError(p.Create(KScheduleDeleter, KNullDesC)); sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: TInt exitReason = p.ExitReason(); sl@0: p.Close(); sl@0: User::LeaveIfError(exitReason); sl@0: } sl@0: sl@0: // registers the client exe, leaving if it is not found sl@0: EXPORT_C TInt SchSvrHelpers::RegisterClientL(RScheduler& aScheduler) sl@0: { sl@0: TFileName filename; sl@0: filename = _L("MinimalTaskHandler"); sl@0: sl@0: return aScheduler.Register(filename, 27); sl@0: } sl@0: sl@0: // registers the panicing client exe sl@0: EXPORT_C TInt SchSvrHelpers::RegisterPanicingClient(RScheduler& aScheduler) sl@0: { sl@0: TFileName filename; sl@0: filename = _L("FaultyMinimalTaskHandler"); sl@0: sl@0: return aScheduler.Register(filename, 27); sl@0: } sl@0: sl@0: // registers the a non existent exe sl@0: EXPORT_C TInt SchSvrHelpers::RegisterNonExistentClient(RScheduler& aScheduler) sl@0: { sl@0: TFileName filename; sl@0: filename = _L("NonExistentClient"); sl@0: sl@0: return aScheduler.Register(filename, 27); sl@0: } sl@0: sl@0: // Sets the system time to the given local time sl@0: // It creates a separate process to do this, sl@0: // as this requires WDD capability which we don't want to grant to all test exes. sl@0: EXPORT_C TInt SchSvrHelpers::SetHomeTimeL(const TTime& aLocalTime) sl@0: { sl@0: sl@0: _LIT(KSetHomeTime, "TSetHomeTime"); sl@0: _LIT(KTimeFormat, "%F%Y%M%D:%H%T%S.%*C6"); sl@0: sl@0: RProcess p; sl@0: TRequestStatus stat; sl@0: TBuf<128> bufLocalTime; sl@0: sl@0: aLocalTime.FormatL(bufLocalTime, KTimeFormat); sl@0: sl@0: User::LeaveIfError(p.Create(KSetHomeTime, bufLocalTime)); sl@0: sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: TInt exitReason = p.ExitReason(); sl@0: p.Close(); sl@0: return (exitReason); sl@0: } sl@0: sl@0: sl@0: // Sets the UTC time to a specified time value sl@0: // It creates a separate process to do this, sl@0: // as this requires WDD capability which we don't want to grant to all test exes. sl@0: EXPORT_C TInt SchSvrHelpers::SetUTCTimeL(const TTime& aUTCTime) sl@0: { sl@0: _LIT(KSetUTCTime, "TSetUTCTime"); sl@0: _LIT(KTimeFormat, "%F%Y%M%D:%H%T%S.%*C6"); sl@0: sl@0: RProcess p; sl@0: TRequestStatus stat; sl@0: TBuf<128> bufUTCTime; sl@0: sl@0: aUTCTime.FormatL(bufUTCTime, KTimeFormat); sl@0: sl@0: User::LeaveIfError(p.Create(KSetUTCTime, bufUTCTime)); sl@0: sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: TInt exitReason = p.ExitReason(); sl@0: p.Close(); sl@0: return (exitReason); sl@0: } sl@0: sl@0: //This function is used in the test code to kill SCHSVR or MinimalTaskHandler sl@0: //processes (or some other) when they leftover and may cause OOM conditions. sl@0: // It creates a separate process to do this as killing a process requires sl@0: // PwrMgmt capability which we don't want to grant to all test exes. sl@0: EXPORT_C TInt CleanupHelpers::KillProcess(const TDesC& aProcessName) sl@0: { sl@0: _LIT(KProcessKiller, "TProcessKiller"); sl@0: TRequestStatus stat; sl@0: RProcess p; sl@0: TInt result = p.Create(KProcessKiller, aProcessName); sl@0: sl@0: if(result == KErrNone) sl@0: { sl@0: // Asynchronous logon: completes when process terminates with process exit code sl@0: p.Logon(stat); sl@0: p.Resume(); sl@0: sl@0: User::WaitForRequest(stat); sl@0: result = p.ExitReason(); sl@0: p.Close(); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: //Call this method before "TheTest(error == KErrNone);" statement. sl@0: //Otherwise if the error code is not KErrNone and the check fails, your sl@0: //cleanup code never gets called - probably you will have low memory condition on the sl@0: //test hardware and the rest of SCHSVR unit tests will fail sometimes and it will be very sl@0: //hard to find out what is going on there. sl@0: EXPORT_C void CleanupHelpers::TestCleanupL() sl@0: { sl@0: // 5 second delay to clean up any launched processes sl@0: // left over by the test sl@0: RDebug::Print(KPauseMessage, 5); sl@0: User::After(5 * KOneSecond); sl@0: sl@0: _LIT(KLogServerName, "SCHEXE"); sl@0: sl@0: TInt err = CleanupHelpers::KillProcess(KLogServerName); sl@0: //dont leave if the process was not found, or if it is already dead sl@0: //but do leave if some other error occured sl@0: if((err != KErrNotFound)&&(err != KErrDied)) sl@0: { sl@0: User::LeaveIfError(err); sl@0: } sl@0: } sl@0: sl@0: sl@0: // sl@0: //class STaskSemaphore sl@0: sl@0: _LIT(KSchSemaphoreName, "SCHMinimalTaskHandler"); sl@0: sl@0: EXPORT_C void STaskSemaphore::CreateL() sl@0: { sl@0: //create semaphore and set it to 0 sl@0: User::LeaveIfError(iSemaphore.CreateGlobal(KSchSemaphoreName,0)); sl@0: } sl@0: sl@0: EXPORT_C void STaskSemaphore::WaitL() sl@0: { sl@0: RSemaphore sem; sl@0: User::LeaveIfError(sem.OpenGlobal(KSchSemaphoreName)); sl@0: sem.Wait(); sl@0: sem.Close(); sl@0: } sl@0: sl@0: EXPORT_C TInt STaskSemaphore::WaitL(TInt aTimeout) sl@0: { sl@0: RSemaphore sem; sl@0: User::LeaveIfError(sem.OpenGlobal(KSchSemaphoreName)); sl@0: TInt r = sem.Wait(aTimeout); sl@0: sem.Close(); sl@0: return r; sl@0: } sl@0: sl@0: EXPORT_C void STaskSemaphore::Close() sl@0: { sl@0: iSemaphore.Close(); sl@0: } sl@0: sl@0: sl@0: