×
Namespaces

Variants
Actions
(Difference between revisions)

Creating and registering a task handler with RScheduler

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
lpvalente (Talk | contribs)
m (Lpvalente -)
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
+
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Files/Data]][[Category:Code Snippet]]
__NOEDITSECTION__
+
{{Archived|timestamp=20120907183435|user=[[User:Lpvalente|Lpvalente]]}}
  
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
 
|-
 
|'''ID''' ||  
 
|'''Creation date''' || May 23, 2008
 
|-
 
|'''Platform''' || S60 3rd Edition, FP1
 
|'''Tested on devices''' || Nokia N93
 
|-
 
|'''Category''' || Symbian C++
 
|'''Subcategory''' || Files/Data
 
|}
 
  
 
+
{{ArticleMetaData <!-- v1.2 -->
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
|-
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|'''Keywords (APIs, classes, methods, functions):''' CFileStore, RStoreReadStream, CDirectFileStore, CScheduledTask, RScheduler, CFileStore::Root(), RStoreReadStream::OpenLC(), RStoreReadStream::ReadInt32L(), CDirectFileStore::FromLC(), CScheduledTask::Info(), CScheduledTask::Data(), CScheduledTask::ValidUntil(), RScheduler::Connect(), RScheduler::Register(), RScheduler::Close()
+
|devices= Nokia N93
|}
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= S60 3rd Edition, FP1
 +
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= CFileStore, RStoreReadStream, CDirectFileStore, CScheduledTask, RScheduler, CFileStore::Root(), RStoreReadStream::OpenLC(), RStoreReadStream::ReadInt32L(), CDirectFileStore::FromLC(), CScheduledTask::Info(), CScheduledTask::Data(), CScheduledTask::ValidUntil(), RScheduler::Connect(), RScheduler::Register(), RScheduler::Close()
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080523
 +
|author= [[User:Aknyman]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= Files/Data
 +
|id= CS000986
 +
}}
  
 
==Overview==
 
==Overview==
This code snippet shows how a task handler EXE program can be created and registered when the class <tt>RScheduler</tt> is used to schedule Task Scheduler tasks. The client has to be registered with the scheduler before any tasks can be scheduled. The registration method is called <tt>Register()</tt> and it takes two parameters, the filename of the program to execute the tasks and the priority which is relative to other clients.  
+
{{Abstract|This code snippet shows how a task handler EXE program can be created and registered when the class {{Icode|RScheduler}} is used to schedule Task Scheduler tasks. The client has to be registered with the scheduler before any tasks can be scheduled. The registration method is called {{Icode|Register()}} and it takes two parameters, the filename of the program to execute the tasks and the priority which is relative to other clients. }}
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.
Line 30: Line 39:
  
 
<code>
 
<code>
LIBRARY             euser.lib
+
LIBRARY euser.lib
LIBRARY             efsrv.lib
+
LIBRARY efsrv.lib
LIBRARY             estor.lib
+
LIBRARY estor.lib
LIBRARY             schsvr.lib
+
LIBRARY schsvr.lib
 
</code>
 
</code>
  
Line 167: Line 176:
  
 
==See also==
 
==See also==
<!-- [[Creating_and_registering_a_task_handler_with_RScheduler]] -->
+
<!-- [[Creating and registering a task handler with RScheduler]] -->
* [[Creating_persistent_and_transient_schedules_with_RScheduler]]
+
* [[Archived:Creating persistent and transient schedules with RScheduler]]
* [[Creating_a_condition_based_schedule_with_RScheduler]]
+
* [[Archived:Creating a condition-based schedule with RScheduler]]
* [[Getting_schedule_and_task_info_using_RScheduler]]
+
* [[Archived:Getting schedule and task info using RScheduler]]
* [[Getting_schedule_and_task_count_using_RScheduler]]
+
* [[Archived:Getting schedule and task count using RScheduler]]
* [[Editing_a_schedule_using_RScheduler]]
+
* [[Archived:Editing a schedule using RScheduler]]
* [[Deleting_schedules_and_tasks_using_RScheduler]]
+
* [[Archived:Deleting schedules and tasks using RScheduler]]
 
+
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Files/Data]]
+

Latest revision as of 21:34, 7 September 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


