|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: biou implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "biou.h" // Class declarations |
|
22 #include "bium.pan" // Panic codes |
|
23 #include "bium.hrh" // Resource Ids |
|
24 |
|
25 #include <bium.rsg> // Resources |
|
26 #include <apgcli.h> |
|
27 #include <eikon.hrh> |
|
28 #include <mtmuidef.hrh> |
|
29 #include <MTMStore.h> |
|
30 #include <msvuids.h> // KUidMsvLocalServiceMtm |
|
31 #include <MtmExtendedCapabilities.hrh> // for KMtmUiNewMessageAction... |
|
32 #include <Muiumsginfo.h> |
|
33 #include <Muiumsginfo.hrh> |
|
34 #include <smuthdr.h> |
|
35 #include <MuiuMsvUiServiceUtilities.h> |
|
36 #include <mmsvattachmentmanagersync.h> |
|
37 #include <mmsvattachmentmanager.h> |
|
38 #include <biouids.h> // KUidBIOMessageTypeMtm... |
|
39 #include <bif.h> // KUidBioUseDefaultApp, KUidBioUseNoApp |
|
40 #include <MsgBioUids.h> // KMsgBioUidPictureMsg |
|
41 #include <aknnotewrappers.h> // CAknInformationNote |
|
42 #include <StringLoader.h> // StringLoader |
|
43 #include <mmsgbiocontrol.h> |
|
44 #include <textresolver.h> |
|
45 #include <gmsModel.h> |
|
46 |
|
47 |
|
48 // Data types |
|
49 class TBioData |
|
50 { |
|
51 public: |
|
52 TUid iTypeUid; |
|
53 TBool iHasParser; |
|
54 TUid iAppUid; |
|
55 TFileName iEditorFileName; |
|
56 }; |
|
57 |
|
58 // Constants |
|
59 _LIT(KBiouMtmUiResourceFile,"bium"); |
|
60 const TInt KParseAndEditOpPriority = CActive::EPriorityStandard; |
|
61 const TInt KArrayGranularity = 8; |
|
62 |
|
63 const TInt KBiumParserWappLeaveFirst = -617; |
|
64 const TInt KBiumParserWappLeaveLast = -601; |
|
65 |
|
66 // this should always be same as KBspInvalidMessage in bsp.h |
|
67 const TInt KBiumParserBspLeave1 = -500; |
|
68 |
|
69 // this should always be same as KBspSmartMessageInvalidToken in bsp.h |
|
70 const TInt KBiumParserBspLeave2 = -501; |
|
71 |
|
72 const TUid KBiouMtmUiSMSViewerAppUid={0x100058BD}; // Uid for SMS Viewer application |
|
73 |
|
74 // This is cloned from smuthdr.cpp, KUidMsvSMSHeaderStream |
|
75 const TUid KBiumUidMsvSMSHeaderStream = {0x10001834}; |
|
76 |
|
77 // maximum amount of characters used for GSM message subject |
|
78 const TInt KMaxSubjectLength = 30; |
|
79 |
|
80 const TInt KTypeStringLength = 32; |
|
81 |
|
82 // Reserve 3 chars for ' ', '<' and '>'. |
|
83 const TInt KCharacterReserve = 3; |
|
84 |
|
85 _LIT(KNotDefinedBium,"@todo Not defined. BIUM."); |
|
86 |
|
87 GLDEF_C void Panic(TBioUiPanic aPanic) |
|
88 { |
|
89 _LIT(KPanicName,"BioUi"); |
|
90 User::Panic(KPanicName, aPanic); |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CBioMtmUi::NewL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CBioMtmUi* CBioMtmUi::NewL(CBaseMtm& aBaseMtm, |
|
99 CRegisteredMtmDll& aRegisteredMtmDll) |
|
100 { |
|
101 CBioMtmUi* self=new(ELeave) CBioMtmUi(aBaseMtm, aRegisteredMtmDll); |
|
102 CleanupStack::PushL(self); |
|
103 self->ConstructL(); |
|
104 CleanupStack::Pop(self); |
|
105 return self; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CBioMtmUi::CBioMtmUi |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CBioMtmUi::CBioMtmUi(CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll) |
|
113 : CBaseMtmUi(aBaseMtm, aRegisteredMtmDll) |
|
114 { |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CBioMtmUi::ConstructL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CBioMtmUi::ConstructL() |
|
122 { |
|
123 // --- Make sure base class correctly constructed --- |
|
124 CBaseMtmUi::ConstructL(); |
|
125 |
|
126 // For Crystal 6.0, msg editors are standalone. |
|
127 // Don't run them embedded, and don't wait for them to exit. |
|
128 iFlags=EMtmUiFlagEditorNoWaitForExit; |
|
129 |
|
130 // Read in data from BIF |
|
131 ResetAndLoadBioDataL(); |
|
132 |
|
133 iErrorResolver = CTextResolver::NewL(*iCoeEnv); |
|
134 |
|
135 iBifObserver=CBifChangeObserver::NewL(*this,iCoeEnv->FsSession()); |
|
136 iBifObserver->Start(); |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CBioMtmUi::~CBioMtmUi |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 CBioMtmUi::~CBioMtmUi() |
|
144 { |
|
145 delete iBioData; |
|
146 delete iErrorResolver; |
|
147 if(iBifObserver) |
|
148 { |
|
149 iBifObserver->Cancel(); |
|
150 } |
|
151 delete iBifObserver; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CBioMtmUi::ResetAndLoadBioDataL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CBioMtmUi::ResetAndLoadBioDataL() |
|
159 { |
|
160 // Reset |
|
161 delete iBioData; |
|
162 iBioData = NULL; |
|
163 |
|
164 // --- Load in only the data we need from BioDatabase --- |
|
165 iBioData = new(ELeave) CArrayFixFlat<TBioData>(KArrayGranularity); |
|
166 CBIODatabase* bioDatabase = CBIODatabase::NewLC(iCoeEnv->FsSession()); |
|
167 TBioData bioData; |
|
168 |
|
169 const TInt bifCount = bioDatabase->BIOCount(); |
|
170 iBioData->SetReserveL(bifCount); // this can be left out |
|
171 for(TInt bifIndex = 0;bifIndex<bifCount;bifIndex++) |
|
172 { |
|
173 bioData.iTypeUid = (bioDatabase->BifReader(bifIndex)).MessageTypeUid(); |
|
174 bioData.iHasParser = ( |
|
175 (bioDatabase->BifReader(bifIndex)).MessageParserName().Length() > 0 ) ? |
|
176 ETrue : |
|
177 EFalse; |
|
178 bioData.iAppUid = (bioDatabase->BifReader(bifIndex)).MessageAppUid(); |
|
179 // Only resolve filename when we have to... |
|
180 bioData.iEditorFileName = KNullDesC; |
|
181 iBioData->AppendL(bioData); |
|
182 } |
|
183 |
|
184 CleanupStack::PopAndDestroy(bioDatabase); // bioDatabase |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CBioMtmUi::HandleBifChangeL |
|
189 // from MBifChangeObserver |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CBioMtmUi::HandleBifChangeL(TBifChangeEvent /*aEvent*/, TUid /*aBioId*/) |
|
193 { |
|
194 ResetAndLoadBioDataL(); |
|
195 } |
|
196 |
|
197 // |
|
198 // Entry creation |
|
199 // |
|
200 // Not supported as BIO messages can not be sent. |
|
201 CMsvOperation* CBioMtmUi::CreateL(const TMsvEntry& /*aEntry*/, |
|
202 CMsvEntry& /*aParent*/, TRequestStatus& /*aStatus*/) |
|
203 { |
|
204 User::Leave(KErrNotSupported); |
|
205 return NULL; // Execution should not get here. This keeps compiler happy. |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CBioMtmUi::OpenL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 CMsvOperation* CBioMtmUi::OpenL(TRequestStatus& aStatus) |
|
213 { |
|
214 // |
|
215 // Validate context |
|
216 CheckEntryL(BaseMtm().Entry().Entry()); |
|
217 |
|
218 // |
|
219 // Context must be a BIO message, so view it.. |
|
220 return ViewL(aStatus); |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CBioMtmUi::OpenL |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 CMsvOperation* CBioMtmUi::OpenL( |
|
228 TRequestStatus& aStatus, const CMsvEntrySelection& aSelection) |
|
229 { |
|
230 // Set up context as 1st message in selection |
|
231 BaseMtm().SwitchCurrentEntryL(aSelection.At(0)); |
|
232 return OpenL(aStatus); // View message |
|
233 } |
|
234 |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CBioMtmUi::CloseL |
|
238 // Not supported as you can only close services and BIO does not have services. |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 CMsvOperation* CBioMtmUi::CloseL(TRequestStatus& /*aStatus*/) |
|
242 { |
|
243 User::Leave(KErrNotSupported); |
|
244 // Execution should not get here. This keeps compiler happy. |
|
245 return NULL; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CBioMtmUi::CloseL |
|
250 // Not supported as you can only close services and BIO does not have services. |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 CMsvOperation* CBioMtmUi::CloseL( |
|
254 TRequestStatus& /*aStatus*/, const CMsvEntrySelection& /*aSelection*/) |
|
255 { |
|
256 User::Leave(KErrNotSupported); |
|
257 // Execution should not get here. This keeps compiler happy. |
|
258 return NULL; |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CBioMtmUi::EditL |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 CMsvOperation* CBioMtmUi::EditL(TRequestStatus& aStatus) |
|
266 { |
|
267 // Will leave if context is not a BIO message |
|
268 CheckEntryL(BaseMtm().Entry().Entry()); |
|
269 return LaunchApplicationL(aStatus,EFalse); |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CBioMtmUi::EditL |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 CMsvOperation* CBioMtmUi::EditL( |
|
277 TRequestStatus& aStatus, const CMsvEntrySelection& aSelection) |
|
278 { |
|
279 // Set up context as 1st message in selection |
|
280 BaseMtm().SwitchCurrentEntryL(aSelection.At(0)); |
|
281 return EditL(aStatus); |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CBioMtmUi::ViewL |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 CMsvOperation* CBioMtmUi::ViewL(TRequestStatus& aStatus) |
|
289 { |
|
290 // Will leave if context is not a BIO message |
|
291 CheckEntryL(BaseMtm().Entry().Entry()); |
|
292 return LaunchApplicationL(aStatus,ETrue); |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CBioMtmUi::ViewL |
|
297 // Views only first in the selection |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 CMsvOperation* CBioMtmUi::ViewL( |
|
301 TRequestStatus& aStatus,const CMsvEntrySelection& aSelection) |
|
302 { |
|
303 // Set up context as 1st message in selection |
|
304 BaseMtm().SwitchCurrentEntryL(aSelection.At(0)); |
|
305 return ViewL(aStatus); |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CBioMtmUi::CancelL |
|
310 // Currently this function only used to suspend messages queued for sending. |
|
311 // Can't send BIO messages, so can't cancel them either. |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 CMsvOperation* CBioMtmUi::CancelL( |
|
315 TRequestStatus& /*aStatus*/, const CMsvEntrySelection& /*aSelection*/) |
|
316 { |
|
317 User::Leave(KErrNotSupported); |
|
318 // Execution should not get here. This keeps compiler happy. |
|
319 return NULL; |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CBioMtmUi::CopyToL |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 CMsvOperation* CBioMtmUi::CopyToL(const CMsvEntrySelection& /*aSelection*/, |
|
327 TRequestStatus& /*aStatus*/) |
|
328 { |
|
329 // Context should be MTM folder/service to copy to |
|
330 User::Leave(KErrNotSupported); |
|
331 // Execution should not get here. This keeps compiler happy. |
|
332 return NULL; |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CBioMtmUi::MoveToL |
|
337 // Not supported as BIO folders are not supported. |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 CMsvOperation* CBioMtmUi::MoveToL(const CMsvEntrySelection& /*aSelection*/, |
|
341 TRequestStatus& /*aStatus*/) |
|
342 { |
|
343 // Context should be MTM folder/service to move to |
|
344 User::Leave(KErrNotSupported); |
|
345 // Execution should not get here. This keeps compiler happy. |
|
346 return NULL; |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CBioMtmUi::CopyFromL |
|
351 // Not supported as BIO folders are not supported. |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 CMsvOperation* CBioMtmUi::CopyFromL(const CMsvEntrySelection& /*aSelection*/, |
|
355 TMsvId /*aTargetId*/, TRequestStatus& /*aStatus*/) |
|
356 { |
|
357 User::Leave(KErrNotSupported); |
|
358 return NULL; // Execution should not get here. This keeps compiler happy. |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CBioMtmUi::MoveFromL |
|
363 // Not supported as BIO folders are not supported. |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 CMsvOperation* CBioMtmUi::MoveFromL(const CMsvEntrySelection& /*aSelection*/, |
|
367 TMsvId /*aTargetId*/, TRequestStatus& /*aStatus*/) |
|
368 { |
|
369 User::Leave(KErrNotSupported); |
|
370 return NULL; // Execution should not get here. This keeps compiler happy. |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CBioMtmUi::ReplyL |
|
375 // Not supported as BIO does not support sending of messages |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 CMsvOperation* CBioMtmUi::ReplyL(TMsvId /*aDestination*/, |
|
379 TMsvPartList /*aPartlist*/, TRequestStatus& /*aCompletionStatus*/) |
|
380 { |
|
381 User::Leave(KErrNotSupported); |
|
382 return NULL; // Execution should not get here. This keeps compiler happy. |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CBioMtmUi::ForwardL |
|
387 // Not supported as BIO does not support sending of messages |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 CMsvOperation* CBioMtmUi::ForwardL(TMsvId /*aDestination*/, |
|
391 TMsvPartList /*aPartList*/, TRequestStatus& /*aCompletionStatus*/) |
|
392 { |
|
393 User::Leave(KErrNotSupported); |
|
394 return NULL; // Execution should not get here. This keeps compiler happy. |
|
395 } |
|
396 |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CBioMtmUi::DeleteFromL |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 CMsvOperation* CBioMtmUi::DeleteFromL(const CMsvEntrySelection& /*aSelection*/, |
|
403 TRequestStatus& /*aStatus*/) |
|
404 { |
|
405 User::Leave(KErrNotSupported); |
|
406 return NULL; // Execution should not get here. This keeps compiler happy. |
|
407 } |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // CBioMtmUi::DeleteServiceL |
|
411 // Bio services not supported |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 CMsvOperation* CBioMtmUi::DeleteServiceL(const TMsvEntry& /*aService*/, |
|
415 TRequestStatus& /*aStatus*/) |
|
416 { |
|
417 User::Leave(KErrNotSupported); |
|
418 return NULL; // Execution should not get here. This keeps compiler happy. |
|
419 } |
|
420 |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CBioMtmUi::QueryCapability |
|
424 // RTTI functions |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 TInt CBioMtmUi::QueryCapability(TUid aCapability, TInt& aResponse) |
|
428 { |
|
429 if (aCapability.iUid == KUidMsvMtmQueryMessageInfo ) |
|
430 { |
|
431 aResponse = ETrue; |
|
432 return KErrNone; |
|
433 } |
|
434 return CBaseMtmUi::QueryCapability(aCapability, aResponse); |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // CBioMtmUi::InvokeAsyncFunctionL |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 // RTTI functions |
|
442 CMsvOperation* CBioMtmUi::InvokeAsyncFunctionL(TInt aFunctionId, |
|
443 const CMsvEntrySelection& aSelection, TRequestStatus& aCompletionStatus, |
|
444 TDes8& aParameter) |
|
445 { |
|
446 if(aFunctionId == KMtmUiFunctionMessageInfo) |
|
447 return ShowMessageInfoL(aCompletionStatus, aParameter); |
|
448 |
|
449 return CBaseMtmUi::InvokeAsyncFunctionL( |
|
450 aFunctionId, aSelection, aCompletionStatus, aParameter); |
|
451 } |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // CBioMtmUi::ShowMessageInfoL |
|
455 // ----------------------------------------------------------------------------- |
|
456 // |
|
457 CMsvOperation* CBioMtmUi::ShowMessageInfoL(TRequestStatus& aCompletionStatus, |
|
458 TDes8& /*aParameter*/) |
|
459 // |
|
460 // gathers the data to populate the info data array from the mtm and then |
|
461 // uses the messge info dialog class to display the data; |
|
462 // only used for viewing bio messages, the smum mtm is actually used for |
|
463 // creating bio messages |
|
464 // |
|
465 { |
|
466 BaseMtm().LoadMessageL(); |
|
467 const TMsvEntry& tentry=BaseMtm().Entry().Entry(); |
|
468 |
|
469 TMsgInfoMessageInfoData infoData; |
|
470 |
|
471 //show subject if GMS message (picture message) |
|
472 if (tentry.iBioType == KMsgBioUidPictureMsg.iUid) |
|
473 { |
|
474 HBufC* gmsTitle = ExtractTitleFromGMSBodyL(BaseMtm().Body(), |
|
475 KMaxSubjectLength); |
|
476 CleanupStack::PushL(gmsTitle); |
|
477 infoData.iSubject.Set(*gmsTitle); |
|
478 } |
|
479 |
|
480 //date |
|
481 infoData.iDateTime = tentry.iDate; |
|
482 |
|
483 //type |
|
484 TInt resourceId( KErrNotFound ); |
|
485 |
|
486 if ( tentry.iBioType == KMsgBioUidVCard.iUid || |
|
487 tentry.iBioType == KMsgBioUidCompBusCard.iUid ) |
|
488 { |
|
489 resourceId = R_QTN_SM_INFO_BUSINESS_CARD; |
|
490 } |
|
491 else if ( tentry.iBioType == KMsgBioUidVCalendar.iUid ) |
|
492 { |
|
493 resourceId = R_QTN_SM_INFO_CALENDAR; |
|
494 } |
|
495 else if ( tentry.iBioType == KMsgBioUidIAC.iUid || |
|
496 tentry.iBioType == KMsgBioUidWmlBrSettings.iUid || |
|
497 tentry.iBioType == KMsgBioUidWVSettings.iUid ) |
|
498 { |
|
499 resourceId = R_QTN_SM_TITLE_CONFIGURATION; |
|
500 } |
|
501 else if ( tentry.iBioType == KMsgBioUidPictureMsg.iUid ) |
|
502 { |
|
503 resourceId = R_QTN_SM_INFO_GMS; |
|
504 } |
|
505 else if ( tentry.iBioType == KMsgBioUidEmailNotif.iUid ) |
|
506 { |
|
507 resourceId = R_QTN_SM_INFO_EMAIL_NOTIFICATION; |
|
508 } |
|
509 else if ( tentry.iBioType == KMsgBioUidRingingTone.iUid ) |
|
510 { |
|
511 resourceId = R_QTN_SM_INFO_RINGING_TONE; |
|
512 } |
|
513 else if ( tentry.iBioType == KMsgBioUidOperatorLogo.iUid ) |
|
514 { |
|
515 resourceId = R_QTN_SM_INFO_OPERATOR_LOGO; |
|
516 } |
|
517 else if ( tentry.iBioType == KMsgBioUidSyncML.iUid ) |
|
518 { |
|
519 resourceId = R_QTN_SM_INFO_SYNC_PROFILE; |
|
520 } |
|
521 else |
|
522 { |
|
523 // Don't change the resourceId |
|
524 } |
|
525 |
|
526 TBuf<KTypeStringLength> typeString; |
|
527 if ( resourceId != KErrNotFound ) |
|
528 { |
|
529 HBufC* type = iEikonEnv->AllocReadResourceLC( resourceId ); |
|
530 typeString = *type; |
|
531 infoData.iType.Set( typeString ); |
|
532 CleanupStack::PopAndDestroy( type ); |
|
533 } |
|
534 else |
|
535 { |
|
536 infoData.iType.Set(tentry.iDescription); |
|
537 } |
|
538 |
|
539 //from |
|
540 HBufC* from = CreateFromTextLC(BaseMtm().Entry()); |
|
541 infoData.iFrom.Set(*from); |
|
542 |
|
543 CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL(); |
|
544 infoDialog->ExecuteLD(infoData,CMsgInfoMessageInfoDialog::EBiosViewer); |
|
545 CleanupStack::PopAndDestroy(from); |
|
546 if (tentry.iBioType == KMsgBioUidPictureMsg.iUid) |
|
547 { |
|
548 CleanupStack::PopAndDestroy(); //gmsTitle |
|
549 } |
|
550 return CMsvCompletedOperation::NewL(Session(), KUidMsvLocalServiceMtm, |
|
551 KNullDesC8, KMsvLocalServiceIndexEntryId, aCompletionStatus, KErrNone); |
|
552 } |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // CBioMtmUi::ExtractTitleFromGMSBodyL |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 HBufC* CBioMtmUi::ExtractTitleFromGMSBodyL(const CRichText& aBody, |
|
559 TInt aMaxLength) |
|
560 { |
|
561 CGmsModel* model = CGmsModel::NewL(CCoeEnv::Static()->FsSession(), |
|
562 KErrCorrupt); |
|
563 CleanupStack::PushL(model); |
|
564 model->ImportGMSL(aBody); |
|
565 HBufC* text = model->TextAsHBufC16LC(); |
|
566 HBufC* result = NULL; |
|
567 if (text->Length() <= aMaxLength) |
|
568 { |
|
569 result = text->AllocL(); |
|
570 } |
|
571 else |
|
572 { |
|
573 // length is greater than max |
|
574 result = text->Left(aMaxLength).AllocL(); |
|
575 } |
|
576 CleanupStack::PopAndDestroy(text); |
|
577 CleanupStack::PopAndDestroy(model); |
|
578 return result; |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CBioMtmUi::ShowInvalidMsgNote |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 void CBioMtmUi::ShowInvalidMsgNote() const |
|
586 { |
|
587 TRAP_IGNORE( |
|
588 { |
|
589 CAknInformationNote* note = new (ELeave) CAknInformationNote; |
|
590 HBufC* text = |
|
591 StringLoader::LoadLC(R_QTN_MCE_INFO_MESSAGE_NOT_OPENED); |
|
592 note->ExecuteLD(*text); |
|
593 CleanupStack::PopAndDestroy(text); |
|
594 } ); |
|
595 } |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CBioMtmUi::ShowSystemErrorNote |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CBioMtmUi::ShowSystemErrorNote(TInt aError) const |
|
602 { |
|
603 TRAP_IGNORE( |
|
604 { |
|
605 const TDesC& error = iErrorResolver->ResolveErrorString( aError ); |
|
606 CAknErrorNote* note = new (ELeave) CAknErrorNote(); |
|
607 note->ExecuteLD(error); |
|
608 } ); |
|
609 } |
|
610 |
|
611 // ----------------------------------------------------------------------------- |
|
612 // CBioMtmUi::InvokeSyncFunctionL |
|
613 // ----------------------------------------------------------------------------- |
|
614 // |
|
615 void CBioMtmUi::InvokeSyncFunctionL(TInt aFunctionId, |
|
616 const CMsvEntrySelection& aSelection, TDes8& aParameter) |
|
617 { |
|
618 // |
|
619 // Delegate to client MTM |
|
620 CBaseMtmUi::InvokeSyncFunctionL(aFunctionId, aSelection, aParameter); |
|
621 } |
|
622 |
|
623 // ----------------------------------------------------------------------------- |
|
624 // CBioMtmUi::GetResourceFileName |
|
625 // Utility |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 void CBioMtmUi::GetResourceFileName(TFileName& aFileName) const |
|
629 { |
|
630 aFileName=KBiouMtmUiResourceFile; |
|
631 } |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // CBioMtmUi::GetProgress |
|
635 // Progress interpretation |
|
636 // ----------------------------------------------------------------------------- |
|
637 // |
|
638 TInt CBioMtmUi::GetProgress( |
|
639 const TDesC8& aProgress, |
|
640 TBuf<EProgressStringMaxLen>& aReturnString, |
|
641 TInt& aTotalEntryCount, TInt& aEntriesDone, |
|
642 TInt& aCurrentEntrySize, TInt& aCurrentBytesTrans) const |
|
643 { |
|
644 TInt error=KErrNone; |
|
645 |
|
646 // |
|
647 // Intialise return data... |
|
648 aReturnString.Zero(); |
|
649 aReturnString.Append(KNotDefinedBium); |
|
650 aTotalEntryCount=0; |
|
651 aEntriesDone=0; |
|
652 aCurrentEntrySize=0; |
|
653 aCurrentBytesTrans=0; |
|
654 |
|
655 if (!aProgress.Length()) |
|
656 return KErrNone; |
|
657 |
|
658 const TInt progressType=ProgressType(aProgress); |
|
659 |
|
660 // Handle any extra Engine/Local specific stuff |
|
661 if(IsLocalProgress(progressType)) |
|
662 { |
|
663 // |
|
664 // Unpack the progress |
|
665 TPckgBuf<TBioUiProgress> paramPack; |
|
666 paramPack.Copy(aProgress); |
|
667 TBioUiProgress progress(paramPack()); |
|
668 |
|
669 error=progress.iError; |
|
670 } |
|
671 else |
|
672 { |
|
673 // |
|
674 // Unpack the progress |
|
675 TPckgBuf<TBioProgress> paramPack; |
|
676 paramPack.Copy(aProgress); |
|
677 TBioProgress progress(paramPack()); |
|
678 |
|
679 error=progress.iErrorCode; |
|
680 } |
|
681 |
|
682 return error; |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // CBioMtmUi::ProgressType |
|
687 // ----------------------------------------------------------------------------- |
|
688 // |
|
689 // Decode progress type from progress package |
|
690 TInt CBioMtmUi::ProgressType(const TDesC8& aProgress) const |
|
691 { |
|
692 TPckgC<TInt> type(0); // Progress type is the first TInt in the buffer. |
|
693 type.Set(aProgress.Left(sizeof(TInt))); |
|
694 const TInt progressType = type(); |
|
695 |
|
696 __ASSERT_DEBUG( IsEngineProgress(progressType) || |
|
697 IsLocalProgress(progressType), Panic(EBioMtmUiUnknownOperation)); |
|
698 |
|
699 return progressType; |
|
700 } |
|
701 |
|
702 // ----------------------------------------------------------------------------- |
|
703 // CBioMtmUi::IsLocalProgress |
|
704 // Check if progress is local engine side |
|
705 // ----------------------------------------------------------------------------- |
|
706 // |
|
707 TBool CBioMtmUi::IsLocalProgress(TInt aProgressType) const |
|
708 { |
|
709 return(aProgressType==TBioUiProgress::EBioMtmUiEditing || |
|
710 aProgressType==TBioUiProgress::EBioMtmUiParseAndEdit); |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CBioMtmUi::IsEngineProgress |
|
715 // Check if progress is from engine side |
|
716 // (ie. if it is of type TBioUiProgress) |
|
717 // ----------------------------------------------------------------------------- |
|
718 // |
|
719 TBool CBioMtmUi::IsEngineProgress(TInt aProgressType) const |
|
720 { |
|
721 return(aProgressType==TBioProgress::EBiosWaiting || |
|
722 aProgressType==TBioProgress::EBiosCreating || |
|
723 aProgressType==TBioProgress::EBiosParsing || |
|
724 aProgressType==TBioProgress::EBiosProcessing); |
|
725 } |
|
726 |
|
727 // ----------------------------------------------------------------------------- |
|
728 // CBioMtmUi::DisplayProgressSummary |
|
729 // Progress interpretation and display |
|
730 // ----------------------------------------------------------------------------- |
|
731 // |
|
732 TInt CBioMtmUi::DisplayProgressSummary(const TDesC8& aProgress) const |
|
733 { |
|
734 TInt err = KErrNone; |
|
735 |
|
736 if (!aProgress.Length()) |
|
737 return KErrNone; |
|
738 |
|
739 const TInt progressType=ProgressType(aProgress); |
|
740 |
|
741 if(IsEngineProgress(progressType)) |
|
742 { |
|
743 // |
|
744 // Handle Engine side progress |
|
745 TPckgBuf<TBioProgress> paramPack; |
|
746 paramPack.Copy(aProgress); |
|
747 TBioProgress progress(paramPack()); |
|
748 err = progress.iErrorCode; |
|
749 if (err == KErrNone) |
|
750 { |
|
751 return KErrNone; |
|
752 } |
|
753 |
|
754 // These are the leave codes that originate from the symbian |
|
755 // parsers and one other parser. |
|
756 if (err == KErrMsgBioMessageNotValid |
|
757 || (KBiumParserWappLeaveFirst <= err && err <= KBiumParserWappLeaveLast) |
|
758 || err == KBiumParserBspLeave1 |
|
759 || err == KBiumParserBspLeave2) |
|
760 { |
|
761 ShowInvalidMsgNote(); |
|
762 } |
|
763 else |
|
764 { |
|
765 ShowSystemErrorNote(err); |
|
766 } |
|
767 } |
|
768 else |
|
769 { |
|
770 // |
|
771 // Handle UI side progress |
|
772 TPckgBuf<TBioUiProgress> paramPack; |
|
773 paramPack.Copy(aProgress); |
|
774 TBioUiProgress progress(paramPack()); |
|
775 err = progress.iError; |
|
776 if (err == KErrNone) |
|
777 { |
|
778 return KErrNone; |
|
779 } |
|
780 if (err == KErrMsgBioMessageNotValid) |
|
781 { |
|
782 ShowInvalidMsgNote(); |
|
783 } |
|
784 else if( err != KLeaveWithoutAlert ) |
|
785 { |
|
786 ShowSystemErrorNote(err); |
|
787 } |
|
788 } |
|
789 return err; |
|
790 } |
|
791 |
|
792 // ----------------------------------------------------------------------------- |
|
793 // CBioMtmUi::LaunchApplicationL |
|
794 // Utility specific to CBioMtmUi |
|
795 // ----------------------------------------------------------------------------- |
|
796 // |
|
797 CMsvOperation* CBioMtmUi::LaunchApplicationL( |
|
798 TRequestStatus& aStatus,TBool aReadOnly ) |
|
799 { |
|
800 const TMsvEntry& tentry=BaseMtm().Entry().Entry(); |
|
801 |
|
802 // Locate BioData for given bio message type |
|
803 TUid msgTypeUid={tentry.iBioType}; |
|
804 const TInt bioDataCount=iBioData->Count(); |
|
805 |
|
806 TBioData* bioData=NULL; |
|
807 |
|
808 |
|
809 for(TInt n=0;n<bioDataCount;n++) |
|
810 { |
|
811 if((iBioData->At(n)).iTypeUid==msgTypeUid) |
|
812 { |
|
813 bioData=&(iBioData->At(n)); |
|
814 break; |
|
815 } |
|
816 } |
|
817 |
|
818 // If we have no data for this bio message type then complete. |
|
819 if(!bioData) |
|
820 { |
|
821 //the TBioUiProgress transmits the error code to |
|
822 //DisplayProgressSummary(..) to be handled there |
|
823 TBioUiProgress progress; |
|
824 progress.iType=TBioUiProgress::EBioMtmUiParseAndEdit; |
|
825 progress.iError=KErrMsgBioMessageNotValid; |
|
826 TPckgBuf<TBioUiProgress> progressPckg(progress); |
|
827 |
|
828 // Mark entry as read |
|
829 CMsvEntry* entry = Session().GetEntryL(tentry.Id()); |
|
830 CleanupStack::PushL(entry); |
|
831 TMsvEntry tEntry(entry->Entry()); |
|
832 tEntry.SetUnread(EFalse); |
|
833 tEntry.SetNew(EFalse); |
|
834 entry->ChangeL(tEntry); |
|
835 CleanupStack::PopAndDestroy(entry); |
|
836 return CMsvCompletedOperation::NewL( |
|
837 Session(), |
|
838 Type(), |
|
839 progressPckg, |
|
840 KMsvLocalServiceIndexEntryId, |
|
841 aStatus, KErrNone); |
|
842 } |
|
843 |
|
844 // If requested to launch default app, then set correct uid |
|
845 if(bioData->iAppUid == KUidBioUseDefaultApp) |
|
846 { |
|
847 bioData->iAppUid = KBiouMtmUiSMSViewerAppUid; |
|
848 } |
|
849 |
|
850 // If app filename has not been resolved AND we need to resolve it, |
|
851 // then try to resolve it now |
|
852 if(bioData->iEditorFileName==KNullDesC && |
|
853 bioData->iAppUid!=KUidBioUseNoApp) |
|
854 { |
|
855 RApaLsSession appList; |
|
856 User::LeaveIfError(appList.Connect()); |
|
857 CleanupClosePushL(appList); |
|
858 TApaAppInfo info; |
|
859 TInt err = appList.GetAppInfo(info,bioData->iAppUid); |
|
860 CleanupStack::PopAndDestroy(); // appList |
|
861 if(err!=KErrNone) |
|
862 { |
|
863 TBufC8<1> buf; |
|
864 // Mark as read |
|
865 CMsvEntry* entry = Session().GetEntryL(tentry.Id()); |
|
866 CleanupStack::PushL(entry); |
|
867 TMsvEntry tEntry(entry->Entry()); |
|
868 tEntry.SetUnread(EFalse); |
|
869 tEntry.SetNew(EFalse); |
|
870 entry->ChangeL(tEntry); |
|
871 CleanupStack::PopAndDestroy(entry); |
|
872 return CMsvCompletedOperation::NewL( |
|
873 Session(), |
|
874 Type(), |
|
875 buf, |
|
876 KMsvLocalServiceIndexEntryId, |
|
877 aStatus, KErrNone); |
|
878 } |
|
879 bioData->iEditorFileName = info.iFullName; |
|
880 } |
|
881 |
|
882 if ( tentry.iMtmData3 == 0 ) //Entry not parsed yet |
|
883 { |
|
884 if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
885 Session(), |
|
886 tentry.iSize ) ) |
|
887 { |
|
888 User::Leave( KErrDiskFull ); |
|
889 } |
|
890 } |
|
891 |
|
892 // |
|
893 // Parse message (if needed) then launch application (if needed)... |
|
894 // |
|
895 TBuf8<1> blankParams; |
|
896 CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection(); |
|
897 CleanupStack::PushL(sel); |
|
898 // Message Server will use UID of 1st message to load in MTM server. |
|
899 sel->AppendL(tentry.Id()); |
|
900 // BIO Server MTM will use 2nd message to actually parse. |
|
901 sel->AppendL(tentry.Id()); |
|
902 |
|
903 // |
|
904 // Create parameters for parseAndEdit operation |
|
905 TParseAndEditParams params; |
|
906 if(bioData->iAppUid==KUidBioUseNoApp) |
|
907 { |
|
908 // If we have not been asked to launch an app |
|
909 params.iLaunchApp=EFalse; |
|
910 // Set the entry id also here. Needed in SetEntryReadAndOldL. |
|
911 params.iEditorParams.iId=tentry.Id(); |
|
912 } |
|
913 else |
|
914 { |
|
915 params.iLaunchApp=ETrue; |
|
916 params.iPreferEmbedded = ( |
|
917 Preferences() & EMtmUiFlagEditorPreferEmbedded ); |
|
918 params.iEditorFileName=bioData->iEditorFileName; |
|
919 // Kick off app with current context id |
|
920 params.iEditorParams.iId=tentry.Id(); |
|
921 params.iEditorParams.iFlags |= ( |
|
922 Preferences() & |
|
923 EMtmUiFlagEditorPreferEmbedded ? |
|
924 EMsgLaunchEditorEmbedded : |
|
925 0 ); |
|
926 |
|
927 params.iEditorParams.iFlags |= ( |
|
928 Preferences() & EMtmUiFlagEditorNoWaitForExit ? |
|
929 0 : |
|
930 EMsgLaunchEditorThenWait ); |
|
931 |
|
932 params.iEditorParams.iSpecialAppId = bioData->iAppUid; |
|
933 if(aReadOnly) |
|
934 params.iEditorParams.iFlags|=EMsgReadOnly; |
|
935 } |
|
936 |
|
937 // Create ParseAndEdit operation |
|
938 CParseAndEditOp* parseAndEdit = |
|
939 CParseAndEditOp::NewL( Session(), aStatus, params ); |
|
940 CleanupStack::PushL( parseAndEdit ); |
|
941 |
|
942 // |
|
943 // Create Parse or ParseAndProcess operation, |
|
944 // for giving to ParseAndEdit operation |
|
945 // Check that message is of correct type for calling Bio Server MTM, |
|
946 // if it's not then there is not much we can do |
|
947 // (so create a completed operation). |
|
948 // This condition also ensures that we do not parse messages |
|
949 // which are due for sending. |
|
950 CMsvOperation* parseOp; |
|
951 if(tentry.iMtm==KUidBIOMessageTypeMtm && bioData->iHasParser) |
|
952 { |
|
953 if(params.iLaunchApp) |
|
954 parseOp=CBaseMtmUi::InvokeAsyncFunctionL(KBiosMtmParse, |
|
955 *sel,parseAndEdit->RequestStatus(),blankParams); |
|
956 else |
|
957 parseOp=CBaseMtmUi::InvokeAsyncFunctionL(KBiosMtmParseThenProcess, |
|
958 *sel,parseAndEdit->RequestStatus(),blankParams); |
|
959 } |
|
960 else |
|
961 { |
|
962 //the TBioUiProgress transmits the error code to |
|
963 //DisplayProgressSummary(..) to be handled there |
|
964 TBioUiProgress progress; |
|
965 if(bioData->iEditorFileName==KNullDesC |
|
966 && bioData->iAppUid==KUidBioUseNoApp |
|
967 && ( ! bioData->iHasParser ) |
|
968 && bioData->iTypeUid != KUidBioUseNoApp) |
|
969 { |
|
970 progress.iError=KErrMsgBioMessageNotValid; |
|
971 } |
|
972 else |
|
973 { |
|
974 progress.iError=KErrNone; |
|
975 } |
|
976 progress.iType=TBioUiProgress::EBioMtmUiParseAndEdit; |
|
977 TPckgBuf<TBioUiProgress> progressPckg(progress); |
|
978 parseOp = CMsvCompletedOperation::NewL( |
|
979 Session(), |
|
980 KUidBIOMessageTypeMtm, |
|
981 progressPckg, |
|
982 KMsvNullIndexEntryId, |
|
983 parseAndEdit->RequestStatus() ); |
|
984 } |
|
985 |
|
986 // Pass 'parse' operation to 'parse and edit' operation |
|
987 parseAndEdit->SetParseOpL(parseOp); |
|
988 |
|
989 CleanupStack::Pop(parseAndEdit); // parseAndEdit |
|
990 CleanupStack::PopAndDestroy(sel); // sel |
|
991 |
|
992 return parseAndEdit; |
|
993 } |
|
994 |
|
995 // ----------------------------------------------------------------------------- |
|
996 // CBioMtmUi::CheckEntryL |
|
997 // Entry validation |
|
998 // Leaves with KErrNotSupported if entry is not a message of the BIO MTM. |
|
999 // ----------------------------------------------------------------------------- |
|
1000 // |
|
1001 void CBioMtmUi::CheckEntryL(const TMsvEntry& aEntry) const |
|
1002 { |
|
1003 // Note: Sending Bio messages will have Mtm type of |
|
1004 // the transport type for sending. |
|
1005 // Instead Sending Bio messages will have iBioType as non-zero. |
|
1006 |
|
1007 if(aEntry.iType.iUid!=KUidMsvMessageEntryValue || |
|
1008 (aEntry.iBioType==0 && aEntry.iMtm!=KUidBIOMessageTypeMtm)) |
|
1009 User::Leave(KErrNotSupported); |
|
1010 } |
|
1011 |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // CBioMtmUi::CreateFromTextLC |
|
1014 // Both name and number are shown if they are known. |
|
1015 // Otherwise only the number is shown. |
|
1016 // Number is always known, except for IR & BT. |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // |
|
1019 HBufC* CBioMtmUi::CreateFromTextLC(CMsvEntry& aEntry) const |
|
1020 { |
|
1021 CMsvStore* store = aEntry.ReadStoreL(); |
|
1022 CleanupStack::PushL(store); |
|
1023 TBool smsBased; |
|
1024 HBufC* toFromSmsBuf; |
|
1025 if (store->IsPresentL(KBiumUidMsvSMSHeaderStream)) |
|
1026 { |
|
1027 smsBased = ETrue; |
|
1028 CPlainText* nullString = CPlainText::NewL(); |
|
1029 CleanupStack::PushL(nullString); |
|
1030 CSmsHeader* smsHeader = CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *nullString); |
|
1031 CleanupStack::PushL(smsHeader); |
|
1032 smsHeader->RestoreL(*store); |
|
1033 toFromSmsBuf = smsHeader->Message().SmsPDU().ToFromAddress().AllocL(); |
|
1034 CleanupStack::PopAndDestroy(2, nullString); // smsHeader nullString |
|
1035 } |
|
1036 else |
|
1037 { |
|
1038 smsBased = EFalse; |
|
1039 toFromSmsBuf = KNullDesC().AllocL(); |
|
1040 } |
|
1041 CleanupStack::PopAndDestroy(store); |
|
1042 CleanupStack::PushL(toFromSmsBuf); |
|
1043 HBufC* result; |
|
1044 TPtrC details(aEntry.Entry().iDetails); |
|
1045 if (smsBased) |
|
1046 { |
|
1047 TPtr toFromSmsPtr(toFromSmsBuf->Des()); |
|
1048 toFromSmsPtr.Trim(); |
|
1049 |
|
1050 // Does the iDetails have a name or number? Do a comparison in order to |
|
1051 // find out. |
|
1052 TBool detailsIsNumber = details.Compare(toFromSmsPtr) == 0; |
|
1053 if (detailsIsNumber) |
|
1054 { |
|
1055 // ...which means that the name was not known when the message arrived. |
|
1056 // We're not going to fetch it now. |
|
1057 // Show the number. |
|
1058 result = details.AllocL(); |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 // The iDetails contains the matched name. Concatenate the name and |
|
1063 // toFromSmsBuf which contains the number. |
|
1064 result = HBufC::NewL( |
|
1065 details.Length() + KCharacterReserve + toFromSmsBuf->Length()); |
|
1066 TPtr resultPtr(result->Des()); |
|
1067 _LIT(KBiumChSpace, " "); |
|
1068 _LIT(KBiumChLeft, "<"); |
|
1069 _LIT(KBiumChRight, ">"); |
|
1070 resultPtr.Append(details); |
|
1071 resultPtr.Append(KBiumChSpace); |
|
1072 resultPtr.Append(KBiumChLeft); |
|
1073 resultPtr.Append(*toFromSmsBuf); |
|
1074 resultPtr.Append(KBiumChRight); |
|
1075 } |
|
1076 } |
|
1077 else |
|
1078 { |
|
1079 // It is either IR or BT, so use the iDetails text. |
|
1080 result = aEntry.Entry().iDetails.AllocL(); |
|
1081 } |
|
1082 CleanupStack::PopAndDestroy(toFromSmsBuf); |
|
1083 CleanupStack::PushL(result); |
|
1084 return result; |
|
1085 } |
|
1086 |
|
1087 |
|
1088 //****************************************************************************** |
|
1089 //****************************************************************************** |
|
1090 // |
|
1091 // class CParseAndEditOp |
|
1092 // |
|
1093 // Operation encapsulating the parse operation |
|
1094 // and the launch application operation. |
|
1095 // |
|
1096 //****************************************************************************** |
|
1097 //****************************************************************************** |
|
1098 |
|
1099 // ----------------------------------------------------------------------------- |
|
1100 // CParseAndEditOp::NewL |
|
1101 // Construction |
|
1102 // ----------------------------------------------------------------------------- |
|
1103 // |
|
1104 CParseAndEditOp* CParseAndEditOp::NewL( |
|
1105 CMsvSession& aMsvSession, TRequestStatus& aObserverRequestStatus, |
|
1106 const TParseAndEditParams& aParams) |
|
1107 { |
|
1108 CParseAndEditOp* self = |
|
1109 new(ELeave) CParseAndEditOp( |
|
1110 aMsvSession,aObserverRequestStatus,aParams ); |
|
1111 CleanupStack::PushL(self); |
|
1112 self->ConstructL(); |
|
1113 CleanupStack::Pop(self); |
|
1114 return self; |
|
1115 } |
|
1116 |
|
1117 // ----------------------------------------------------------------------------- |
|
1118 // CParseAndEditOp::CParseAndEditOp |
|
1119 // ----------------------------------------------------------------------------- |
|
1120 // |
|
1121 CParseAndEditOp::CParseAndEditOp( |
|
1122 CMsvSession& aMsvSession,TRequestStatus& aObserverRequestStatus, |
|
1123 const TParseAndEditParams& aParams) |
|
1124 : CMsvOperation(aMsvSession, |
|
1125 KParseAndEditOpPriority,aObserverRequestStatus), |
|
1126 iState(EStateIdle),iParams(aParams) |
|
1127 { |
|
1128 iLocalProgress.iType=TBioUiProgress::EBioMtmUiParseAndEdit; |
|
1129 iLocalProgress.iError=KErrNone; |
|
1130 |
|
1131 CActiveScheduler::Add(this); |
|
1132 } |
|
1133 |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // CParseAndEditOp::ConstructL |
|
1136 // Construction |
|
1137 // ----------------------------------------------------------------------------- |
|
1138 // |
|
1139 void CParseAndEditOp::ConstructL() |
|
1140 { |
|
1141 iMtmStore=CMtmStore::NewL(iMsvSession); |
|
1142 } |
|
1143 |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // CParseAndEditOp::~CParseAndEditOp |
|
1146 // Destruction |
|
1147 // ----------------------------------------------------------------------------- |
|
1148 // |
|
1149 CParseAndEditOp::~CParseAndEditOp() |
|
1150 { |
|
1151 Cancel(); |
|
1152 delete iOperation; |
|
1153 delete iMtmStore; |
|
1154 } |
|
1155 |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // CParseAndEditOp::ProgressL |
|
1158 // ----------------------------------------------------------------------------- |
|
1159 // |
|
1160 const TDesC8& CParseAndEditOp::ProgressL() |
|
1161 { |
|
1162 if(iOperation) |
|
1163 return iOperation->ProgressL(); |
|
1164 |
|
1165 iLocalProgressPckg=iLocalProgress; |
|
1166 return iLocalProgressPckg; |
|
1167 } |
|
1168 |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // CParseAndEditOp::RequestStatus |
|
1171 // Enquiry |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // |
|
1174 TRequestStatus& CParseAndEditOp::RequestStatus() |
|
1175 { |
|
1176 return iStatus; |
|
1177 } |
|
1178 |
|
1179 // ----------------------------------------------------------------------------- |
|
1180 // CParseAndEditOp::SetParseOpL |
|
1181 // Setup and kick off operation |
|
1182 // ----------------------------------------------------------------------------- |
|
1183 // |
|
1184 void CParseAndEditOp::SetParseOpL(CMsvOperation* aOp) |
|
1185 { |
|
1186 __ASSERT_DEBUG(aOp, Panic(EBioMtmUiNullOperation)); |
|
1187 __ASSERT_DEBUG(!iOperation, Panic(EBioMtmUiOperationAlreadyExists)); |
|
1188 iOperation = aOp; |
|
1189 iMtm = iOperation->Mtm(); |
|
1190 iState = EStateParsing; |
|
1191 SetActive(); |
|
1192 } |
|
1193 |
|
1194 // ----------------------------------------------------------------------------- |
|
1195 // CParseAndEditOp::DoCancel |
|
1196 // from CActive |
|
1197 // ----------------------------------------------------------------------------- |
|
1198 // |
|
1199 void CParseAndEditOp::DoCancel() |
|
1200 { |
|
1201 if(iOperation) |
|
1202 iOperation->Cancel(); |
|
1203 CompleteObserver(); |
|
1204 } |
|
1205 |
|
1206 // ----------------------------------------------------------------------------- |
|
1207 // CParseAndEditOp::RunL |
|
1208 // from CActive |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // |
|
1211 void CParseAndEditOp::RunL() |
|
1212 { |
|
1213 __ASSERT_DEBUG(iOperation,Panic(EBioMtmUiOperationDoesNotExist)); |
|
1214 |
|
1215 switch(iState) |
|
1216 { |
|
1217 case EStateParsing: // The parse has completed. |
|
1218 { |
|
1219 TBuf<CBaseMtmUi::EProgressStringMaxLen> bufNotUsed1; |
|
1220 TInt intNotUsed2; |
|
1221 TInt intNotUsed3; |
|
1222 TInt intNotUsed4; |
|
1223 TInt intNotUsed5; |
|
1224 CBaseMtmUi& mtmUi=iMtmStore->GetMtmUiLC(KUidBIOMessageTypeMtm); |
|
1225 const TInt err=mtmUi.GetProgress(iOperation->FinalProgress(), |
|
1226 bufNotUsed1,intNotUsed2,intNotUsed3, |
|
1227 intNotUsed4,intNotUsed5); |
|
1228 CleanupStack::PopAndDestroy(); // (release cleanup item for mtmUi) |
|
1229 if(KErrNone==err && iParams.iLaunchApp) |
|
1230 DoEditL(); |
|
1231 else |
|
1232 { |
|
1233 SetEntryReadAndOldL(iParams.iEditorParams.iId); |
|
1234 CompleteObserver(); |
|
1235 } |
|
1236 } |
|
1237 break; |
|
1238 case EStateEditing: // Edit has completed. |
|
1239 DeleteMessageAttachmentL(iParams.iEditorParams.iId); |
|
1240 CompleteObserver(); |
|
1241 break; |
|
1242 |
|
1243 default:;// To prevent warning enumeration value |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 // ----------------------------------------------------------------------------- |
|
1248 // CParseAndEditOp::RunError |
|
1249 // from CActive |
|
1250 // RunError will get called if our RunL leaves |
|
1251 // ----------------------------------------------------------------------------- |
|
1252 // |
|
1253 TInt CParseAndEditOp::RunError(TInt aError) |
|
1254 { |
|
1255 delete iOperation; // So that we will report our local progress |
|
1256 iOperation=NULL; |
|
1257 iLocalProgress.iError = aError; |
|
1258 CompleteObserver(); |
|
1259 return KErrNone; // the Bio MTM UI will handle the error |
|
1260 } |
|
1261 |
|
1262 // ----------------------------------------------------------------------------- |
|
1263 // CParseAndEditOp::DoEditL |
|
1264 // ----------------------------------------------------------------------------- |
|
1265 // |
|
1266 void CParseAndEditOp::DoEditL() |
|
1267 { |
|
1268 delete iOperation; |
|
1269 iOperation=NULL; |
|
1270 |
|
1271 TBioUiProgress progress; |
|
1272 progress.iType=TBioUiProgress::EBioMtmUiEditing; |
|
1273 progress.iError=KErrNone; |
|
1274 TPckgBuf<TBioUiProgress> progressPckg(progress); |
|
1275 |
|
1276 iOperation = MsgEditorLauncher::LaunchEditorApplicationL( |
|
1277 iMsvSession, |
|
1278 iMtm, |
|
1279 iStatus, |
|
1280 iParams.iEditorParams, |
|
1281 iParams.iEditorFileName, |
|
1282 progressPckg); |
|
1283 |
|
1284 iState = EStateEditing; |
|
1285 SetActive(); |
|
1286 } |
|
1287 |
|
1288 // ----------------------------------------------------------------------------- |
|
1289 // CParseAndEditOp::CompleteObserver |
|
1290 // ----------------------------------------------------------------------------- |
|
1291 // |
|
1292 void CParseAndEditOp::CompleteObserver() |
|
1293 { |
|
1294 TRequestStatus* status = &iObserverRequestStatus; |
|
1295 TInt err; |
|
1296 if (iOperation) |
|
1297 { |
|
1298 err = iOperation->iStatus.Int(); |
|
1299 } |
|
1300 else |
|
1301 { |
|
1302 err = iLocalProgress.iError; |
|
1303 } |
|
1304 |
|
1305 User::RequestComplete(status, err); |
|
1306 iState = EStateComplete; |
|
1307 } |
|
1308 |
|
1309 // ----------------------------------------------------------------------------- |
|
1310 // CParseAndEditOp::SetEntryReadAndOldL |
|
1311 // ----------------------------------------------------------------------------- |
|
1312 // |
|
1313 void CParseAndEditOp::SetEntryReadAndOldL(TMsvId aEntryId) |
|
1314 { |
|
1315 CMsvEntry* entry = iMsvSession.GetEntryL(aEntryId); |
|
1316 CleanupStack::PushL(entry); |
|
1317 TMsvEntry tEntry(entry->Entry()); |
|
1318 tEntry.SetUnread(EFalse); |
|
1319 tEntry.SetNew(EFalse); |
|
1320 entry->ChangeL(tEntry); |
|
1321 CleanupStack::PopAndDestroy(entry); |
|
1322 } |
|
1323 |
|
1324 // ----------------------------------------------------------------------------- |
|
1325 // CParseAndEditOp::DeleteMessageAttachmentL |
|
1326 // ----------------------------------------------------------------------------- |
|
1327 // |
|
1328 void CParseAndEditOp::DeleteMessageAttachmentL(TMsvId aEntryId) |
|
1329 { |
|
1330 CMsvEntry* entry = NULL; |
|
1331 TRAPD(err,entry = iMsvSession.GetEntryL(aEntryId)); |
|
1332 |
|
1333 if(err == KErrNone) |
|
1334 { |
|
1335 CleanupStack::PushL(entry); // 1st push |
|
1336 TMsvEntry tEntry = entry->Entry(); |
|
1337 TBool readOnly = tEntry.ReadOnly(); |
|
1338 tEntry.SetReadOnly(EFalse); |
|
1339 entry->ChangeL(tEntry); |
|
1340 CMsvStore* store = entry->EditStoreL(); |
|
1341 CleanupStack::PushL(store); // 2nd push |
|
1342 if(store->AttachmentManagerL().AttachmentCount() > 0) |
|
1343 { |
|
1344 store->AttachmentManagerExtensionsL().RemoveAttachmentL(0); |
|
1345 store->CommitL(); |
|
1346 } |
|
1347 if(store->IsPresentL(KUidMsvBIODataStream)) |
|
1348 { |
|
1349 store->Remove(KUidMsvBIODataStream); |
|
1350 store->CommitL(); |
|
1351 } |
|
1352 TMsvEntry tEntryNew = entry->Entry(); |
|
1353 tEntryNew.SetReadOnly(readOnly); |
|
1354 tEntryNew.iMtmData3 = 0; // EBioMsgNotParsed in bioop.h |
|
1355 entry->ChangeL(tEntryNew); |
|
1356 CleanupStack::PopAndDestroy(store); |
|
1357 CleanupStack::PopAndDestroy(entry); |
|
1358 } |
|
1359 // we ignore error if attachment was not found |
|
1360 else if(err != KErrNotFound) |
|
1361 { |
|
1362 User::LeaveIfError(err); |
|
1363 } |
|
1364 |
|
1365 } |
|
1366 |
|
1367 |
|
1368 // end of file |