|
1 // Copyright (c) 2001-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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 #ifndef SCHSENDEXE_H_ |
|
18 #define SCHSENDEXE_H_ |
|
19 |
|
20 #ifdef _DEBUG |
|
21 #undef _MSG_NO_LOGGING |
|
22 #endif |
|
23 |
|
24 |
|
25 #include <msvschedulesend.h> //for SCHSENDLOG and KSchSendLogDir |
|
26 |
|
27 #ifdef _DEBUG |
|
28 //#define _SCHSENDEXE_TEST //undefine when submitting code |
|
29 #endif |
|
30 |
|
31 #ifdef _SCHSENDEXE_TEST |
|
32 #pragma message("WARNING: Test code enabled") |
|
33 const TInt KMsvSendExeOneMinute = 1000000 * 60 / 30; |
|
34 #else |
|
35 const TInt KMsvSendExeOneMinute = 1000000 * 60; |
|
36 #endif |
|
37 |
|
38 const TInt KSendExeActiveTimeout = KMsvSendExeOneMinute / 12; // 10 secs |
|
39 const TInt KSchSendExeMinReschedule = KMsvSendExeOneMinute * 1; // 1 mins |
|
40 const TInt KSchSendExeMaxReschedule = KMsvSendExeOneMinute * 3; // 4 mins |
|
41 const TInt KDefaultPriority = CActive::EPriorityStandard; |
|
42 const TInt KMsvSendExeGrowth = 5; |
|
43 |
|
44 class CScheduledTask; |
|
45 |
|
46 // |
|
47 // |
|
48 // Local Function Declarations |
|
49 // |
|
50 // |
|
51 |
|
52 enum TSchSendExePanic |
|
53 { |
|
54 EMultipleMtms, |
|
55 ENoMessagesInSelection, |
|
56 ENoSendCommand, |
|
57 EOperationCompletedTooSoon, |
|
58 ETooManyOperationsCompleted, |
|
59 EObjectNotNull |
|
60 }; |
|
61 |
|
62 void gPanic(TSchSendExePanic aPanic); |
|
63 void gPanic(TInt aPanic); |
|
64 |
|
65 TInt Execute(const TDesC& aFileName, RFile& aFile ); |
|
66 void DoExecuteL(const TDesC& aFileName, RFile& aFile ); |
|
67 |
|
68 class CMsvSendExeActive; |
|
69 |
|
70 |
|
71 /** |
|
72 |
|
73 The CProgressTimer class |
|
74 Calls iOperation.ProgressL() every iPollInterval microseconds. |
|
75 Used by CMsvSendExeActive. |
|
76 |
|
77 */ |
|
78 class CProgressTimer : public CTimer |
|
79 { |
|
80 public: |
|
81 static CProgressTimer* NewL(CMsvOperation& aOperation, const TTimeIntervalMicroSeconds32& aPollInterval); |
|
82 void Start(); |
|
83 ~CProgressTimer(); |
|
84 |
|
85 private: |
|
86 CProgressTimer(CMsvOperation& aOperation, const TTimeIntervalMicroSeconds32& aPollInterval); |
|
87 void RunL(); |
|
88 CMsvOperation& iOperation; |
|
89 TTimeIntervalMicroSeconds32 iPollInterval; |
|
90 }; |
|
91 |
|
92 |
|
93 |
|
94 /** |
|
95 |
|
96 The CMsvSendExe class |
|
97 Reads the task file and starts the corresponding messaging operations. |
|
98 |
|
99 */ |
|
100 class CMsvSendExe : public MMsvSessionObserver, CActive |
|
101 { |
|
102 public: |
|
103 |
|
104 static CMsvSendExe* StartLC(const TDesC& aFileName, RFile& aFile ); |
|
105 |
|
106 ~CMsvSendExe(); |
|
107 |
|
108 void HandleSessionEventL(MMsvSessionObserver::TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) {}; |
|
109 TBool IsSendActive(); // {return IsActive();} |
|
110 void OperationComplete(const CMsvSendExeActive& aActive, TInt aError); |
|
111 |
|
112 #ifndef _MSG_NO_LOGGING |
|
113 static void FLog(const TDesC& aFileName, TRefByValue<const TDesC16> aFmt, ...); |
|
114 #endif |
|
115 |
|
116 private: |
|
117 |
|
118 CMsvSendExe(const TDesC& aFileName, RFile& aFile ); |
|
119 |
|
120 void ConstructL(); |
|
121 |
|
122 void DoCancel(); |
|
123 void RunL(); |
|
124 |
|
125 void ProcessFileL(); |
|
126 void CallMtmL(); |
|
127 |
|
128 void RetrievePackagesL(); |
|
129 void AddPackageL(const CScheduledTask& aTask); |
|
130 |
|
131 void RetrieveMessagesL(); |
|
132 |
|
133 void AddTaskL(const TMsvSchedulePackage& aPackage); |
|
134 void AddTaskL(const TMsvSchedulePackage& aPackage, const TUid& aMtm); |
|
135 |
|
136 void RescheduleOnError(const CMsvSendExeActive& aActive, TInt aError); |
|
137 void RescheduleOnError(const CMsvEntrySelection& aSelection, const TMsvSchedulePackage& aPackage, TInt aError); |
|
138 void RescheduleAllL(TInt aError); |
|
139 void CompleteReschedule(RScheduler& aScheduler, const TSchedulerItemRef& aRef, TInt aCount); |
|
140 |
|
141 void DoResheduleOnErrorL(RScheduler& aScheduler, const CMsvEntrySelection& aSelection, const TMsvSchedulePackage& aPackage, TInt aError, TSchedulerItemRef& aRef, TInt& aCount, TTime& aStartTime); |
|
142 void FailOnError(const CMsvEntrySelection& aActive, TInt aError); |
|
143 void RestoreScheduleSettingsL(TMsvId aServiceId, const TUid& aMtm, CMsvScheduleSettings& aSettings); |
|
144 TBool FindorCreateScheduleL(RScheduler& aScheduler, TTime& aStartTime, const CMsvScheduleSettings& aSettings, TSchedulerItemRef& aRef); |
|
145 void UpdateEntryL(CMsvEntry& aMsvEntry, TMsvEntry& aEntry, const TSchedulerItemRef& aRef, const TTaskInfo& aInfo, const TTime& aStartTime); |
|
146 |
|
147 CMsvSession* iSession; |
|
148 const TDesC& iFileName; |
|
149 |
|
150 RFile& iTaskFile; |
|
151 |
|
152 TTime iCreated; |
|
153 RPointerArray<CMsvSendExeActive> iOperations; |
|
154 RArray<TMsvSchedulePackage> iPackages; |
|
155 CActiveSchedulerWait iActiveSchedulerWait; |
|
156 |
|
157 #ifdef _DEBUG |
|
158 TInt iOperationsComplete; |
|
159 #endif |
|
160 }; |
|
161 |
|
162 class CMsvSendExeActive : public CActive |
|
163 { |
|
164 public: |
|
165 static CMsvSendExeActive* NewLC(CMsvSession& aSession, CMsvSendExe& aParent, const TMsvSchedulePackage& aPackage, const TUid& aMtm, TInt aPriority = EPriorityStandard); |
|
166 ~CMsvSendExeActive(); |
|
167 void StartL(); |
|
168 void AppendL(TMsvId aId); |
|
169 inline TInt MsgCount() const; |
|
170 inline const TMsvSchedulePackage& Package() const; |
|
171 inline const TUid& Mtm() const; |
|
172 inline const CMsvEntrySelection& Selection() const; |
|
173 |
|
174 private: |
|
175 CMsvSendExeActive(CMsvSession& aSession, CMsvSendExe& aParent, const TMsvSchedulePackage& aPackage, const TUid& aMtm, TInt aPriority); |
|
176 void ConstructL(); |
|
177 void RunL(); |
|
178 void DoCancel(); |
|
179 |
|
180 private: |
|
181 |
|
182 CMsvSession& iSession; |
|
183 CMsvSendExe& iParent; |
|
184 CProgressTimer* iTimer; |
|
185 CMsvOperation* iOperation; |
|
186 CMsvEntrySelection* iSelection; |
|
187 TMsvSchedulePackage iPackage; |
|
188 TUid iMtm; |
|
189 }; |
|
190 |
|
191 inline TInt CMsvSendExeActive::MsgCount() const |
|
192 { |
|
193 return iSelection->Count(); |
|
194 } |
|
195 |
|
196 inline const CMsvEntrySelection& CMsvSendExeActive::Selection() const |
|
197 { |
|
198 return *iSelection; |
|
199 } |
|
200 |
|
201 inline const TMsvSchedulePackage& CMsvSendExeActive::Package() const |
|
202 { |
|
203 return iPackage; |
|
204 } |
|
205 |
|
206 inline const TUid& CMsvSendExeActive::Mtm() const |
|
207 { |
|
208 return iMtm; |
|
209 } |
|
210 |
|
211 #endif |