Article Metadata
Tested with
Devices(s): Nokia N93
Compatibility
Platform(s): S60 3rd Edition, FP1
Article
Keywords: CFileStore, RStoreReadStream, CDirectFileStore, CScheduledTask, RScheduler, CFileStore::Root(), RStoreReadStream::OpenLC(), RStoreReadStream::ReadInt32L(), CDirectFileStore::FromLC(), CScheduledTask::Info(), CScheduledTask::Data(), CScheduledTask::ValidUntil(), RScheduler::Connect(), RScheduler::Register(), RScheduler::Close()
Created: aknyman (23 May 2008)
Last edited: lpvalente (07 Sep 2012)

Contents

[edit] Overview

This code snippet shows how a task handler EXE program can be created and registered when the class RScheduler is used to schedule Task Scheduler tasks. The client has to be registered with the scheduler before any tasks can be scheduled. The registration method is called Register() and it takes two parameters, the filename of the program to execute the tasks and the priority which is relative to other clients.

This snippet can be self-signed.

[edit] MMP file

The following libraries are required:

LIBRARY euser.lib
LIBRARY efsrv.lib
LIBRARY estor.lib
LIBRARY schsvr.lib


[edit] Source file (ExampleTaskHandler.exe)

#include <schinfo.h>
#include <schtask.h>
#include <s32file.h>
 
static void DoRunTaskL(RFile& aTaskFile)
{
TInt taskCount(0);
CFileStore* fileStore;
RStoreReadStream readStream;
 
fileStore = CDirectFileStore::FromLC(aTaskFile);
readStream.OpenLC(*fileStore,fileStore->Root());
 
//from schtask.h :
//The root stream of the direct file store contains a 32-bit value, followed
//by the external representations of one or more CScheduledTask objects. The
//32-bit value is interpreted as a TInt32 and contains the number of CScheduledTask
//objects that follow in the stream.
taskCount = readStream.ReadInt32L();
 
for (TInt index = 0; index < taskCount; index++)
{
CScheduledTask* task = CScheduledTask::NewLC(readStream);
 
// Do something with the task info...
//task->Info().iName;
//task->Info().iTaskId;
//task->ValidUntil();
//HBufC* data = const_cast<HBufC*>(&(task->Data()));
 
CleanupStack::PopAndDestroy(task);
}
 
CleanupStack::PopAndDestroy(2); // fileStore, readStream
}
 
LOCAL_D TInt RunTask()
{
TInt err(KErrNoMemory);
CTrapCleanup* cleanup=CTrapCleanup::New();
 
if (cleanup)
{
RFile file;
 
//from schtask.h :
//The registered program can use the RFile::AdoptFromCreator API in conjunction
//with the APIs provided by this class to access the scheduled task file store
err = file.AdoptFromCreator(TScheduledTaskFile::FsHandleIndex(),
TScheduledTaskFile::FileHandleIndex());
if (err != KErrNone)
{
return err;
}
 
TRAP(err, DoRunTaskL(file));
 
file.Close();
 
delete cleanup;
}
 
return err;
}
 
GLDEF_C TInt E32Main()
{
return RunTask();
}


[edit] Header file

#ifndef __SCHEDULEREXAMPLEAPPUI_H__
#define __SCHEDULEREXAMPLEAPPUI_H__
 
#include <csch_cli.h> // RScheduler
 
class CSchedulerExampleAppUi : public CAknAppUi
{
//...
private:
 
RScheduler iScheduler;
 
};
 
#endif // __SCHEDULEREXAMPLEAPPUI_H__


[edit] Source file

void CSchedulerExampleAppUi::ConstructL()
{
//...
User::LeaveIfError(iScheduler.Connect());
 
_LIT(KExampleTaskHandlerExe, "ExampleTaskHandler.exe");
TFileName exampleHandler(KExampleTaskHandlerExe);
 
User::LeaveIfError(iScheduler.Register(exampleHandler, CActive::EPriorityStandard));
}
 
CSchedulerExampleAppUi::~CSchedulerExampleAppUi()
{
 
//...
iScheduler.Close();
}


[edit] Postconditions

The client is registered with the scheduler and ready to schedule Task Scheduler tasks. The program ExampleTaskHandler.exe is responsible for running scheduled tasks.

[edit] See also

This page was last modified on 7 September 2012, at 21:34.
72 page views in the last 30 days.
×