×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Getting schedule and task count using RScheduler

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
lpvalente (Talk | contribs)
m (Lpvalente -)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Symbian C++]][[Category:Code Examples]][[Category:Files/Data]][[Category:S60 3rd Edition FP1]][[Category:Code Snippet]]
+
[[Category:Symbian C++]][[Category:Code Snippet]][[Category:Files/Data]][[Category:S60 3rd Edition FP1]][[Category:Code Snippet]]
__NOTOC__
+
{{Archived|timestamp=20120313125214|user=roy.debjit| }}
__NOEDITSECTION__
+
{{KBCS}}
+
{{ArticleMetaData
+
|id=CS000990
+
|platform=S60 3rd Edition, FP1
+
|devices=Nokia N93
+
|category=Symbian C++
+
|subcategory=Files/Data
+
|creationdate=May 28, 2008
+
|keywords=RScheduler, TSchedulerItemRef, TScheduleEntryInfo2, TTaskSchedulerCondition, TTaskInfo, TTsTime, TScheduleState2, RScheduler::Connect(), RScheduler::Register(), RScheduler::Close(), RScheduler::GetScheduleRefsL(), RScheduler::GetScheduleL()
+
  
 +
{{ArticleMetaData <!-- v1.2 -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|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]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= Nokia N93
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= S60 3rd Edition, FP1
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Aknyman]]
+
|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= RScheduler, TSchedulerItemRef, TScheduleEntryInfo2, TTaskSchedulerCondition, TTaskInfo, TTsTime, TScheduleState2, RScheduler::Connect(), RScheduler::Register(), RScheduler::Close(), RScheduler::GetScheduleRefsL(), RScheduler::GetScheduleL()
 +
|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= CS000990
 
}}
 
}}
{{Archived|timestamp=20120313125214|user=roy.debjit| }}
 
 
    
 
    
 
==Overview==
 
==Overview==
This code snippet implements three simple helper methods to get a count of schedules, scheduled condition-based tasks, and scheduled time-based tasks. The <tt>RScheduler</tt> method <tt>GetScheduleRefsL()</tt> is used to get the count of schedules. The filter parameter of this method can be used to include all schedules (EAllSchedules) or only pending (EPendingSchedules) schedules to count.
+
{{Abstract|This code snippet implements three simple helper methods to get a count of schedules, scheduled condition-based tasks, and scheduled time-based tasks. The {{Icode|RScheduler}} method {{Icode|GetScheduleRefsL()}} is used to get the count of schedules. The filter parameter of this method can be used to include all schedules (EAllSchedules) or only pending (EPendingSchedules) schedules to count.}}
  
The RScheduler method <tt>GetScheduleL()</tt> is used to get task count of the schedule by a given ID. This example implements separate methods for time-based and condition-based schedules. All these helper methods return -1 in error situations.
+
The RScheduler method {{Icode|GetScheduleL()}} is used to get task count of the schedule by a given ID. This example implements separate methods for time-based and condition-based schedules. All these helper methods return -1 in error situations.
  
 
This snippet can be self-signed.
 
This snippet can be self-signed.
Line 34: Line 40:
  
 
<code>
 
<code>
LIBRARY             schsvr.lib
+
LIBRARY schsvr.lib
 
</code>
 
</code>
  
Line 40: Line 46:
  
 
ExampleTaskHandler.exe must be created and time-based and condition-based schedules with example tasks must be scheduled before this code snippet can be executed.  
 
ExampleTaskHandler.exe must be created and time-based and condition-based schedules with example tasks must be scheduled before this code snippet can be executed.  
See code snippets [[CS000986 - Creating and registering a task handler with RScheduler]], [[CS000987 - Creating persistent and transient schedules with RScheduler]], and [[CS000988 - Creating a condition-based schedule with RScheduler]] for more information.
+
See code snippets [[Creating and registering a task handler with RScheduler]], [[Archived:Creating persistent and transient schedules with RScheduler]], and [[Archived:Creating a condition-based schedule with RScheduler]] for more information.
  
 
==Resource files==
 
==Resource files==
Line 276: Line 282:
  
 
==See also==
 
