|
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 // SmssServ.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "SMSSERV.H" |
|
19 #include "SMSSPAN.H" |
|
20 #include "SMSSOUTB.H" |
|
21 |
|
22 #include <msventry.h> |
|
23 #include <smss.rsg> |
|
24 #include <smscmds.h> |
|
25 #include <smut.h> |
|
26 #include "SMSSchSend.h" |
|
27 #include "SmssSimUtils.h" |
|
28 #include <centralrepository.h> |
|
29 #include <tmsvsystemprogress.h> |
|
30 |
|
31 EXPORT_C CSmsServerMtm* CSmsServerMtm::NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aServerEntry) |
|
32 { |
|
33 CSmsServerMtm* smsservermtm=new(ELeave) CSmsServerMtm(aRegisteredMtmDll, aServerEntry); |
|
34 CleanupStack::PushL(smsservermtm); |
|
35 smsservermtm->ConstructL(); |
|
36 CleanupStack::Pop(); |
|
37 return smsservermtm; |
|
38 } |
|
39 |
|
40 CSmsServerMtm::~CSmsServerMtm() |
|
41 { |
|
42 Cancel(); |
|
43 delete iScheduleSend; |
|
44 delete iOutboxSend; |
|
45 delete iSimUtils; |
|
46 } |
|
47 |
|
48 void CSmsServerMtm::CopyToLocalL(const CMsvEntrySelection& /*aSelection*/,TMsvId /*aDestination*/, TRequestStatus& aStatus) |
|
49 { |
|
50 TRequestStatus* status=&aStatus; |
|
51 User::RequestComplete(status,KErrNotSupported); |
|
52 } |
|
53 |
|
54 void CSmsServerMtm::CopyFromLocalL(const CMsvEntrySelection& aSelection,TMsvId /*aDestination*/, TRequestStatus& aStatus) |
|
55 { |
|
56 __ASSERT_ALWAYS(iServerEntry!=NULL,Panic(ESmssEntryNotSet)); |
|
57 __ASSERT_ALWAYS(!iOutboxSend, Panic(KSmssPanicMtmAlreadyActive)); |
|
58 |
|
59 Queue(aStatus); |
|
60 RestoreSettingsL(); |
|
61 iOutboxSend=CSmsOutboxSend::NewL(*iServerEntry, *iScheduleSend, iFs); |
|
62 iState=ESmsServerMtmSending; |
|
63 #if (defined SYMBIAN_USER_PROMPT_SERVICE) |
|
64 iOutboxSend->StartL(iStatus,aSelection, EFalse, KNullDesC8, iClientThreadId, iHasCapability); |
|
65 #else |
|
66 iOutboxSend->Start(iStatus,aSelection, EFalse, KNullDesC8); |
|
67 #endif |
|
68 SetActive(); |
|
69 } |
|
70 |
|
71 void CSmsServerMtm::CopyWithinServiceL(const CMsvEntrySelection& /*aSelection*/,TMsvId /*aDestination*/, TRequestStatus& aStatus) |
|
72 { |
|
73 TRequestStatus* status=&aStatus; |
|
74 User::RequestComplete(status,KErrNotSupported); |
|
75 } |
|
76 |
|
77 void CSmsServerMtm::MoveToLocalL(const CMsvEntrySelection& /*aSelection*/,TMsvId /*aDestination*/, TRequestStatus& aStatus) |
|
78 { |
|
79 TRequestStatus* status=&aStatus; |
|
80 User::RequestComplete(status,KErrNotSupported); |
|
81 } |
|
82 |
|
83 void CSmsServerMtm::MoveFromLocalL(const CMsvEntrySelection& /*aSelection*/,TMsvId /*aDestination*/, TRequestStatus& aStatus) |
|
84 { |
|
85 TRequestStatus* status=&aStatus; |
|
86 User::RequestComplete(status,KErrNotSupported); |
|
87 } |
|
88 |
|
89 void CSmsServerMtm::MoveWithinServiceL(const CMsvEntrySelection& /*aSelection*/,TMsvId /*aDestination*/, TRequestStatus& aStatus) |
|
90 { |
|
91 TRequestStatus* status=&aStatus; |
|
92 User::RequestComplete(status,KErrNotSupported); |
|
93 } |
|
94 |
|
95 void CSmsServerMtm::DeleteAllL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus) |
|
96 { |
|
97 iProgress = TSmsProgress(); |
|
98 iProgress.iType = TSmsProgress::ESmsProgressTypeDeleteAll; |
|
99 iProgress.iMsgCount = aSelection.Count(); |
|
100 User::LeaveIfError(iServerEntry->SetEntry(aSelection[0])); |
|
101 User::LeaveIfError(iServerEntry->SetEntry(iServerEntry->Entry().Parent())); |
|
102 CMsvEntrySelection* sel = aSelection.CopyL(); |
|
103 iProgress.iError = iServerEntry->DeleteEntries(*sel); |
|
104 delete sel; |
|
105 |
|
106 TRequestStatus* status = &aStatus; |
|
107 User::RequestComplete(status, KErrNone); |
|
108 } |
|
109 |
|
110 void CSmsServerMtm::CreateL(TMsvEntry /*aNewEntry*/, TRequestStatus& aStatus) |
|
111 { |
|
112 TRequestStatus* status=&aStatus; |
|
113 User::RequestComplete(status,KErrNotSupported); |
|
114 } |
|
115 |
|
116 void CSmsServerMtm::ChangeL(TMsvEntry /*aNewEntry*/, TRequestStatus& aStatus) |
|
117 { |
|
118 TRequestStatus* status=&aStatus; |
|
119 User::RequestComplete(status,KErrNotSupported); |
|
120 } |
|
121 |
|
122 void CSmsServerMtm::StartCommandL(CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter, TRequestStatus& aStatus) |
|
123 { |
|
124 __ASSERT_ALWAYS(iServerEntry!=NULL,Panic(ESmssEntryNotSet)); |
|
125 __ASSERT_ALWAYS(iState==ESmsServerMtmWaiting,Panic(KSmssPanicMtmAlreadyActive)); |
|
126 |
|
127 RestoreSettingsL(); |
|
128 iProgress = TSmsProgress(); |
|
129 TInt err = KErrNone; |
|
130 |
|
131 switch (aCommand) |
|
132 { |
|
133 case ESmsMtmCommandScheduleCopy: |
|
134 case ESmsMtmCommandScheduleMove: |
|
135 case ESmsMtmCommandDeleteSchedule: |
|
136 case ESmsMtmCommandCheckSchedule: |
|
137 case ESmsMtmCommandSendScheduledCopy: |
|
138 case ESmsMtmCommandSendScheduledMove: |
|
139 { |
|
140 TRAP(err, ScheduleCommandL(aSelection, aCommand, aParameter, aStatus)); |
|
141 break; |
|
142 } |
|
143 case ESmsMtmCommandEnumeratePhoneStores: |
|
144 case ESmsMtmCommandDeleteFromPhoneStore: |
|
145 case ESmsMtmCommandCopyFromPhoneStore: |
|
146 case ESmsMtmCommandMoveFromPhoneStore: |
|
147 case ESmsMtmCommandReadSimParams: |
|
148 case ESmsMtmCommandWriteSimParams: |
|
149 case ESmsMtmCommandCopyToPhoneStore: |
|
150 case ESmsMtmCommandMoveToPhoneStore: |
|
151 { |
|
152 TRAP(err, SimUtilsL(aSelection, aCommand, aParameter, aStatus)); |
|
153 break; |
|
154 } |
|
155 default: |
|
156 { |
|
157 Panic(KSmssPanicUnexpectedCommand); |
|
158 } |
|
159 } |
|
160 |
|
161 if (err != KErrNone) |
|
162 { |
|
163 iServerEntry->SetEntry(KMsvNullIndexEntryId); |
|
164 User::Leave(err); |
|
165 } |
|
166 } |
|
167 |
|
168 TBool CSmsServerMtm::CommandExpected() |
|
169 { |
|
170 return EFalse; |
|
171 } |
|
172 |
|
173 const TDesC8& CSmsServerMtm::Progress() |
|
174 { |
|
175 switch (iState) |
|
176 { |
|
177 case ESmsServerMtmSending: |
|
178 { |
|
179 iProgress = iOutboxSend->Progress(); |
|
180 break; |
|
181 } |
|
182 case ESmsServerMtmSimUtils: |
|
183 { |
|
184 iProgress = iSimUtils->Progress(); |
|
185 break; |
|
186 } |
|
187 default: |
|
188 { |
|
189 //Do not change iProgress |
|
190 } |
|
191 } |
|
192 |
|
193 iProgressBuf = TSmsProgressBuf(iProgress); |
|
194 return iProgressBuf; |
|
195 } |
|
196 |
|
197 void CSmsServerMtm::DoCancel() |
|
198 { |
|
199 switch (iState) |
|
200 { |
|
201 case ESmsServerMtmSending: |
|
202 { |
|
203 iOutboxSend->Cancel(); |
|
204 break; |
|
205 } |
|
206 case ESmsServerMtmSimUtils: |
|
207 { |
|
208 iSimUtils->Cancel(); |
|
209 break; |
|
210 } |
|
211 case ESmsServerMtmScheduling: |
|
212 { |
|
213 break; |
|
214 } |
|
215 default: |
|
216 { |
|
217 Panic(KSmssPanicUnexpectedCommand); |
|
218 } |
|
219 } |
|
220 CompleteCommand(KErrCancel); |
|
221 } |
|
222 |
|
223 void CSmsServerMtm::DoRunL() |
|
224 { |
|
225 DoComplete(KErrNone); |
|
226 } |
|
227 |
|
228 void CSmsServerMtm::CompleteCommand(TInt aError) |
|
229 { |
|
230 if (iReport) |
|
231 { |
|
232 switch (iState) |
|
233 { |
|
234 case ESmsServerMtmSending: |
|
235 { |
|
236 Progress(); |
|
237 delete iOutboxSend; |
|
238 iOutboxSend=NULL; |
|
239 break; |
|
240 } |
|
241 case ESmsServerMtmScheduling: |
|
242 { |
|
243 break; |
|
244 } |
|
245 case ESmsServerMtmSimUtils: |
|
246 { |
|
247 Progress(); |
|
248 delete iSimUtils; |
|
249 iSimUtils = NULL; |
|
250 break; |
|
251 } |
|
252 default: |
|
253 { |
|
254 Panic(KSmssPanicUnexpectedState); |
|
255 } |
|
256 } |
|
257 if (aError != KErrNone) // iProgress.iError may be recording a send error |
|
258 { |
|
259 iProgress.iError = aError; // so it shouldn't be over-written with KErrNone |
|
260 } |
|
261 |
|
262 User::RequestComplete(iReport, KErrNone); |
|
263 } |
|
264 |
|
265 iState = ESmsServerMtmWaiting; |
|
266 iReport = NULL; |
|
267 |
|
268 if (iServerEntry) |
|
269 iServerEntry->SetEntry(KMsvNullIndexEntryId); //ignore error |
|
270 } |
|
271 |
|
272 void CSmsServerMtm::DoComplete(TInt aError) |
|
273 { |
|
274 CompleteCommand(aError); |
|
275 } |
|
276 |
|
277 CSmsServerMtm::CSmsServerMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aServerEntry): |
|
278 CScheduleBaseServerMtm(aRegisteredMtmDll, aServerEntry) |
|
279 { |
|
280 CActiveScheduler::Add(this); |
|
281 } |
|
282 |
|
283 void CSmsServerMtm::ConstructL() |
|
284 { |
|
285 CScheduleBaseServerMtm::ConstructL(); |
|
286 |
|
287 #if defined (__WINS__) |
|
288 TInt ret=StartC32(); |
|
289 if (ret!=KErrAlreadyExists) |
|
290 User::LeaveIfError(ret); |
|
291 #endif |
|
292 |
|
293 iScheduleSend = CSmsScheduleSend::NewL(*iServerEntry); |
|
294 TSmsUtilities::ServiceIdL(*iServerEntry, iSmsServiceId); |
|
295 RestoreSettingsL(); |
|
296 } |
|
297 |
|
298 void CSmsServerMtm::RestoreSettingsL() |
|
299 { |
|
300 __ASSERT_ALWAYS(iServerEntry!=NULL,Panic(ESmssEntryNotSet)); |
|
301 |
|
302 User::LeaveIfError(iServerEntry->SetEntry(iSmsServiceId)); |
|
303 RestoreScheduleSettingsL(); |
|
304 User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId)); |
|
305 } |
|
306 |
|
307 void CSmsServerMtm::LoadResourceFileL() |
|
308 { |
|
309 CScheduleBaseServerMtm::LoadResourceFileL(KSmsResourceFile); |
|
310 } |
|
311 |
|
312 void CSmsServerMtm::RestoreScheduleSettingsL() |
|
313 { |
|
314 CRepository* repository = CRepository::NewLC(KUidMsgTypeSMS); |
|
315 // just v2 |
|
316 CScheduleBaseServerMtm::LoadScheduleSettingsL(*repository, ETrue, ERROR_ACTIONS); |
|
317 CleanupStack::PopAndDestroy(repository); |
|
318 } |
|
319 |
|
320 void CSmsServerMtm::PopulateSchedulePackage(const TDesC8& aParameter, const TBool aMove, TMsvSchedulePackage& aPackage) const |
|
321 { |
|
322 aPackage.iPollProgress = 3000000; |
|
323 aPackage.iParameter = aParameter; |
|
324 aPackage.iCommandId = aMove ? ESmsMtmCommandSendScheduledMove : ESmsMtmCommandSendScheduledCopy; |
|
325 } |
|
326 |
|
327 void CSmsServerMtm::ScheduleCommandL(CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter, TRequestStatus& aStatus) |
|
328 { |
|
329 iState = ESmsServerMtmScheduling; |
|
330 iProgress.iType = TSmsProgress::ESmsProgressTypeScheduling; |
|
331 |
|
332 switch (aCommand) |
|
333 { |
|
334 case ESmsMtmCommandScheduleCopy: |
|
335 ScheduleL(aSelection, EFalse, aParameter, aStatus); |
|
336 break; |
|
337 case ESmsMtmCommandScheduleMove: |
|
338 { |
|
339 TRequestStatus* status = &aStatus; |
|
340 User::RequestComplete(status, KErrNotSupported); |
|
341 break; |
|
342 } |
|
343 case ESmsMtmCommandDeleteSchedule: |
|
344 iProgress.iType = TSmsProgress::ESmsProgressTypeDeleteSchedule; |
|
345 DeleteScheduleL(aSelection, aParameter, aStatus); |
|
346 break; |
|
347 case ESmsMtmCommandCheckSchedule: |
|
348 iProgress.iType = TSmsProgress::ESmsProgressTypeCheckSchedule; |
|
349 CheckScheduleL(aSelection, aParameter, aStatus); |
|
350 break; |
|
351 case ESmsMtmCommandSendScheduledCopy: |
|
352 SendScheduledL(aSelection, EFalse, aParameter, aStatus); |
|
353 break; |
|
354 case ESmsMtmCommandSendScheduledMove: |
|
355 SendScheduledL(aSelection, ETrue, aParameter, aStatus); |
|
356 break; |
|
357 default: |
|
358 Panic(KSmssPanicUnexpectedCommand); |
|
359 } |
|
360 } |
|
361 |
|
362 void CSmsServerMtm::SimUtilsL(const CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter, TRequestStatus& aStatus) |
|
363 { |
|
364 __ASSERT_DEBUG(iSimUtils == NULL, Panic(KSmssPanicAlreadyUsingSimUtils)); |
|
365 |
|
366 Queue(aStatus); |
|
367 |
|
368 iSimUtils = CSmsSimUtils::NewL(*iServerEntry, iFs, iSmsServiceId); |
|
369 |
|
370 iState = ESmsServerMtmSimUtils; |
|
371 |
|
372 switch (aCommand) |
|
373 { |
|
374 case ESmsMtmCommandEnumeratePhoneStores: |
|
375 iSimUtils->EnumerateL(aParameter, iStatus); |
|
376 break; |
|
377 case ESmsMtmCommandDeleteFromPhoneStore: |
|
378 iSimUtils->DeleteFromPhoneStoreL(aSelection, iStatus); |
|
379 break; |
|
380 case ESmsMtmCommandCopyFromPhoneStore: |
|
381 iSimUtils->CopyFromPhoneStoreL(aSelection, aParameter, iStatus); |
|
382 break; |
|
383 case ESmsMtmCommandMoveFromPhoneStore: |
|
384 iSimUtils->MoveFromPhoneStoreL(aSelection, aParameter, iStatus); |
|
385 break; |
|
386 case ESmsMtmCommandReadSimParams: |
|
387 iSimUtils->ReadSimParamsL(iStatus); |
|
388 break; |
|
389 case ESmsMtmCommandWriteSimParams: |
|
390 iSimUtils->WriteSimParamsL(iStatus); |
|
391 break; |
|
392 case ESmsMtmCommandCopyToPhoneStore: |
|
393 iSimUtils->CopyToPhoneStoreL(aSelection, aParameter, iStatus); |
|
394 break; |
|
395 case ESmsMtmCommandMoveToPhoneStore: |
|
396 iSimUtils->MoveToPhoneStoreL(aSelection, aParameter, iStatus); |
|
397 break; |
|
398 default: |
|
399 Panic(KSmssPanicUnexpectedCommand); |
|
400 } |
|
401 |
|
402 SetActive(); |
|
403 } |
|
404 |
|
405 /** |
|
406 The extension method provides a polymorphic behaviour to call the correct |
|
407 MTM. |
|
408 @param aExtensionId The Uid passed in as KUIDMsgClientThreadInfo to copy the |
|
409 Client Thread Info. |
|
410 @return KErrNone. |
|
411 */ |
|
412 TInt CSmsServerMtm::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1) |
|
413 { |
|
414 switch(aExtensionId) |
|
415 { |
|
416 #if (defined SYMBIAN_USER_PROMPT_SERVICE) |
|
417 case KUIDMsgClientThreadInfo: |
|
418 { |
|
419 iClientThreadId = *(TThreadId*) (a1); |
|
420 iHasCapability = (TBool)*(TInt*)(a0); |
|
421 return KErrNone; |
|
422 } |
|
423 #endif |
|
424 case KUIDMsgMsvSystemProgress: |
|
425 default: |
|
426 { |
|
427 // Chain to base class |
|
428 return CBaseServerMtm::Extension_(aExtensionId, a0, a1); |
|
429 } |
|
430 } |
|
431 } |