williamr@2
|
1 |
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
#ifndef __MSVSCHEDULESEND_H__
|
williamr@2
|
17 |
#define __MSVSCHEDULESEND_H__
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifdef _DEBUG
|
williamr@2
|
20 |
#undef _MSG_NO_LOGGING
|
williamr@2
|
21 |
#endif
|
williamr@2
|
22 |
|
williamr@2
|
23 |
|
williamr@2
|
24 |
|
williamr@2
|
25 |
|
williamr@2
|
26 |
#include <e32base.h>
|
williamr@2
|
27 |
#include <msvstd.h>
|
williamr@2
|
28 |
#include <csch_cli.h>
|
williamr@2
|
29 |
#include <msvschedulepackage.h>
|
williamr@2
|
30 |
#include <msvscheduledentry.h>
|
williamr@2
|
31 |
|
williamr@2
|
32 |
class CMsvEntrySelection;
|
williamr@2
|
33 |
class TMsvSchedulePackage;
|
williamr@2
|
34 |
class TMsvSendErrorAction;
|
williamr@2
|
35 |
class CMsvStore;
|
williamr@2
|
36 |
class TMsvEntry;
|
williamr@2
|
37 |
class CMsvOffPeakTimes;
|
williamr@2
|
38 |
class CMsvScheduleSettings;
|
williamr@2
|
39 |
class CMsvSendErrorActions;
|
williamr@2
|
40 |
class CMsvSysAgentActions;
|
williamr@2
|
41 |
class TMsvSchedulePackage;
|
williamr@2
|
42 |
class TMsvEntryScheduleData;
|
williamr@2
|
43 |
class CMsvServerEntry;
|
williamr@2
|
44 |
class CRepository;
|
williamr@2
|
45 |
|
williamr@2
|
46 |
const TUid KUidMsvScheduledSendingDLL = {0x100056A0};
|
williamr@2
|
47 |
const TInt KMsvSchsendArrayGrowth = 10;
|
williamr@2
|
48 |
|
williamr@2
|
49 |
#ifdef _MSG_NO_LOGGING
|
williamr@2
|
50 |
#define SCHSENDLOG(a)
|
williamr@2
|
51 |
#else
|
williamr@2
|
52 |
_LIT(KSchSendLogDir, "schsend");
|
williamr@2
|
53 |
_LIT(KSchSendLogFile,"SchSend.txt");
|
williamr@2
|
54 |
#define SCHSENDLOG(a) a
|
williamr@2
|
55 |
#endif
|
williamr@2
|
56 |
|
williamr@2
|
57 |
/**
|
williamr@2
|
58 |
Provides a Server MTM's interface to the Task Scheduler for messaging
|
williamr@2
|
59 |
scheduling.
|
williamr@2
|
60 |
|
williamr@2
|
61 |
Server MTM's must provide a derived class that implements GetMessageL() to
|
williamr@2
|
62 |
provide a factory for MTM-specific scheduling CMsvScheduledEntry-based objects.
|
williamr@2
|
63 |
|
williamr@2
|
64 |
@publishedAll
|
williamr@2
|
65 |
@released
|
williamr@2
|
66 |
*/
|
williamr@2
|
67 |
class CMsvScheduleSend : public CBase
|
williamr@2
|
68 |
{
|
williamr@2
|
69 |
public:
|
williamr@2
|
70 |
IMPORT_C ~CMsvScheduleSend();
|
williamr@2
|
71 |
|
williamr@2
|
72 |
IMPORT_C void ScheduleL(const CMsvEntrySelection& aSelection, const TMsvSchedulePackage& aPackage);
|
williamr@2
|
73 |
|
williamr@2
|
74 |
IMPORT_C void ReScheduleL(const CMsvEntrySelection& aSelection, const TMsvSchedulePackage& aPackage, const TMsvSendErrorAction* aErrorAction = NULL);
|
williamr@2
|
75 |
|
williamr@2
|
76 |
IMPORT_C void CheckScheduleL(const CMsvEntrySelection& aSelection);
|
williamr@2
|
77 |
IMPORT_C void DeleteScheduleL(const CMsvEntrySelection& aSelection);
|
williamr@2
|
78 |
|
williamr@2
|
79 |
IMPORT_C void SendingCompleteL(TMsvEntry& aEntry, const TBool aChangeEntry = EFalse);
|
williamr@2
|
80 |
IMPORT_C void SendingCompleteL(const CMsvEntrySelection& aSelection);
|
williamr@2
|
81 |
|
williamr@2
|
82 |
|
williamr@2
|
83 |
inline CMsvOffPeakTimes& OffPeakTimes() const;
|
williamr@2
|
84 |
inline CMsvScheduleSettings& ScheduleSettings() const;
|
williamr@2
|
85 |
inline CMsvSendErrorActions& SendErrorActions() const;
|
williamr@2
|
86 |
inline CMsvSysAgentActions& AgentActions() const;
|
williamr@2
|
87 |
|
williamr@2
|
88 |
IMPORT_C static void CreateScheduleL(RScheduler& aScheduler, const CMsvScheduleSettings& aSettings, const TTime& aStartTime, const TTimeIntervalMinutes& aValidityPeriod, TSchedulerItemRef& aRef);
|
williamr@2
|
89 |
IMPORT_C static void CreateScheduleL(RScheduler& aScheduler, const CArrayFixFlat<TTaskSchedulerCondition>& aConditions, const TTime& aTimeout, TSchedulerItemRef& aRef);
|
williamr@2
|
90 |
IMPORT_C static void FindScheduleL(RScheduler& aScheduler, const TTime& aStartTime, TSchedulerItemRef& aRef);
|
williamr@2
|
91 |
IMPORT_C static void FindScheduleL(RScheduler& aScheduler, const CArrayFixFlat<TTaskSchedulerCondition>& aConditions, const TTime& aTimeout, TSchedulerItemRef& aRef);
|
williamr@2
|
92 |
IMPORT_C static void RoundUpToMinute(TTime& aTime);
|
williamr@2
|
93 |
IMPORT_C static void ScheduleEntryL(RScheduler& aScheduler, const TSchedulerItemRef& aRef, const TMsvSchedulePackage& aPackage, TTaskInfo& aInfo);
|
williamr@2
|
94 |
IMPORT_C static void UpdateEntryAfterSchedule(const TSchedulerItemRef& aRef, const TTaskInfo& aInfo, const TTime& aTime, TInt aFinalState, TMsvEntry& aEntry, TMsvEntryScheduleData& aData);
|
williamr@2
|
95 |
IMPORT_C static void ConnectAndRegisterL(RScheduler& aScheduler, const CMsvScheduleSettings& aSettings);
|
williamr@2
|
96 |
|
williamr@2
|
97 |
IMPORT_C void LoadScheduleSettingsL(CRepository& aRepository);
|
williamr@2
|
98 |
|
williamr@2
|
99 |
protected:
|
williamr@2
|
100 |
|
williamr@2
|
101 |
IMPORT_C CMsvScheduleSend(CMsvServerEntry& aServerEntry);
|
williamr@2
|
102 |
IMPORT_C virtual void ConstructL();
|
williamr@2
|
103 |
|
williamr@2
|
104 |
/**
|
williamr@2
|
105 |
Gets the schedule data and recipients of a message.
|
williamr@2
|
106 |
|
williamr@2
|
107 |
Recipient information is MTM-specific, so the server MTM must provide a
|
williamr@2
|
108 |
derived class that implements CMsvScheduledEntry, and return objects of
|
williamr@2
|
109 |
that type from this function.
|
williamr@2
|
110 |
|
williamr@2
|
111 |
@param aId
|
williamr@2
|
112 |
The message ID.
|
williamr@2
|
113 |
|
williamr@2
|
114 |
@return
|
williamr@2
|
115 |
The message's schedule data.
|
williamr@2
|
116 |
*/
|
williamr@2
|
117 |
virtual CMsvScheduledEntry* GetMessageL(const TMsvId aId) const = 0;
|
williamr@2
|
118 |
|
williamr@2
|
119 |
private:
|
williamr@2
|
120 |
|
williamr@2
|
121 |
enum
|
williamr@2
|
122 |
{
|
williamr@2
|
123 |
EDefaultTaskPriority = 1, //used when scheduling a task in the task scheduler
|
williamr@2
|
124 |
EDefaultTaskRepeat = 0 //used when scheduling a task in the task scheduler
|
williamr@2
|
125 |
};
|
williamr@2
|
126 |
|
williamr@2
|
127 |
void SendingCompleteL(CMsvScheduledEntry& aScheduledEntry, const TBool aChangeEntry);
|
williamr@2
|
128 |
|
williamr@2
|
129 |
TBool GetNextRetry(CMsvScheduledEntry& aMessage, const TMsvSendErrorAction& aErrorAction, TTimeIntervalSeconds& aInterval) const;
|
williamr@2
|
130 |
|
williamr@2
|
131 |
void DoScheduleL(CMsvScheduledEntries& aSchEntries, const TInt aFinalState, const TTime& aTime, TBool aPendingConditions);
|
williamr@2
|
132 |
void DoReScheduleL(CMsvScheduledEntries& aSchEntries);
|
williamr@2
|
133 |
|
williamr@2
|
134 |
void GetMessagesL(const CMsvEntrySelection& aSelection);
|
williamr@2
|
135 |
|
williamr@2
|
136 |
void ConnectAndRegisterL();
|
williamr@2
|
137 |
|
williamr@2
|
138 |
void ScheduleEntryL(CMsvScheduledEntry& aMessage, const TInt aFinalState, const TTime& aStartTime, const TSchedulerItemRef& aRef, TBool aPendingConditions);
|
williamr@2
|
139 |
|
williamr@2
|
140 |
void GetOffPeakL(TTime aFromTime, TTime& aStartTime, TTimeIntervalMinutes& aValidityPeriod) const;
|
williamr@2
|
141 |
|
williamr@2
|
142 |
void DeleteScheduleForEntryL(CMsvScheduledEntry& aMessage);
|
williamr@2
|
143 |
void ResetScheduleInfoForEntryL(CMsvScheduledEntry& aMessage, const TBool aChangeEntry);
|
williamr@2
|
144 |
void SortByDateAndPendingConditionsL(CMsvScheduledEntries& aScheduledEntries);
|
williamr@2
|
145 |
void CreateScheduleL(const TTime& aStartTime, const TTimeIntervalMinutes& aValidityPeriod, const CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions, TBool aPendingConditions, TSchedulerItemRef& aRef);
|
williamr@2
|
146 |
void FindScheduleL(const TTime& aTime, const CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions, TBool aPendingConditions, TSchedulerItemRef& aRef);
|
williamr@2
|
147 |
|
williamr@2
|
148 |
void PopulateScheduleConditionsL(CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions);
|
williamr@2
|
149 |
TBool SetMessageStartTime(CMsvScheduledEntry& aMessage, const TTime& aFromTime, const TMsvSendErrorAction* aErrorAction = NULL);
|
williamr@2
|
150 |
|
williamr@2
|
151 |
TBool TaskAndMessageMatchL(const CMsvScheduledEntry& aMessage);
|
williamr@2
|
152 |
TMsvId GetMessageIdForTaskL(TInt aTaskId);
|
williamr@2
|
153 |
#ifndef _MSG_NO_LOGGING
|
williamr@2
|
154 |
void FLog(TRefByValue<const TDesC> aFormat, ...);
|
williamr@2
|
155 |
void FLog(TRefByValue<const TDesC8> aFormat, ...);
|
williamr@2
|
156 |
#endif
|
williamr@2
|
157 |
|
williamr@2
|
158 |
protected:
|
williamr@2
|
159 |
|
williamr@2
|
160 |
/** The Server MTM specific scheduled message sending settings. */
|
williamr@2
|
161 |
CMsvScheduleSettings* iSettings;
|
williamr@2
|
162 |
/** The Server MTM specific off peak time periods. */
|
williamr@2
|
163 |
CMsvOffPeakTimes* iOffPeakTimes;
|
williamr@2
|
164 |
/** The Server MTM specific actions to take when particular errors occur during
|
williamr@2
|
165 |
message sending. */
|
williamr@2
|
166 |
CMsvSendErrorActions* iErrorActions;
|
williamr@2
|
167 |
/** The System Agent conditions that must be satisfied before a sending attempt. */
|
williamr@2
|
168 |
CMsvSysAgentActions* iAgentActions;
|
williamr@2
|
169 |
|
williamr@2
|
170 |
/** Indicates if this has been registered with the Task Scheduler.
|
williamr@2
|
171 |
|
williamr@2
|
172 |
Initially set to EFalse. */
|
williamr@2
|
173 |
TBool iRegistered;
|
williamr@2
|
174 |
/** Provides an interface to the Task Scheduler. */
|
williamr@2
|
175 |
RScheduler iScheduler;
|
williamr@2
|
176 |
/** The CMsvServerEntry of the server MTM. */
|
williamr@2
|
177 |
CMsvServerEntry& iServerEntry;
|
williamr@2
|
178 |
/** Scheduling options. */
|
williamr@2
|
179 |
TMsvSchedulePackage iPackage;
|
williamr@2
|
180 |
|
williamr@2
|
181 |
/** Array of message schedule data. */
|
williamr@2
|
182 |
CMsvScheduledEntries* iSchEntries;
|
williamr@2
|
183 |
|
williamr@2
|
184 |
/** Array of schedule entry data. */
|
williamr@2
|
185 |
CArrayFixFlat<TScheduleEntryInfo2>* iSchEntryInfo;
|
williamr@2
|
186 |
/** Array of schedule task data. */
|
williamr@2
|
187 |
CArrayFixFlat<TTaskInfo>* iSchTaskInfo;
|
williamr@2
|
188 |
};
|
williamr@2
|
189 |
|
williamr@2
|
190 |
#include <msvschedulesend.inl>
|
williamr@2
|
191 |
|
williamr@2
|
192 |
#endif
|