==See also==
* [[CS000986 - Creating and registering a task handler with RScheduler]]
+
* [[Creating and registering a task handler with RScheduler]]
* [[CS000987 - Creating persistent and transient schedules with RScheduler]]
+
* [[Archived:Creating persistent and transient schedules with RScheduler]]
* [[CS000988 - Creating a condition-based schedule with RScheduler]]
+
* [[Archived:Creating a condition-based schedule with RScheduler]]
* [[CS000989 - Getting schedule and task info using RScheduler]]
+
* [[Archived:Getting schedule and task info using RScheduler]]
<!-- [[Getting_schedule_and_task_count_using_RScheduler]] -->
+
<!-- [[Getting schedule and task count using RScheduler]] -->
* [[CS000991 - Editing a schedule using RScheduler]]
+
* [[Archived:Editing a schedule using RScheduler]]
* [[CS000992 - Deleting schedules and tasks using RScheduler]]
+
* [[Archived:Deleting schedules and tasks using RScheduler]]

Latest revision as of 16:04, 23 January 2013

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}}.

Article Metadata
Tested with
Devices(s): Nokia N93
Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition FP1
Article
Keywords: RScheduler, TSchedulerItemRef, TScheduleEntryInfo2, TTaskSchedulerCondition, TTaskInfo, TTsTime, TScheduleState2, RScheduler::Connect(), RScheduler::Register(), RScheduler::Close(), RScheduler::GetScheduleRefsL(), RScheduler::GetScheduleL()
Created: aknyman (23 May 2008)
Last edited: lpvalente (23 Jan 2013)

Contents

[edit] Overview

This code snippet implements three simple helper methods to get a count of schedules, scheduled condition-based tasks, and scheduled time-based tasks. The RScheduler method GetScheduleRefsL() is used to get the count of schedules. The filter parameter of this method can be used to include all schedules (EAllSchedules) or only pending (EPendingSchedules) schedules to count.

The RScheduler method GetScheduleL() is used to get task count of the schedule by a given ID. This example implements separate methods for time-based and condition-based schedules. All these helper methods return -1 in error situations.

This snippet can be self-signed.

[edit] MMP file

The following libraries are required:

LIBRARY schsvr.lib

[edit] Preconditions

ExampleTaskHandler.exe must be created and time-based and condition-based schedules with example tasks must be scheduled before this code snippet can be executed. See code snippets Creating and registering a task handler with RScheduler, Archived:Creating persistent and transient schedules with RScheduler, and Archived:Creating a condition-based schedule with RScheduler for more information.

[edit] Resource files

.rss

RESOURCE MENU_PANE r_schedulerexample_menu
{
items =
{
//...
MENU_ITEM {command = EGetCountExample; txt = "GetCountExample";},
//...
MENU_ITEM {command = EAknSoftkeyExit; txt = "Exit";}
};
}

.hrh

enum TSchedulerExampleIds
{
//...
EGetCountExample,
//...
};

[edit] Header file

#ifndef __SCHEDULEREXAMPLEAPPUI_H__
#define __SCHEDULEREXAMPLEAPPUI_H__
 
#include <csch_cli.h> // RScheduler
#include <schinfo.h> // TSchedulerItemRef, TTaskInfo...
 
class CSchedulerExampleAppUi : public CAknAppUi
{
//...
public:
void HandleCommandL(TInt aCommand);
//...
private:
TInt GetConditionBasedScheduleTaskCountL(RScheduler& aScheduler,
TInt aScheduleId,
TInt& aTaskCount);
 
TInt GetTimeBasedScheduleTaskCountL(RScheduler& aScheduler,
TInt aScheduleId,
TInt& aTaskCount);
 
TInt GetScheduleCountL(TScheduleFilter aFilter,
RScheduler& aScheduler,
TInt& aScheduleCount);
//...
private:
 
RScheduler iScheduler;
 
TSchedulerItemRef iPersistentScheduleHandle;
TSchedulerItemRef iConditionScheduleHandle;
};
 
#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();
}
 
