epoc32/include/schtask.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 schtask.h
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Representation of a task: 
       
    15 // Includes both user-defined data (iInfo+iData) and data set by system
       
    16 // construction from stream & accessors are exported for task executors
       
    17 // 
       
    18 //
       
    19 
       
    20 #if !defined(__SCHTASK_H__)
       
    21 #define __SCHTASK_H__
       
    22 
       
    23 #if !defined(__SCHINFO_H__)
       
    24 #include <schinfo.h>
       
    25 #endif 
       
    26 
       
    27 #include <s32file.h>
       
    28 
       
    29 
       
    30 /**
       
    31 @publishedPartner
       
    32 
       
    33 When SYMBIAN_SECURE_TASK_SCHEDULER is defined, platform security
       
    34 support functionality is included in Task Scheduler.
       
    35 
       
    36 This means that:
       
    37 
       
    38 (i) Scheduled executables will be passed a shared file handle to
       
    39 the scheduled task file by the Task Scheduler.
       
    40 
       
    41 (ii) The CScheduledTask::SecurityInfo() API is availble to
       
    42 retrieve security information about the schedule creator.
       
    43 */
       
    44 #ifndef SYMBIAN_SECURE_TASK_SCHEDULER
       
    45 #define SYMBIAN_SECURE_TASK_SCHEDULER
       
    46 #endif
       
    47 
       
    48 /**
       
    49 Class used by registered programs to access the scheduled task file store.
       
    50 
       
    51 When tasks are due, the Task Scheduler encapsulates task information within 
       
    52 CScheduledTask objects, and externalises them to a direct file store.
       
    53 
       
    54 This file store is located in the task scheduler's private data cage and thus
       
    55 cannot be accessed directly.  Instead the task scheduler passes a shared RFs and
       
    56 RFile handle to the registered program.
       
    57 
       
    58 The registered program can use the RFile::AdoptFromCreator API in conjunction
       
    59 with the APIs provided by this class to access the scheduled task file store as
       
    60 shown in the following example:
       
    61 
       
    62 @code
       
    63 	RFile file;
       
    64 	TInt error = file.AdoptFromCreator(TScheduledTaskFile::FsHandleIndex(),
       
    65 											TScheduledTaskFile::FileHandleIndex());
       
    66 @endcode
       
    67 @see CScheduledTask
       
    68 @see RFile::AdoptFromCreator
       
    69 @publishedAll
       
    70 @released
       
    71 */
       
    72 class TScheduledTaskFile
       
    73 	{
       
    74 public:
       
    75 	IMPORT_C static TInt FsHandleIndex();
       
    76 	IMPORT_C static TInt FileHandleIndex();
       
    77 	};
       
    78 
       
    79 /** 
       
    80 The representation of a scheduled task that is passed to registered programs.
       
    81 
       
    82 When tasks are due, the Task Scheduler encapsulates task information within 
       
    83 CScheduledTask objects, and externalises them to a direct file store.
       
    84 
       
    85 The root stream of the direct file store contains a 32 bit value, followed 
       
    86 by the external representations of one or more CScheduledTask objects. The 
       
    87 32 bit value is interpreted as a TInt32 and contains the number of CScheduledTask 
       
    88 objects that follow in the stream.
       
    89 
       
    90 The registered program can create successive CScheduledTask objects from this 
       
    91 stream using the static NewLC() function.
       
    92  
       
    93 @see TScheduledTaskFile
       
    94 @see RStoreReadStream 
       
    95 @publishedAll
       
    96 @released
       
    97 */
       
    98 class CScheduledTask : public CBase
       
    99 	{
       
   100 public:
       
   101 	IMPORT_C static CScheduledTask* NewLC(RReadStream& aStream);
       
   102 	~CScheduledTask();
       
   103 	IMPORT_C const TTaskInfo& Info() const;
       
   104 	IMPORT_C const HBufC& Data() const;
       
   105 	IMPORT_C const TTsTime& ValidUntil() const;
       
   106 	IMPORT_C TScheduleType ScheduleType() const;
       
   107 	IMPORT_C const TSecurityInfo& SecurityInfo() const;
       
   108 	
       
   109 	// These methods only used by task scheduler server
       
   110 	CScheduledTask(TTaskInfo& aInfo, 
       
   111 					HBufC* aData, 
       
   112 					TScheduleType aScheduleType,
       
   113 					const TSecurityInfo& aSecurityInfo);
       
   114 
       
   115 	TBool Due() const;
       
   116 	void SetDue(TBool aDue);
       
   117 	void OnDue(const TTsTime& aValidUntil);
       
   118 	void DecRepeat();
       
   119 	void Remove();
       
   120 	void ExternalizeL(RWriteStream& aStream) const;
       
   121 	//
       
   122 	TInt ScheduleId() const;
       
   123 	void SetScheduleId(TInt aScheduleId);	
       
   124 	//
       
   125 	TBool Persists() const;
       
   126 	void SetPersists();
       
   127 	//
       
   128 	static TInt Offset();
       
   129 	//
       
   130 private:
       
   131 	CScheduledTask();	
       
   132 	void InternalizeL(RReadStream& aStream);
       
   133 private:
       
   134 	TPriQueLink iPLink;
       
   135 	TTaskInfo iInfo;
       
   136 	HBufC* iData;
       
   137 	TTsTime iValidUntil;
       
   138 	TBool iDue;
       
   139 	TInt iScheduleId;
       
   140 	TScheduleType iScheduleType;
       
   141 	TSecurityInfo iSecurityInfo;
       
   142 	TBool iPersists;
       
   143 	};
       
   144 	
       
   145 /**
       
   146 Streaming operators for TSecurityInfo
       
   147 @internalComponent
       
   148 */	
       
   149 RWriteStream& operator<<(RWriteStream& aWriteStream, 
       
   150 						const TSecurityInfo& aSecurityInfo);
       
   151 
       
   152 /**
       
   153 Streaming operators for TSecurityInfo
       
   154 @internalComponent
       
   155 */	
       
   156 RReadStream& operator>>(RReadStream& aReadStream,
       
   157 						TSecurityInfo& aSecurityInfo);
       
   158 
       
   159 #endif