|
1 // Copyright (c) 1999-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 <e32base.h> |
|
17 #include <e32std.h> |
|
18 #include <msvstd.h> |
|
19 #include <msventry.h> |
|
20 #include <msvuids.h> |
|
21 #include <bautils.h> |
|
22 #include <msvschedulesend.h> |
|
23 #include <schedulebaseservermtm.h> |
|
24 #include <schsend_panic.h> |
|
25 #include <centralrepository.h> |
|
26 |
|
27 |
|
28 // |
|
29 // |
|
30 // CScheduleBaseServerMtm Implementation |
|
31 // |
|
32 // |
|
33 |
|
34 EXPORT_C CScheduleBaseServerMtm::CScheduleBaseServerMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aServerEntry) |
|
35 : CBaseServerMtm(aRegisteredMtmDll, aServerEntry) |
|
36 /** |
|
37 Constructor. |
|
38 |
|
39 @param aRegisteredMtmDll Registration data for the MTM DLL |
|
40 @param aServerEntry Context on which to operate |
|
41 */ |
|
42 { |
|
43 //Do Nothing Else |
|
44 } |
|
45 |
|
46 EXPORT_C CScheduleBaseServerMtm::~CScheduleBaseServerMtm() |
|
47 /** |
|
48 Destructor. |
|
49 |
|
50 The derived class destructor should delete the iScheduleSend member. |
|
51 */ |
|
52 { |
|
53 iResourceFile.Close(); |
|
54 iFs.Close(); |
|
55 } |
|
56 |
|
57 EXPORT_C void CScheduleBaseServerMtm::SendScheduledL(CMsvEntrySelection& aSelection, const TBool aMove, const TDesC8& /*aParameter*/, TRequestStatus& aStatus) |
|
58 /** |
|
59 Sends messages now that were previously scheduled. |
|
60 |
|
61 The messages are sent immediately, overriding the scheduling. |
|
62 |
|
63 @param aSelection The selection of messages that were previously scheduled |
|
64 and now need to be sent |
|
65 @param aMove Whether to perform a Move (ETrue) or a Copy (EFalse) when sending |
|
66 has completed |
|
67 @param aParameter The parameter (MTM-specific) that is required when sending |
|
68 the messages |
|
69 @param aStatus Asynchronous status word |
|
70 */ |
|
71 { |
|
72 if (aMove) |
|
73 { |
|
74 MoveFromLocalL(aSelection, NULL, aStatus); |
|
75 } |
|
76 else |
|
77 { |
|
78 CopyFromLocalL(aSelection, NULL, aStatus); |
|
79 } |
|
80 } |
|
81 |
|
82 EXPORT_C void CScheduleBaseServerMtm::LoadResourceFileL(const TDesC& aResFileName) |
|
83 /** |
|
84 Loads the specified resource file. |
|
85 |
|
86 A utility function that can be used from the pure virtual LoadResourceFileL(). |
|
87 |
|
88 It leaves if the resource file reader cannot be opened. |
|
89 |
|
90 @param aResFileName Resource file name |
|
91 */ |
|
92 { |
|
93 TFileName fileName; |
|
94 Dll::FileName(fileName); |
|
95 TParse parse; |
|
96 parse.Set(aResFileName, &fileName, 0); |
|
97 fileName=parse.FullName(); |
|
98 BaflUtils::NearestLanguageFile(iFs, fileName); |
|
99 iResourceFile.OpenL(iFs, fileName); |
|
100 } |
|
101 |
|
102 EXPORT_C void CScheduleBaseServerMtm::ConstructL() |
|
103 /** |
|
104 Second phase constructor. |
|
105 |
|
106 This calls LoadResourceFileL(). |
|
107 |
|
108 The derived class second phase constructor should call this function. It should |
|
109 also construct the iScheduleSend member. |
|
110 |
|
111 @leave Leaves with one of the system-wide error if unable to connect to the |
|
112 file server |
|
113 @leave LoadResourceFileL() |
|
114 */ |
|
115 { |
|
116 User::LeaveIfError(iFs.Connect()); |
|
117 LoadResourceFileL(); |
|
118 } |
|
119 |
|
120 |
|
121 /** |
|
122 Loads all the schedule settings either from CenRep or a resource file. |
|
123 |
|
124 @param aRepository |
|
125 CenRep repository to load settings from |
|
126 |
|
127 @param aRestoreErrorsFromResource |
|
128 Whether to read error handling information (a SEND_ERROR_ACTIONS struct) from a resource file |
|
129 |
|
130 @param aErrorsResourceId |
|
131 Resource ID of the error handling resource struct |
|
132 |
|
133 @see CMsvScheduleSend::RestoreL |
|
134 @see CMsvSendErrorActions::RestoreFromResourceL() |
|
135 |
|
136 @panic ScheduleSend-DLL 24 |
|
137 The context is not a service entry |
|
138 */ |
|
139 EXPORT_C void CScheduleBaseServerMtm::LoadScheduleSettingsL(CRepository& aRepository, TBool aRestoreErrorsFromResource, TInt aErrorsResourceId) |
|
140 { |
|
141 iScheduleSend->LoadScheduleSettingsL(aRepository); |
|
142 |
|
143 if (aRestoreErrorsFromResource) |
|
144 { |
|
145 //Restore the errors from a resource file |
|
146 TResourceReader reader; |
|
147 HBufC8* rBuf = iResourceFile.AllocReadLC(aErrorsResourceId); |
|
148 reader.SetBuffer(rBuf); |
|
149 iScheduleSend->SendErrorActions().RestoreFromResourceL(reader); |
|
150 CleanupStack::PopAndDestroy(); //rBuf |
|
151 } |
|
152 } |
|
153 |
|
154 EXPORT_C void CScheduleBaseServerMtm::ScheduleL(CMsvEntrySelection& aSelection, const TBool aMove, const TDesC8& aParameter, TRequestStatus& aStatus) |
|
155 /** |
|
156 Schedules a message. |
|
157 |
|
158 The functions should schedule a message using CMsvScheduleSend::ScheduleL(). |
|
159 Make sure RestoreScheduleSettingsL() is called before |
|
160 CMsvScheduleSend::ScheduleL(). |
|
161 |
|
162 @param aSelection The selection of messages that need to be scheduled |
|
163 @param aMove Whether to perform a Move (ETrue) or a Copy (EFalse) when sending |
|
164 has completed |
|
165 @param aParameter The parameter (MTM-specific) that is required when sending |
|
166 the messages |
|
167 @param aStatus Asynchronous status word |
|
168 |
|
169 @leave CMsvScheduleSend::ScheduleL() |
|
170 */ |
|
171 { |
|
172 TMsvSchedulePackage package; |
|
173 PopulateSchedulePackage(aParameter, aMove, package); |
|
174 iScheduleSend->ScheduleL(aSelection, package); |
|
175 RequestComplete(&aStatus, KErrNone); |
|
176 } |
|
177 |
|
178 EXPORT_C void CScheduleBaseServerMtm::Queue(TRequestStatus& aStatus) |
|
179 /** |
|
180 Specifies an asynchronous status word to be completed when an asynchronous |
|
181 MTM operation completes. |
|
182 |
|
183 This provides a form of observer functionality. It sets the the iReport |
|
184 member. |
|
185 |
|
186 @param aStatus Asynchronous status word to use |
|
187 |
|
188 @panic ScheduleSend-DLL 28 iReport member not NULL. Debug build only. |
|
189 */ |
|
190 { |
|
191 __ASSERT_DEBUG(iReport==NULL,gPanic(EReportNotNull)); |
|
192 |
|
193 aStatus=KRequestPending; |
|
194 iReport=&aStatus; |
|
195 } |
|
196 |
|
197 EXPORT_C void CScheduleBaseServerMtm::CheckScheduleL(const CMsvEntrySelection& aSelection, const TDesC8& /*aParameter*/, TRequestStatus& aStatus) |
|
198 /** |
|
199 Verifies that the schedule information stored in specified messages |
|
200 is the same as that on the task scheduler. |
|
201 |
|
202 @see CMsvScheduleSend::CheckScheduleL() |
|
203 |
|
204 @param aSelection Array of message IDs that need to be checked against the task scheduler |
|
205 @param aParameter Unused |
|
206 @param aStatus Asynchronous status word |
|
207 |
|
208 @leave CMsvScheduleSend::CheckScheduleL() |
|
209 */ |
|
210 { |
|
211 iScheduleSend->CheckScheduleL(aSelection); |
|
212 RequestComplete(&aStatus, KErrNone); |
|
213 } |
|
214 |
|
215 EXPORT_C void CScheduleBaseServerMtm::DeleteScheduleL(const CMsvEntrySelection& aSelection, const TDesC8& /*aParameter*/, TRequestStatus& aStatus) |
|
216 /** |
|
217 Deletes the schedules for the specified messages from the task scheduler. |
|
218 |
|
219 The messages themselves are not deleted. |
|
220 |
|
221 @see CMsvScheduleSend::DeleteScheduleL() |
|
222 |
|
223 @param aSelection Array of message IDs that need to be deleted from the |
|
224 task scheduler |
|
225 @param aParameter Unused |
|
226 @param aStatus Asynchronous status word |
|
227 |
|
228 @leave CMsvScheduleSend::DeleteScheduleL() |
|
229 */ |
|
230 { |
|
231 iScheduleSend->DeleteScheduleL(aSelection); |
|
232 RequestComplete(&aStatus, KErrNone); |
|
233 } |
|
234 |
|
235 void CScheduleBaseServerMtm::RequestComplete(TRequestStatus* aStatus, TInt aError) |
|
236 { |
|
237 User::RequestComplete(aStatus, aError); |
|
238 } |