genericservices/taskscheduler/INC/SCHINFO.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Various T-classes for client input to scheduler, scheduler output to client	
       
    15 // These classes comprise part of the interface (the rest is defined in RScheduler)
       
    16 // 
       
    17 //
       
    18 
       
    19 #if !defined (__SCHINFO_H__)
       
    20 #define __SCHINFO_H__
       
    21 
       
    22 #if !defined (__SCHTIME_H__)
       
    23 #include <schtime.h>
       
    24 #endif
       
    25 
       
    26 #if !defined(__E32BASE_H__)
       
    27 #include <e32base.h>
       
    28 #endif
       
    29 
       
    30 #include <s32strm.h>
       
    31 
       
    32 
       
    33 
       
    34 /** 
       
    35 Contains detailed information for a single task.
       
    36 
       
    37 A schedule can have any number of tasks. An object of this type is passed 
       
    38 to RScheduler::ScheduleTask(). Objects of this type are also returned by functions 
       
    39 within RScheduler that retrieve information about tasks.
       
    40 
       
    41 @see RScheduler::ScheduleTask()
       
    42 @see RScheduler::GetScheduleL()
       
    43 @see RScheduler::GetTaskInfoL() 
       
    44 @publishedAll
       
    45 @released
       
    46 */
       
    47 class TTaskInfo
       
    48 	{
       
    49 public:
       
    50 	//ctors
       
    51 	IMPORT_C TTaskInfo (TInt aTaskId, TName& aName, TInt aPriority, TInt aRepeat);
       
    52 	IMPORT_C TTaskInfo();//
       
    53 	//assignment
       
    54 	IMPORT_C TTaskInfo& operator=(const TTaskInfo& aTaskInfo);
       
    55 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
    56 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
    57 	//needs a copy ctor
       
    58 	//TTaskInfo (TTaskInfo& aTaskInfo);
       
    59 	
       
    60 	//data
       
    61 	/** Specifies how often the task is to be repeated.
       
    62 	
       
    63 	This is defined by the client.
       
    64 	
       
    65 	A value of 1 means once, a value of 2 means twice etc.
       
    66 	
       
    67 	Note that zero is interpreted to mean once, and a negative value is interpreted 
       
    68 	to mean that the task will be repeated until it is explicitly deleted. */
       
    69 	TInt iRepeat;
       
    70 	
       
    71 	/** The unique Id for the task.
       
    72 	
       
    73 	This is generated by the Task Scheduler. Clients should use the generated 
       
    74 	Id to refer to the task in future transactions. */
       
    75 	TInt iTaskId;
       
    76 	
       
    77 	/** The name of the task.
       
    78 	
       
    79 	This is defined by the client.
       
    80 	
       
    81 	@see TName */
       
    82 	TName iName;
       
    83 	
       
    84 	/** The priority of the task.
       
    85 	
       
    86 	This is defined by the client.
       
    87 	
       
    88 	Determines the order in which a client's tasks are executed. Where a client 
       
    89 	has two tasks with different priorities, the task with the higher priority 
       
    90 	will be executed first. */
       
    91 	TInt iPriority;
       
    92 	};
       
    93 
       
    94 /** 
       
    95 Defines a filter to be used when listing tasks scheduled in a call to RScheduler::GetTaskRefsL().
       
    96 
       
    97 @see RScheduler::GetTaskRefsL()
       
    98 @publishedAll
       
    99 @released
       
   100 */
       
   101 enum TTaskFilter
       
   102 	{
       
   103 	/** Indicates that all tasks are to be selected. */
       
   104 	EAllTasks,
       
   105 	/** Indicates those tasks associated with the executing program with which the 
       
   106 	calling client is associated, are to be selected. */
       
   107 	EMyTasks
       
   108 	};
       
   109 
       
   110 
       
   111 /** 
       
   112 Defines a filter to be used when listing schedules in a call to RScheduler::GetScheduleRefsL(), 
       
   113 and when listing tasks in a call to RScheduler::GetTaskRefsL().
       
   114 
       
   115 @see RScheduler::GetScheduleRefsL()
       
   116 @see RScheduler::GetTaskRefsL() 
       
   117 @publishedAll
       
   118 @released
       
   119 */
       
   120 enum TScheduleFilter
       
   121 	{
       
   122 	/** Indicates that all schedules are to be selected. */
       
   123 	EAllSchedules,
       
   124 	/** Indicates that only pending schedules are to be selected.
       
   125 	
       
   126 	Note that pending schedules are those that are enabled and have tasks associated 
       
   127 	with them. */
       
   128 	EPendingSchedules
       
   129 	};
       
   130 
       
   131 /** 
       
   132 Defines the type of interval used by a schedule entry.
       
   133 
       
   134 @see TScheduleEntryInfo
       
   135 @publishedAll
       
   136 @released
       
   137 */
       
   138 enum TIntervalType
       
   139 	{
       
   140 	/** The interval is based on hours. */
       
   141 	EHourly,
       
   142 	/** The interval is based on days. */
       
   143 	EDaily,
       
   144 	/** The interval is based on months. */
       
   145 	EMonthly,
       
   146 	/** The interval is based on years. */
       
   147 	EYearly
       
   148 	};
       
   149 
       
   150 
       
   151 /**
       
   152 Defines the types of schedules supported by the task scheduler API
       
   153 @internalAll
       
   154 */
       
   155 // Not for Client use , only to be used internally 
       
   156 enum TScheduleType
       
   157 	{
       
   158 	/** Indicates a time based schedule. */
       
   159 	ETimeSchedule,
       
   160 	/** Indicates a conditon based schedule. */
       
   161 	EConditionSchedule
       
   162 	};
       
   163 
       
   164 	
       
   165 /** 
       
   166 Defines, and uniquely identifies a schedule.
       
   167 
       
   168 @see RScheduler::CreatePersistentSchedule()
       
   169 @see RScheduler::ScheduleTask()
       
   170 @see RScheduler::GetScheduleRefsL()
       
   171 @see RScheduler::GetTaskRefsL()
       
   172 @see RScheduler::GetTaskInfoL()
       
   173 @publishedAll
       
   174 @released
       
   175 */
       
   176 class TSchedulerItemRef
       
   177 	{
       
   178 public:
       
   179 	/** The unique Id for the schedule.
       
   180 	
       
   181 	This is generated by the Task Scheduler when the schedule is created. Clients 
       
   182 	should use this Id to refer to the schedule in future transactions. */
       
   183 	TInt iHandle;
       
   184 	
       
   185 	/** The name of the schedule.
       
   186 	
       
   187 	This is defined by the client. */
       
   188 	TName iName;
       
   189 	};
       
   190 
       
   191 /** 
       
   192 Contains detailed information for a single schedule entry.
       
   193 
       
   194 A schedule can have any number of schedule entries. A client passes one or 
       
   195 more of these objects, contained within an array, to the RScheduler functions 
       
   196 that create or amend a schedule.
       
   197 
       
   198 @see RScheduler::CreatePersistentSchedule()
       
   199 @see RScheduler::EditSchedule()
       
   200 @see RScheduler::ScheduleTask()
       
   201 @see RScheduler::GetScheduleL() 
       
   202 @publishedAll
       
   203 @deprecated and replaced by TScheduleEntryInfo2
       
   204 */
       
   205 class TScheduleEntryInfo
       
   206 	{
       
   207 public:
       
   208 	void ExternalizeL(RWriteStream& aStream) const;
       
   209 	void InternalizeL(RReadStream& aStream);
       
   210 
       
   211 	/** Defines the type of time-frame relative to which execution of tasks is timed; 
       
   212 	for example, EHourly implies relative to the current hour, EDaily implies 
       
   213 	relative to the current day.
       
   214 	
       
   215 	@see TIntervalType */
       
   216 	TIntervalType iIntervalType;
       
   217 	
       
   218 	/** The first time that the entry will cause execution of tasks. */
       
   219 	TTime iStartTime;
       
   220 	
       
   221 	/** The interval between execution of tasks.
       
   222 	
       
   223 	The way that this value is interpreted depends on the value of iIntervalType. 
       
   224 	For example, if the interval is 2 and iIntervalType has a value of EMonthly, 
       
   225 	then the interval is 2 months.
       
   226 	
       
   227 	The interval must have a minimum value of 1.
       
   228 	
       
   229 	@see TIntervalType
       
   230 	@see iIntervalType */
       
   231 	TInt iInterval;
       
   232 	
       
   233 	/** The period for which the entry is valid.
       
   234 	
       
   235 	After the validity period has expired, tasks associated with the entry will 
       
   236 	not be eligible for execution.
       
   237 	
       
   238 	@see TTimeIntervalMinutes */
       
   239 	TTimeIntervalMinutes iValidityPeriod;
       
   240 	};
       
   241 	
       
   242 	
       
   243 	
       
   244 /** 
       
   245 Contains detailed information for a single schedule entry.
       
   246 
       
   247 A schedule can have any number of schedule entries. A client passes one or 
       
   248 more of these objects, contained within an array, to the RScheduler functions 
       
   249 that create or amend a schedule.
       
   250 
       
   251 @see RScheduler::CreatePersistentSchedule()
       
   252 @see RScheduler::EditSchedule()
       
   253 @see RScheduler::ScheduleTask()
       
   254 @see RScheduler::GetScheduleL() 
       
   255 @publishedAll
       
   256 @released
       
   257 */
       
   258 class TScheduleEntryInfo2
       
   259 	{
       
   260 public:
       
   261 	//constructors
       
   262 	IMPORT_C TScheduleEntryInfo2();
       
   263 	IMPORT_C TScheduleEntryInfo2(const TScheduleEntryInfo2& aEntryInfo);
       
   264 	IMPORT_C TScheduleEntryInfo2(const TTsTime& aStartTime, TIntervalType aIntervalType, TInt aInterval, TTimeIntervalMinutes aValidityPeriod);
       
   265 	 
       
   266 	//utility Get and Set methods
       
   267 	IMPORT_C TIntervalType IntervalType() const;
       
   268 	IMPORT_C void SetIntervalType(TIntervalType aIntervalType);
       
   269 
       
   270 	IMPORT_C const TTsTime& StartTime() const;
       
   271 	IMPORT_C void SetStartTime(const TTsTime& aStartTime);
       
   272 
       
   273 	IMPORT_C TInt Interval() const;
       
   274 	IMPORT_C void SetInterval(TInt aInterval);
       
   275 
       
   276 	IMPORT_C TTimeIntervalMinutes ValidityPeriod() const;
       
   277 	IMPORT_C void SetValidityPeriod(TTimeIntervalMinutes aValidityPeriod);
       
   278 
       
   279 	//assignment operator	
       
   280 	IMPORT_C TScheduleEntryInfo2& operator=(const TScheduleEntryInfo2& aEntryInfo);
       
   281 
       
   282 
       
   283 public:
       
   284 	// APIs for use within the Task Scheduler server
       
   285 	TScheduleEntryInfo2(const TScheduleEntryInfo& aEntryInfo);
       
   286 	void ProcessOffsetEvent();
       
   287 
       
   288 	void ExternalizeL(RWriteStream& aStream) const;
       
   289 	void InternalizeL(RReadStream& aStream);
       
   290 
       
   291 private:
       
   292 	/** The interval between execution of tasks.
       
   293 	The way that this value is interpreted depends on the value of iIntervalType. 
       
   294 	For example, if the interval is 2 and iIntervalType has a value of EMonthly, 
       
   295 	then the interval is 2 months.
       
   296 	The interval must have a minimum value of 1.
       
   297 	 */
       
   298 	TInt iInterval;
       
   299 	
       
   300 	/** Defines the type of interval between the execution of tasks. 
       
   301 	May be EHourly, EDaily, EMonthly or EYearly.
       
   302 	 */
       
   303 	TIntervalType iIntervalType;
       
   304 	
       
   305 	/** The first time that the entry will cause execution of tasks. */
       
   306 	TTsTime iStartTime;
       
   307 	
       
   308 	/** The period for which the entry is valid.
       
   309 	After the validity period has expired, tasks associated with the entry will 
       
   310 	not be eligible for execution.
       
   311 	*/
       
   312 	TTimeIntervalMinutes iValidityPeriod;
       
   313 
       
   314 	/** For future use
       
   315 	*/
       
   316 	TAny* iReserved;	
       
   317 	
       
   318 	// Declare the test accessor as a friend
       
   319 	friend class TScheduleEntryInfo2_StateAccessor;
       
   320 	};
       
   321 
       
   322 
       
   323 /** 
       
   324 Defines the state of a schedule.
       
   325 
       
   326 An object of this type is passed to, and populated by, a call to RScheduler::GetScheduleL().
       
   327 
       
   328 @see RScheduler::GetScheduleL()
       
   329 @publishedAll
       
   330 @released
       
   331 */
       
   332 class TScheduleState2
       
   333 	{
       
   334 public:
       
   335 
       
   336 	//constructors
       
   337 	IMPORT_C TScheduleState2();
       
   338 	IMPORT_C TScheduleState2(const TScheduleState2& aScheduleState);
       
   339 	IMPORT_C TScheduleState2(const TName& aName, const TTsTime& aDueTime, TBool aPersists, TBool aEnabled);
       
   340 		
       
   341 	//get, set methods
       
   342 	IMPORT_C const TName& Name() const;
       
   343 	IMPORT_C void SetName(const TName& aName);
       
   344 
       
   345 	IMPORT_C const TTsTime& DueTime() const;
       
   346 	IMPORT_C void SetDueTime(const TTsTime& aDueTime);
       
   347 
       
   348 	IMPORT_C TBool Persists() const;
       
   349 	IMPORT_C void SetPersists(TBool aPersists);
       
   350 
       
   351 	IMPORT_C TBool Enabled() const;
       
   352 	IMPORT_C void SetEnabled(TBool aEnabled);
       
   353 	
       
   354 	IMPORT_C TScheduleState2& operator=(const TScheduleState2& aScheduleState);
       
   355 
       
   356 private:
       
   357 	/** The name of the schedule. */
       
   358 	TName iName;
       
   359 	
       
   360 	/** The time when the schedule is next due.
       
   361 	This only has meaning if the schedule is pending, i.e. it is enabled and has 
       
   362 	tasks associated with it. */
       
   363 	TTsTime iDueTime;
       
   364 	
       
   365 	/** Flags used to indicate:
       
   366 	1.  Whether the schedule is enabled or not. (bit 0)
       
   367 	2.	Whether the schedule is persistent or not. (bit 1)
       
   368 		If a schedule is persistent, its lifetime is not limited to the lifetime of 
       
   369 		the tasks associated with it .
       
   370 		If a schedule is transient, it is created together with a new scheduled task, 
       
   371 		and is destroyed when the task is destroyed.
       
   372 		
       
   373 		Bits 2-31 reserved for future use
       
   374 	*/
       
   375 	TUint32 iFlags;
       
   376 	
       
   377 	/** For future use
       
   378 	*/
       
   379 	TAny* iReserved;
       
   380 	
       
   381 	// Declare the test accessor as a friend
       
   382 	friend class TScheduleState2_StateAccessor;
       
   383 	};
       
   384 
       
   385 /** 
       
   386 Defines the state of a schedule.
       
   387 
       
   388 An object of this type is passed to, and populated by, a call to RScheduler::GetScheduleL().
       
   389 
       
   390 @see RScheduler::GetScheduleL()
       
   391 @publishedAll
       
   392 @deprecated and replaced by TScheduleState2.
       
   393 */
       
   394 class TScheduleState
       
   395 	{
       
   396 public:
       
   397 	//constructor for use with the deprecated APIs
       
   398 	TScheduleState(const TScheduleState2& aScheduleState2);
       
   399 	TScheduleState()
       
   400 		{		
       
   401 		}
       
   402 	
       
   403 	/** The name of the schedule. */
       
   404 	TName iName;
       
   405 	
       
   406 	/** The time when the schedule is next due.
       
   407 	
       
   408 	This only has meaning if the schedule is pending, i.e. it is enabled and has 
       
   409 	tasks associated with it. */
       
   410 	TTime iDueTime;
       
   411 	
       
   412 	/** Indicates whether the schedule is persistent or not.
       
   413 	
       
   414 	If a schedule is persistent, its lifetime is not limited to the lifetime of 
       
   415 	the tasks associated with it .
       
   416 	
       
   417 	If a schedule is transient, it is created together with a new scheduled task, 
       
   418 	and is destroyed when the task is destroyed. */
       
   419 	TBool iPersists;
       
   420 	
       
   421 	/** Indicates whether the schedule is enabled or not. */
       
   422 	TBool iEnabled;
       
   423 	};
       
   424 
       
   425 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   426 #include <schinfointernal.h>
       
   427 
       
   428 #endif
       
   429 
       
   430 #endif