|
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 #include <csch_cli.h> |
|
17 #include <msvapi.h> |
|
18 #include <msvschedulepackage.h> |
|
19 #include "SchSendExe.h" |
|
20 |
|
21 // |
|
22 // CMsvSendExeActive |
|
23 // |
|
24 |
|
25 |
|
26 /** |
|
27 |
|
28 CMsvSendExeActive Factory Function |
|
29 |
|
30 @return Newly constructed CMsvSendExeActive |
|
31 @internalAll |
|
32 @param aSession Message server session |
|
33 @param aParent Used to callback on when the operation is complete |
|
34 @param aPackage Details of what type of operation to exectute |
|
35 @param aMtm The MTM of the message in aPackage |
|
36 @param aPriority CActive priority. Defaults to EPriorityStandard |
|
37 */ |
|
38 CMsvSendExeActive* CMsvSendExeActive::NewLC(CMsvSession& aSession, CMsvSendExe& aParent, const TMsvSchedulePackage& aPackage, const TUid& aMtm, TInt aPriority) |
|
39 { |
|
40 CMsvSendExeActive* self = new (ELeave) CMsvSendExeActive(aSession, aParent, aPackage, aMtm, aPriority); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 /** |
|
48 |
|
49 CMsvSendExeActive Destructor |
|
50 |
|
51 @return |
|
52 @internalAll |
|
53 */ |
|
54 CMsvSendExeActive::~CMsvSendExeActive() |
|
55 { |
|
56 Cancel(); |
|
57 delete iTimer; |
|
58 delete iOperation; |
|
59 delete iSelection; |
|
60 } |
|
61 |
|
62 |
|
63 /** |
|
64 |
|
65 The CMsvSendExeActive::StartL method |
|
66 Starts the operation relating to iPackage. |
|
67 Starts the timer that will poll iOperation's progress |
|
68 |
|
69 @return |
|
70 @internalAll |
|
71 */ |
|
72 void CMsvSendExeActive::StartL() |
|
73 { |
|
74 __ASSERT_DEBUG(iOperation == NULL, gPanic(EObjectNotNull)); |
|
75 __ASSERT_DEBUG(iTimer == NULL, gPanic(EObjectNotNull)); |
|
76 |
|
77 iOperation = iSession.TransferCommandL(*iSelection, iPackage.iCommandId, iPackage.iParameter, iStatus); |
|
78 |
|
79 //Start the timer that will poll the progress on iOperation |
|
80 iTimer = CProgressTimer::NewL(*iOperation, iPackage.iPollProgress); |
|
81 iTimer->Start(); |
|
82 SetActive(); |
|
83 } |
|
84 |
|
85 |
|
86 /** |
|
87 |
|
88 CMsvSendExeActive Constructor |
|
89 |
|
90 @return |
|
91 @internalAll |
|
92 @param aSession Message server session |
|
93 @param aParent Used to callback on when the operation is complete |
|
94 @param aPackage Details of what type of operation to exectute |
|
95 @param aMtm The MTM of the message in aPackage |
|
96 @param aPriority CActive priority. Defaults to EPriorityStandard |
|
97 */ |
|
98 CMsvSendExeActive::CMsvSendExeActive(CMsvSession& aSession, CMsvSendExe& aParent, const TMsvSchedulePackage& aPackage, const TUid& aMtm, TInt aPriority) |
|
99 : CActive(aPriority), iSession(aSession), iParent(aParent), iPackage(aPackage), iMtm(aMtm) |
|
100 { |
|
101 CActiveScheduler::Add(this); |
|
102 } |
|
103 |
|
104 void CMsvSendExeActive::ConstructL() |
|
105 { |
|
106 iSelection = new (ELeave) CMsvEntrySelection; |
|
107 } |
|
108 |
|
109 void CMsvSendExeActive::RunL() |
|
110 { |
|
111 if (iTimer) |
|
112 iTimer->Cancel(); |
|
113 |
|
114 iParent.OperationComplete(*this, iStatus.Int()); |
|
115 } |
|
116 |
|
117 void CMsvSendExeActive::DoCancel() |
|
118 { |
|
119 if (iOperation) |
|
120 iOperation->Cancel(); |
|
121 |
|
122 if (iTimer) |
|
123 iTimer->Cancel(); |
|
124 |
|
125 iParent.OperationComplete(*this, KErrCancel); |
|
126 } |
|
127 |
|
128 void CMsvSendExeActive::AppendL(TMsvId aId) |
|
129 { |
|
130 if (iSelection->Find(aId) == KErrNotFound) |
|
131 iSelection->AppendL(aId); |
|
132 } |
|
133 |
|
134 |
|
135 // |
|
136 // CProgressTimer |
|
137 // |
|
138 |
|
139 CProgressTimer* CProgressTimer::NewL(CMsvOperation& aOperation, const TTimeIntervalMicroSeconds32& aPollInterval) |
|
140 { |
|
141 CProgressTimer* self = new (ELeave) CProgressTimer(aOperation, aPollInterval); |
|
142 CleanupStack::PushL(self); |
|
143 |
|
144 self->ConstructL(); |
|
145 |
|
146 CleanupStack::Pop(); |
|
147 |
|
148 return self; |
|
149 } |
|
150 |
|
151 CProgressTimer::CProgressTimer(CMsvOperation& aOperation, const TTimeIntervalMicroSeconds32& aPollInterval) |
|
152 : CTimer(EPriorityHigh), iOperation(aOperation), iPollInterval(aPollInterval) |
|
153 { |
|
154 CActiveScheduler::Add(this); |
|
155 } |
|
156 |
|
157 CProgressTimer::~CProgressTimer() |
|
158 { |
|
159 Cancel(); |
|
160 } |
|
161 |
|
162 void CProgressTimer::Start() |
|
163 { |
|
164 if (iPollInterval.Int() > 0) |
|
165 { |
|
166 After(iPollInterval); |
|
167 } |
|
168 } |
|
169 |
|
170 void CProgressTimer::RunL() |
|
171 { |
|
172 if (iPollInterval.Int() > 0) |
|
173 { |
|
174 // Ignore progress errors (we don't care) |
|
175 TRAPD(error, iOperation.ProgressL()); |
|
176 After(iPollInterval); |
|
177 } |
|
178 } |