os/ossrv/genericservices/taskscheduler/SCHSVR/SCHINFO.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericservices/taskscheduler/SCHSVR/SCHINFO.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,485 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "SCHINFO.H"
    1.20 +#include "SCHEXEC.H"
    1.21 +
    1.22 +/**
    1.23 +Persists flag value, used by TScheduleState2
    1.24 +@internalComponent
    1.25 +*/
    1.26 +const TUint32 KPersists = 0x00000001;
    1.27 +
    1.28 +
    1.29 +/**
    1.30 +IsEnabled flag value, used by TScheduleState2
    1.31 +@internalComponent
    1.32 +*/
    1.33 +const TUint32 KIsEnabled = 0x00000002;
    1.34 +
    1.35 +
    1.36 +EXPORT_C TTaskInfo::TTaskInfo(TInt aTaskId, TName& aName, TInt aPriority, TInt aRepeat)
    1.37 +				:iRepeat(aRepeat), iTaskId(aTaskId), iName(aName), iPriority(aPriority)
    1.38 +/** Constructor taking the specified parameters.
    1.39 +
    1.40 +@param aTaskId The task Id.
    1.41 +@param aName The name of the task.
    1.42 +@param aPriority The task priority.
    1.43 +@param aRepeat How often the task is to be repeated */
    1.44 +	{
    1.45 +	} 
    1.46 +
    1.47 +EXPORT_C TTaskInfo::TTaskInfo()
    1.48 +/** Default constructor. */
    1.49 +	{
    1.50 +	}
    1.51 +
    1.52 +EXPORT_C TTaskInfo& TTaskInfo::operator=(const TTaskInfo& aTaskInfo)
    1.53 +	{
    1.54 +	Mem::Copy(this,&aTaskInfo,sizeof(*this));
    1.55 +	return *this;
    1.56 +	}
    1.57 +
    1.58 +EXPORT_C void TTaskInfo::ExternalizeL(RWriteStream& aWriteStream) const
    1.59 +/** Externalises an object of this class to a write stream.
    1.60 +	
    1.61 +	The presence of this function means that the standard templated operator<<() 
    1.62 +	can be used to externalise objects of this class.
    1.63 +	
    1.64 +	@param aStream Stream to which the object should be externalised. */
    1.65 +	{
    1.66 +	aWriteStream << iName;
    1.67 +	aWriteStream.WriteInt32L(iTaskId);
    1.68 +	aWriteStream.WriteInt32L(iRepeat);
    1.69 +	aWriteStream.WriteInt32L(iPriority);
    1.70 +	}
    1.71 +
    1.72 +EXPORT_C void TTaskInfo::InternalizeL(RReadStream& aReadStream)
    1.73 +	/** Internalises an object of this class from a read stream.
    1.74 +	
    1.75 +	The presence of this function means that the standard templated operator>>() 
    1.76 +	can be used to internalise objects of this class.
    1.77 +	
    1.78 +	Note that the function has assignment semantics. It replaces the old value 
    1.79 +	of the object with a new value read from the read stream.
    1.80 +	
    1.81 +	@param aStream Stream from which the object is to be internalised. */
    1.82 +	{
    1.83 +	aReadStream >> iName;
    1.84 +	iTaskId = aReadStream.ReadInt32L();
    1.85 +	iRepeat = aReadStream.ReadInt32L();
    1.86 +	iPriority = aReadStream.ReadInt32L();
    1.87 +	}
    1.88 +
    1.89 +//
    1.90 +/**
    1.91 +Externalizes the ScheduleEntryInfo
    1.92 +@internalComponent only used by server
    1.93 +*/
    1.94 +void TScheduleEntryInfo::ExternalizeL(RWriteStream& aStream) const
    1.95 +	{
    1.96 +	aStream.WriteInt32L(iValidityPeriod.Int());
    1.97 +	aStream.WriteInt32L(iInterval);
    1.98 +	aStream.WriteInt8L(iIntervalType);
    1.99 +	TInt64 asInt = iStartTime.Int64();
   1.100 +	aStream.WriteInt32L(I64LOW(asInt));
   1.101 +	aStream.WriteInt32L(I64HIGH(asInt));
   1.102 +	}
   1.103 +
   1.104 +/**
   1.105 +Internalizes the ScheduleEntryInfo
   1.106 +@internalComponent only used by server
   1.107 +*/
   1.108 +void TScheduleEntryInfo::InternalizeL(RReadStream& aStream)
   1.109 +	{
   1.110 +	iValidityPeriod = aStream.ReadInt32L();
   1.111 +	iInterval = aStream.ReadInt32L();
   1.112 +	iIntervalType = TIntervalType(aStream.ReadInt8L());
   1.113 +	TInt64 asInt;
   1.114 +	TInt lo;
   1.115 +	TInt hi;
   1.116 +	lo=aStream.ReadInt32L();
   1.117 +	hi=aStream.ReadInt32L();
   1.118 +	asInt = MAKE_TINT64(hi,lo);
   1.119 +	iStartTime = asInt;
   1.120 +	}
   1.121 +
   1.122 +
   1.123 +
   1.124 +/**
   1.125 +TScheduleEntryInfo2 Default constructor. 
   1.126 +It sets the object's members data to the following default values.
   1.127 +iIntervalType : EHourly
   1.128 +iStartTime : UTC time set to 0
   1.129 +iInterval : 0
   1.130 +iValidityPeriod : 0
   1.131 +*/
   1.132 +EXPORT_C TScheduleEntryInfo2::TScheduleEntryInfo2() :
   1.133 +		iInterval(0),
   1.134 +		iIntervalType(TIntervalType(0)),
   1.135 +		iValidityPeriod(0),
   1.136 +		iReserved(NULL)
   1.137 +	{
   1.138 +		
   1.139 +	}
   1.140 +	
   1.141 +/**
   1.142 +Copy constructor for TScheduleEntryInfo2
   1.143 +Sets the parameter's data to this object.
   1.144 +@param aEntryInfo The TScheduleEntryInfo2 object to be copied
   1.145 +*/	
   1.146 +EXPORT_C TScheduleEntryInfo2::TScheduleEntryInfo2(const TScheduleEntryInfo2& aEntryInfo)
   1.147 +	{
   1.148 +	*this = aEntryInfo;
   1.149 +	}
   1.150 +
   1.151 +/**
   1.152 +TScheduleEntryInfo2 constructor taking the specified parameters.
   1.153 +
   1.154 +@param aStartTime The first time that the entry will cause execution of tasks
   1.155 +@param aIntervalType Defines the type of time-frame relative to which execution of tasks is timed; 
   1.156 +for example, EHourly implies relative to the current hour, EDaily implies 
   1.157 +relative to the current day
   1.158 +@param aInterval The interval between execution of tasks
   1.159 +For a schedule entry interval to be valid, it should be greater than or equal to 1
   1.160 +@param aIntervalMinutes The period for which the entry is valid
   1.161 +*/	
   1.162 +EXPORT_C TScheduleEntryInfo2::TScheduleEntryInfo2(const TTsTime& aStartTime, TIntervalType aIntervalType, TInt aInterval, TTimeIntervalMinutes aValidityPeriod)
   1.163 +	{
   1.164 +	iStartTime = aStartTime;
   1.165 +	iIntervalType = aIntervalType;
   1.166 +	iInterval = aInterval;
   1.167 +	iValidityPeriod = aValidityPeriod ;
   1.168 +	iReserved = NULL;
   1.169 +	}
   1.170 +
   1.171 +/**
   1.172 +Returns the Interval Type
   1.173 +@return The type of interval used between due times for this schedule entry.
   1.174 +The type of interval used may be EHourly, EDaily, EMonthly or EYearly.
   1.175 +@see TIntervalType
   1.176 +*/
   1.177 +EXPORT_C TIntervalType TScheduleEntryInfo2::IntervalType() const
   1.178 +	{
   1.179 +	return iIntervalType;	
   1.180 +	}
   1.181 +
   1.182 +/**
   1.183 +Sets the type of interval used between due times for this schedule entry.
   1.184 +The type of interval used may be EHourly, EDaily, EMonthly or EYearly.
   1.185 +@param aIntervalType The type of interval to be used.
   1.186 +@see TIntervalType
   1.187 +*/	
   1.188 +EXPORT_C void TScheduleEntryInfo2::SetIntervalType(TIntervalType aIntervalType)
   1.189 +	{
   1.190 +	iIntervalType = aIntervalType;	
   1.191 +	}
   1.192 +
   1.193 +/**
   1.194 +Returns the first time at which the entry will cause execution of tasks.
   1.195 +@return Start time - this TTsTime value may be either UTC or local time based.
   1.196 +Entries with local time based start times will remain at that local time regardless of
   1.197 +timezone or DST changes (ie. will float). Entries with UTC based start times, will
   1.198 +remain at the given UTC time (will not float).
   1.199 +@see TTsTime
   1.200 +*/
   1.201 +EXPORT_C const TTsTime& TScheduleEntryInfo2::StartTime() const
   1.202 +	{
   1.203 +	return iStartTime;	
   1.204 +	}
   1.205 +
   1.206 +/**
   1.207 +Sets the first time the entry will cause execution of tasks.
   1.208 +@param aStartTime This TTsTime value may be either UTC or local time based.
   1.209 +If this is a local time based value, the schedule entry will remain
   1.210 +at that local time regardless of timezone and DST changes (ie. it will float)
   1.211 +If the value is UTC based, the schedule entry will remain at that UTC time (will not float).
   1.212 +@see TTsTime
   1.213 +*/
   1.214 +EXPORT_C void TScheduleEntryInfo2::SetStartTime(const TTsTime& aStartTime)
   1.215 +	{
   1.216 +	iStartTime = aStartTime;
   1.217 +	}
   1.218 +	
   1.219 +/**
   1.220 +Returns the interval between execution of tasks.
   1.221 +@return Interval between execution of tasks. 
   1.222 +For a schedule entry interval to be valid, it should be greater than or equal to 1.
   1.223 +@see TScheduleEntryInfo2::SetInterval
   1.224 +*/	
   1.225 +EXPORT_C TInt TScheduleEntryInfo2::Interval() const
   1.226 +	{
   1.227 +	return 	iInterval;
   1.228 +	}
   1.229 +
   1.230 +/**
   1.231 +Sets the interval between execution of tasks.
   1.232 +The way that this value is interpreted depends on the value of iIntervalType. 
   1.233 +For example, if the interval is 2 and iIntervalType has a value of EMonthly, 
   1.234 +then the interval is 2 months. 
   1.235 +@param aInterval For a schedule entry interval to be valid, it should be greater than or equal to 1.
   1.236 +*/	
   1.237 +EXPORT_C void TScheduleEntryInfo2::SetInterval(TInt aInterval)
   1.238 +	{
   1.239 +	iInterval = aInterval;	
   1.240 +	}
   1.241 +
   1.242 +/**
   1.243 +Return the period for which the entry is valid.
   1.244 +After the validity period has expired, tasks associated with the entry will 
   1.245 +not be eligible for execution
   1.246 +@return TTimeIntervalMinutes
   1.247 +*/
   1.248 +EXPORT_C TTimeIntervalMinutes TScheduleEntryInfo2::ValidityPeriod() const
   1.249 +	{
   1.250 +	return iValidityPeriod;	
   1.251 +	}
   1.252 +	
   1.253 +/**
   1.254 +Sets the period for which the entry is valid.
   1.255 +After the validity period has expired, tasks associated with the entry will 
   1.256 +not be eligible for execution
   1.257 +@param aValidityPeriod, the period for which the entry is valid
   1.258 +@see TTimeIntervalMinutes
   1.259 +*/	
   1.260 +EXPORT_C void TScheduleEntryInfo2::SetValidityPeriod(TTimeIntervalMinutes aValidityPeriod)
   1.261 +	{
   1.262 +	iValidityPeriod = aValidityPeriod;	
   1.263 +	}
   1.264 +
   1.265 +
   1.266 +/**
   1.267 +Non exported constructor accepting a TScheduleEntryInfo parameter
   1.268 +This constructor is provided for use with the deprecated APIs.
   1.269 +This will assume home time in order to maintain backwards compatibility and will create a #
   1.270 +TScheduleEntryInfo2 object with a local time based start time.
   1.271 +@param aEntryInfo Entry info of deprecated type TScheduleEntryInfo
   1.272 +@see TScheduleEntryInfo
   1.273 +*/
   1.274 +TScheduleEntryInfo2::TScheduleEntryInfo2(const TScheduleEntryInfo& aEntryInfo)
   1.275 +	{	
   1.276 +	iStartTime.SetLocalTime(aEntryInfo.iStartTime);
   1.277 +	iIntervalType = aEntryInfo.iIntervalType;
   1.278 +	iInterval = aEntryInfo.iInterval;
   1.279 +	iValidityPeriod = aEntryInfo.iValidityPeriod ;	
   1.280 +	}
   1.281 +
   1.282 +
   1.283 +/**
   1.284 +Externalises an object of this class to a write stream.
   1.285 +The presence of this function means that the standard templated operator<<() 
   1.286 +can be used to externalise objects of this class.
   1.287 +	
   1.288 +@param aStream Stream to which the object should be externalised.
   1.289 +@internalComponent only used by server
   1.290 +*/
   1.291 +void TScheduleEntryInfo2::ExternalizeL(RWriteStream& aStream) const
   1.292 +	{
   1.293 +	aStream << iStartTime;
   1.294 +	aStream.WriteInt32L(iIntervalType);	
   1.295 +	aStream.WriteInt32L(iInterval);
   1.296 +	aStream.WriteInt32L(iValidityPeriod.Int());	
   1.297 +	}
   1.298 +
   1.299 +	
   1.300 +/**
   1.301 +Internalises an object of this class from a read stream.
   1.302 +The presence of this function means that the standard templated operator>>() 
   1.303 +can be used to internalise objects of this class.
   1.304 +		
   1.305 +@param aStream Stream from which the object is to be internalised.
   1.306 +@internalComponent only used by server
   1.307 +*/	
   1.308 +void TScheduleEntryInfo2::InternalizeL(RReadStream& aStream)
   1.309 +	{
   1.310 +	aStream >> iStartTime;
   1.311 +	iIntervalType = TIntervalType(aStream.ReadInt32L());
   1.312 +	iInterval = aStream.ReadInt32L();
   1.313 +	iValidityPeriod = aStream.ReadInt32L();
   1.314 +	}
   1.315 +	
   1.316 +/**
   1.317 +Calls ProcessOffsetEvent() on TScheduleEntryInfo's start time member
   1.318 +@see TTsTime::ProcessOffsetEvent
   1.319 +@internalComponent only used by the server
   1.320 +*/
   1.321 +void TScheduleEntryInfo2::ProcessOffsetEvent()
   1.322 +	{
   1.323 +	iStartTime.ProcessOffsetEvent();
   1.324 +	}
   1.325 +
   1.326 +/**
   1.327 +Assignment operator for TScheduleEntryInfo2
   1.328 +@see Mem::Copy
   1.329 +*/
   1.330 +EXPORT_C TScheduleEntryInfo2& TScheduleEntryInfo2::operator=(const TScheduleEntryInfo2& aEntryInfo)
   1.331 +	{
   1.332 +	Mem::Copy(this,&aEntryInfo,sizeof(*this));
   1.333 +	return *this;
   1.334 +	}
   1.335 +	
   1.336 +/**
   1.337 +Default Constructor for TScheduleState2.
   1.338 +By default, this state: has an empty string name, is non persistent, non enabled and its due time is set to zero.
   1.339 +*/
   1.340 +EXPORT_C TScheduleState2::TScheduleState2():
   1.341 +	iName(_L("")),
   1.342 +	iFlags(0),
   1.343 +	iReserved(NULL)
   1.344 +	{
   1.345 +		
   1.346 +	}
   1.347 +
   1.348 +/**
   1.349 +Copy constructor for TScheduleState2
   1.350 +@param aScheduleState The TScheduleState2 object to be copied
   1.351 +*/	
   1.352 +EXPORT_C TScheduleState2::TScheduleState2(const TScheduleState2& aScheduleState)
   1.353 +	{
   1.354 +	*this = aScheduleState;
   1.355 +	}
   1.356 +
   1.357 +/**
   1.358 +Constructor taking the specified parameters.
   1.359 +@param	aName The name of the schedule
   1.360 +@param 	aDueTime The time when the schedule is next due.
   1.361 +@param 	aPersists Boolean to indicate whether the schedule is persistent or not.
   1.362 +if a schedule is persistent, its lifetime is not limited to the lifetime of 
   1.363 +the tasks associated with it.
   1.364 +If a schedule is transient, it is created together with a new scheduled task, 
   1.365 +and is destroyed when the task is destroyed
   1.366 +@param 	aEnabled Boolean to indicate whether the shedule is enabled or not.
   1.367 +*/	
   1.368 +EXPORT_C TScheduleState2::TScheduleState2(const TName& aName, const TTsTime& aDueTime, TBool aPersists, TBool aEnabled)
   1.369 +	{
   1.370 +	iName = aName;
   1.371 +	iDueTime = aDueTime;
   1.372 +	SetPersists(aPersists);
   1.373 +	SetEnabled(aEnabled);
   1.374 +	iReserved = NULL;
   1.375 +	
   1.376 +	}
   1.377 +		
   1.378 +/**
   1.379 +@return  The name of the schedule
   1.380 +*/
   1.381 +EXPORT_C const TName& TScheduleState2::Name() const
   1.382 +	{
   1.383 +	return iName;	
   1.384 +	}
   1.385 +	
   1.386 +/**
   1.387 +Sets the name of the schedule
   1.388 +@param aName The name of the schedule
   1.389 +*/	
   1.390 +EXPORT_C void TScheduleState2::SetName(const TName& aName)
   1.391 +	{
   1.392 +	iName = aName;	
   1.393 +	}
   1.394 +
   1.395 +
   1.396 +/**
   1.397 +Returns the time when the schedule is next due.
   1.398 +@return The time when the schedule is next due. This time could be either home time (for floating schedules) or UTC time.
   1.399 +@see TTsTime
   1.400 +*/
   1.401 +EXPORT_C const TTsTime& TScheduleState2::DueTime() const
   1.402 +	{
   1.403 +	return iDueTime;	
   1.404 +	}
   1.405 +
   1.406 +	
   1.407 +/**
   1.408 +Sets the time when the schedule is next due.
   1.409 +@param aDueTime The time when the schedule is next due. This time could be either home time (for floating schedules) or UTC time.
   1.410 +@see TTsTime
   1.411 +*/	
   1.412 +EXPORT_C void TScheduleState2::SetDueTime(const TTsTime& aDueTime)
   1.413 +	{
   1.414 +	iDueTime = aDueTime;
   1.415 +	}
   1.416 +
   1.417 +
   1.418 +/**
   1.419 +Returns a boolean whether this schedule perists or not.
   1.420 +@return Etrue if this schedule persists, EFalse if this schedule doen't persist.
   1.421 +*/
   1.422 +EXPORT_C TBool TScheduleState2::Persists() const
   1.423 +	{
   1.424 +	return iFlags & KPersists ? ETrue: EFalse;		
   1.425 +	}
   1.426 +
   1.427 +	
   1.428 +
   1.429 +/**
   1.430 +Sets a boolean whether this schedule perists or not.
   1.431 +@param aPersists Etrue if this schedule persits, EFalse if this schedule doen't persist.
   1.432 +*/	
   1.433 +EXPORT_C void TScheduleState2::SetPersists(TBool aPersists)
   1.434 +	{
   1.435 +	if(aPersists )
   1.436 +		iFlags |= KPersists;
   1.437 +	else
   1.438 +		iFlags &= ~KPersists;
   1.439 +	}
   1.440 +
   1.441 +
   1.442 +/**
   1.443 +Returns information on whether this schedule is enabled or not.
   1.444 +@return Etrue if the schedule is enabled, EFalse id the schedule is not enabled.
   1.445 +*/
   1.446 +EXPORT_C TBool TScheduleState2::Enabled() const
   1.447 +	{
   1.448 +	return iFlags & KIsEnabled ? ETrue: EFalse;	
   1.449 +	}
   1.450 +
   1.451 +	
   1.452 +/**
   1.453 +Sets information on whether this schedule is enabled or not.
   1.454 +@param aEnabled 
   1.455 +*/	
   1.456 +EXPORT_C void TScheduleState2::SetEnabled(TBool aEnabled)
   1.457 +	{
   1.458 +	if(aEnabled )
   1.459 +		iFlags |= KIsEnabled;
   1.460 +	else
   1.461 +		iFlags &= ~KIsEnabled;	
   1.462 +	}
   1.463 +
   1.464 +/**
   1.465 +Assigns a TScheduleState2 to this object.
   1.466 +@see Mem::Copy
   1.467 +*/
   1.468 +EXPORT_C TScheduleState2& TScheduleState2::operator=(const TScheduleState2& aScheduleState)
   1.469 +	{
   1.470 +	Mem::Copy(this,&aScheduleState,sizeof(*this));
   1.471 +	return *this;
   1.472 +	}
   1.473 +
   1.474 +/**
   1.475 +A constructor for TScheduleState that takes a TScheduleState2 parameter,
   1.476 +for use with the deprecated APIs. All TScheduleStates created will have 
   1.477 +local time based iDueTime data members.
   1.478 +@internalComponent
   1.479 +*/
   1.480 +TScheduleState::TScheduleState(const TScheduleState2& aScheduleState2)
   1.481 +	{
   1.482 +	iName = aScheduleState2.Name();	
   1.483 +	iPersists = aScheduleState2.Persists();
   1.484 +	iEnabled = aScheduleState2.Enabled();
   1.485 +	
   1.486 +	// iDueTime is local time based for backwards compatibility
   1.487 +	iDueTime = aScheduleState2.DueTime().GetLocalTime();
   1.488 +	}