void CSchedulerExampleAppUi::HandleCommandL(TInt aCommand)
{
TBuf<100> Text1; //first line of dialog text
TBuf<100> Text2; //second line of dialog text
 
switch(aCommand)
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
//...
case EGetCountExample:
{
TInt err(KErrNone);
TInt scheduleCount=-1;
TInt timeBasedScheduleTaskCount=-1;
TInt conditionBasedScheduleTaskCount=-1;
 
err = GetScheduleCountL(EAllSchedules, iScheduler, scheduleCount);
 
err = GetTimeBasedScheduleTaskCountL(iScheduler,
iPersistentScheduleHandle.iHandle, timeBasedScheduleTaskCount );
 
err = GetConditionBasedScheduleTaskCountL(iScheduler,
iConditionScheduleHandle.iHandle, conditionBasedScheduleTaskCount );
 
Text1.Append(_L("ScheduleCount:"));
Text1.AppendNum(scheduleCount);
 
Text2.Append(_L("TimeBasedScheduleTaskCount:"));
Text2.AppendNum(timeBasedScheduleTaskCount);
Text2.Append(_L("\nConditionBasedScheduleTaskCount:"));
Text2.AppendNum(conditionBasedScheduleTaskCount);
 
CEikonEnv::Static()->InfoWinL(Text1, Text2);
}
break;
 
default:
//Panic(ESchedulerExampleUi);
break;
}
}
 
 
TInt CSchedulerExampleAppUi::GetConditionBasedScheduleTaskCountL(RScheduler& aScheduler,
TInt aScheduleId,
TInt& aTaskCount)
{
TInt ret(KErrNone);
 
CArrayFixFlat<TTaskInfo>* tasks =
new (ELeave) CArrayFixFlat<TTaskInfo>(1);
CleanupStack::PushL(tasks);
 
TTsTime time;
TScheduleState2 state;
CArrayFixFlat<TTaskSchedulerCondition>* conditions =
new (ELeave) CArrayFixFlat<TTaskSchedulerCondition>(1);
CleanupStack::PushL(conditions);
 
tasks->Reset();
ret = aScheduler.GetScheduleL(aScheduleId,
state,
*conditions,
time,
*tasks);
CleanupStack::PopAndDestroy(conditions);
 
if(ret == KErrNone)
aTaskCount = tasks->Count();
else
aTaskCount = -1;
 
CleanupStack::PopAndDestroy(tasks);
 
return ret;
}
 
 
TInt CSchedulerExampleAppUi::GetTimeBasedScheduleTaskCountL(RScheduler& aScheduler,
TInt aScheduleId,
TInt& aTaskCount)
{
TInt ret(KErrNone);
 
CArrayFixFlat<TTaskInfo>* tasks = new (ELeave) CArrayFixFlat<TTaskInfo>(1);
CleanupStack::PushL(tasks);
 
TTsTime time;
TScheduleState2 state;
CArrayFixFlat<TScheduleEntryInfo2>* entries =
new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
CleanupStack::PushL(entries);
 
tasks->Reset();
ret = aScheduler.GetScheduleL(aScheduleId,
state,
*entries,
*tasks,
time);
 
CleanupStack::PopAndDestroy(entries);
 
if(ret == KErrNone)
aTaskCount = tasks->Count();
else
aTaskCount = -1;
 
CleanupStack::PopAndDestroy(tasks);
 
return ret;
}
 
 
TInt CSchedulerExampleAppUi::GetScheduleCountL(TScheduleFilter aFilter,
RScheduler& aScheduler,
TInt& aScheduleCount)
{
TInt ret(KErrNone);
 
CArrayFixFlat<TSchedulerItemRef>* items =
new (ELeave) CArrayFixFlat<TSchedulerItemRef> (1);
CleanupStack::PushL(items);
 
ret = aScheduler.GetScheduleRefsL(*items, aFilter);
 
if(ret == KErrNone)
aScheduleCount = items->Count();
else
aScheduleCount = -1;
 
CleanupStack::PopAndDestroy(items);
 
return ret;
}


[edit] Postconditions

The count of schedules, time-based schedule tasks, and condition-based schedule tasks are displayed to the user with info dialogs.

[edit] See also

This page was last modified on 23 January 2013, at 16:04.
94 page views in the last 30 days.