1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/msvschedulesend.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,192 @@
1.4 +// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __MSVSCHEDULESEND_H__
1.20 +#define __MSVSCHEDULESEND_H__
1.21 +
1.22 +#ifdef _DEBUG
1.23 +#undef _MSG_NO_LOGGING
1.24 +#endif
1.25 +
1.26 +
1.27 +
1.28 +
1.29 +#include <e32base.h>
1.30 +#include <msvstd.h>
1.31 +#include <csch_cli.h>
1.32 +#include <msvschedulepackage.h>
1.33 +#include <msvscheduledentry.h>
1.34 +
1.35 +class CMsvEntrySelection;
1.36 +class TMsvSchedulePackage;
1.37 +class TMsvSendErrorAction;
1.38 +class CMsvStore;
1.39 +class TMsvEntry;
1.40 +class CMsvOffPeakTimes;
1.41 +class CMsvScheduleSettings;
1.42 +class CMsvSendErrorActions;
1.43 +class CMsvSysAgentActions;
1.44 +class TMsvSchedulePackage;
1.45 +class TMsvEntryScheduleData;
1.46 +class CMsvServerEntry;
1.47 +class CRepository;
1.48 +
1.49 +const TUid KUidMsvScheduledSendingDLL = {0x100056A0};
1.50 +const TInt KMsvSchsendArrayGrowth = 10;
1.51 +
1.52 +#ifdef _MSG_NO_LOGGING
1.53 +#define SCHSENDLOG(a)
1.54 +#else
1.55 +_LIT(KSchSendLogDir, "schsend");
1.56 +_LIT(KSchSendLogFile,"SchSend.txt");
1.57 +#define SCHSENDLOG(a) a
1.58 +#endif
1.59 +
1.60 +/**
1.61 +Provides a Server MTM's interface to the Task Scheduler for messaging
1.62 +scheduling.
1.63 +
1.64 +Server MTM's must provide a derived class that implements GetMessageL() to
1.65 +provide a factory for MTM-specific scheduling CMsvScheduledEntry-based objects.
1.66 +
1.67 +@publishedAll
1.68 +@released
1.69 +*/
1.70 +class CMsvScheduleSend : public CBase
1.71 + {
1.72 +public:
1.73 + IMPORT_C ~CMsvScheduleSend();
1.74 +
1.75 + IMPORT_C void ScheduleL(const CMsvEntrySelection& aSelection, const TMsvSchedulePackage& aPackage);
1.76 +
1.77 + IMPORT_C void ReScheduleL(const CMsvEntrySelection& aSelection, const TMsvSchedulePackage& aPackage, const TMsvSendErrorAction* aErrorAction = NULL);
1.78 +
1.79 + IMPORT_C void CheckScheduleL(const CMsvEntrySelection& aSelection);
1.80 + IMPORT_C void DeleteScheduleL(const CMsvEntrySelection& aSelection);
1.81 +
1.82 + IMPORT_C void SendingCompleteL(TMsvEntry& aEntry, const TBool aChangeEntry = EFalse);
1.83 + IMPORT_C void SendingCompleteL(const CMsvEntrySelection& aSelection);
1.84 +
1.85 +
1.86 + inline CMsvOffPeakTimes& OffPeakTimes() const;
1.87 + inline CMsvScheduleSettings& ScheduleSettings() const;
1.88 + inline CMsvSendErrorActions& SendErrorActions() const;
1.89 + inline CMsvSysAgentActions& AgentActions() const;
1.90 +
1.91 + IMPORT_C static void CreateScheduleL(RScheduler& aScheduler, const CMsvScheduleSettings& aSettings, const TTime& aStartTime, const TTimeIntervalMinutes& aValidityPeriod, TSchedulerItemRef& aRef);
1.92 + IMPORT_C static void CreateScheduleL(RScheduler& aScheduler, const CArrayFixFlat<TTaskSchedulerCondition>& aConditions, const TTime& aTimeout, TSchedulerItemRef& aRef);
1.93 + IMPORT_C static void FindScheduleL(RScheduler& aScheduler, const TTime& aStartTime, TSchedulerItemRef& aRef);
1.94 + IMPORT_C static void FindScheduleL(RScheduler& aScheduler, const CArrayFixFlat<TTaskSchedulerCondition>& aConditions, const TTime& aTimeout, TSchedulerItemRef& aRef);
1.95 + IMPORT_C static void RoundUpToMinute(TTime& aTime);
1.96 + IMPORT_C static void ScheduleEntryL(RScheduler& aScheduler, const TSchedulerItemRef& aRef, const TMsvSchedulePackage& aPackage, TTaskInfo& aInfo);
1.97 + IMPORT_C static void UpdateEntryAfterSchedule(const TSchedulerItemRef& aRef, const TTaskInfo& aInfo, const TTime& aTime, TInt aFinalState, TMsvEntry& aEntry, TMsvEntryScheduleData& aData);
1.98 + IMPORT_C static void ConnectAndRegisterL(RScheduler& aScheduler, const CMsvScheduleSettings& aSettings);
1.99 +
1.100 + IMPORT_C void LoadScheduleSettingsL(CRepository& aRepository);
1.101 +
1.102 +protected:
1.103 +
1.104 + IMPORT_C CMsvScheduleSend(CMsvServerEntry& aServerEntry);
1.105 + IMPORT_C virtual void ConstructL();
1.106 +
1.107 +/**
1.108 +Gets the schedule data and recipients of a message.
1.109 +
1.110 +Recipient information is MTM-specific, so the server MTM must provide a
1.111 +derived class that implements CMsvScheduledEntry, and return objects of
1.112 +that type from this function.
1.113 +
1.114 +@param aId
1.115 +The message ID.
1.116 +
1.117 +@return
1.118 +The message's schedule data.
1.119 +*/
1.120 + virtual CMsvScheduledEntry* GetMessageL(const TMsvId aId) const = 0;
1.121 +
1.122 +private:
1.123 +
1.124 + enum
1.125 + {
1.126 + EDefaultTaskPriority = 1, //used when scheduling a task in the task scheduler
1.127 + EDefaultTaskRepeat = 0 //used when scheduling a task in the task scheduler
1.128 + };
1.129 +
1.130 + void SendingCompleteL(CMsvScheduledEntry& aScheduledEntry, const TBool aChangeEntry);
1.131 +
1.132 + TBool GetNextRetry(CMsvScheduledEntry& aMessage, const TMsvSendErrorAction& aErrorAction, TTimeIntervalSeconds& aInterval) const;
1.133 +
1.134 + void DoScheduleL(CMsvScheduledEntries& aSchEntries, const TInt aFinalState, const TTime& aTime, TBool aPendingConditions);
1.135 + void DoReScheduleL(CMsvScheduledEntries& aSchEntries);
1.136 +
1.137 + void GetMessagesL(const CMsvEntrySelection& aSelection);
1.138 +
1.139 + void ConnectAndRegisterL();
1.140 +
1.141 + void ScheduleEntryL(CMsvScheduledEntry& aMessage, const TInt aFinalState, const TTime& aStartTime, const TSchedulerItemRef& aRef, TBool aPendingConditions);
1.142 +
1.143 + void GetOffPeakL(TTime aFromTime, TTime& aStartTime, TTimeIntervalMinutes& aValidityPeriod) const;
1.144 +
1.145 + void DeleteScheduleForEntryL(CMsvScheduledEntry& aMessage);
1.146 + void ResetScheduleInfoForEntryL(CMsvScheduledEntry& aMessage, const TBool aChangeEntry);
1.147 + void SortByDateAndPendingConditionsL(CMsvScheduledEntries& aScheduledEntries);
1.148 + void CreateScheduleL(const TTime& aStartTime, const TTimeIntervalMinutes& aValidityPeriod, const CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions, TBool aPendingConditions, TSchedulerItemRef& aRef);
1.149 + void FindScheduleL(const TTime& aTime, const CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions, TBool aPendingConditions, TSchedulerItemRef& aRef);
1.150 +
1.151 + void PopulateScheduleConditionsL(CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions);
1.152 + TBool SetMessageStartTime(CMsvScheduledEntry& aMessage, const TTime& aFromTime, const TMsvSendErrorAction* aErrorAction = NULL);
1.153 +
1.154 + TBool TaskAndMessageMatchL(const CMsvScheduledEntry& aMessage);
1.155 + TMsvId GetMessageIdForTaskL(TInt aTaskId);
1.156 +#ifndef _MSG_NO_LOGGING
1.157 + void FLog(TRefByValue<const TDesC> aFormat, ...);
1.158 + void FLog(TRefByValue<const TDesC8> aFormat, ...);
1.159 +#endif
1.160 +
1.161 +protected:
1.162 +
1.163 + /** The Server MTM specific scheduled message sending settings. */
1.164 + CMsvScheduleSettings* iSettings;
1.165 + /** The Server MTM specific off peak time periods. */
1.166 + CMsvOffPeakTimes* iOffPeakTimes;
1.167 + /** The Server MTM specific actions to take when particular errors occur during
1.168 + message sending. */
1.169 + CMsvSendErrorActions* iErrorActions;
1.170 + /** The System Agent conditions that must be satisfied before a sending attempt. */
1.171 + CMsvSysAgentActions* iAgentActions;
1.172 +
1.173 + /** Indicates if this has been registered with the Task Scheduler.
1.174 +
1.175 + Initially set to EFalse. */
1.176 + TBool iRegistered;
1.177 + /** Provides an interface to the Task Scheduler. */
1.178 + RScheduler iScheduler;
1.179 + /** The CMsvServerEntry of the server MTM. */
1.180 + CMsvServerEntry& iServerEntry;
1.181 + /** Scheduling options. */
1.182 + TMsvSchedulePackage iPackage;
1.183 +
1.184 + /** Array of message schedule data. */
1.185 + CMsvScheduledEntries* iSchEntries;
1.186 +
1.187 + /** Array of schedule entry data. */
1.188 + CArrayFixFlat<TScheduleEntryInfo2>* iSchEntryInfo;
1.189 + /** Array of schedule task data. */
1.190 + CArrayFixFlat<TTaskInfo>* iSchTaskInfo;
1.191 + };
1.192 +
1.193 +#include <msvschedulesend.inl>
1.194 +
1.195 +#endif