00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <txtrich.h>
00019 #include <eikrted.h>
00020 #include <apffndr.h>
00021 #include <eikenv.h>
00022 #include <eikfsel.h>
00023 #include <eikon.hrh>
00024 #include <eikon.rsg>
00025
00026
00027 #include <msvuids.h>
00028 #include <msvids.h>
00029
00030
00031 #include "TXTCMDS.H"
00032 #include "TXCLIENT.H"
00033
00034 #include "TXTU.HRH"
00035 #include "TXTU.H"
00036 #include "TXTUCMDS.H"
00037 #include "Txtupan.h"
00038 #include <txtu.rsg>
00039 #include "TXTU.HRH"
00040
00041
00042 #ifdef __WINS__
00043
00044 _LIT(KTxtuMtmUiResourceFile,"z:\\resource\\messaging\\txtu.rsc");
00045 #else
00046 _LIT(KTxtuMtmUiResourceFile,"Z:\\resource\\messaging\\txtu.rsc");
00047 #endif
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 CTextMtmUi* CTextMtmUi::NewL(CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll)
00058 {
00059 CTextMtmUi* self=new(ELeave) CTextMtmUi(aBaseMtm, aRegisteredMtmDll);
00060 CleanupStack::PushL(self);
00061 self->ConstructL();
00062 CleanupStack::Pop();
00063 return self;
00064 }
00065
00066 CTextMtmUi::CTextMtmUi(CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll)
00067 : CBaseMtmUi(aBaseMtm, aRegisteredMtmDll)
00068 {
00069 }
00070
00071 CTextMtmUi::~CTextMtmUi()
00072 {
00073 }
00074
00075 void CTextMtmUi::ConstructL()
00076 {
00077 CBaseMtmUi::ConstructL();
00078 }
00079
00080 CMsvOperation* CTextMtmUi::CancelL(TRequestStatus& , const CMsvEntrySelection& )
00081 {
00082 User::Leave(KErrNotSupported);
00083 return NULL;
00084 }
00085
00086 void CTextMtmUi::GetResourceFileName(TFileName& aFileName) const
00087
00088 {
00089 aFileName=KTxtuMtmUiResourceFile;
00090 }
00091
00092
00093
00094
00095
00096 CMsvOperation* CTextMtmUi::OpenL(TRequestStatus& aStatus)
00097
00098 {
00099 __ASSERT_DEBUG(iBaseMtm.Entry().Entry().iType==KUidMsvMessageEntry,
00100 Panic(ETextMtmUiOnlyWorksWithMessageEntries));
00101 return EditL(aStatus);
00102 }
00103
00104 CMsvOperation* CTextMtmUi::OpenL(TRequestStatus& aStatus, const CMsvEntrySelection& aSelection)
00105
00106 {
00107 __ASSERT_DEBUG(aSelection.Count(), Panic(ETextMtmUiEmptySelection));
00108 iBaseMtm.SwitchCurrentEntryL(aSelection.At(0));
00109 return OpenL(aStatus);
00110 }
00111
00112 CMsvOperation* CTextMtmUi::CloseL(TRequestStatus& aStatus)
00113 {
00114
00115 __ASSERT_DEBUG(iBaseMtm.Entry().Entry().iType==KUidMsvMessageEntry,
00116 Panic(ETextMtmUiOnlyWorksWithMessageEntries));
00117
00118
00119 TPckgBuf<TMsvLocalOperationProgress> progress;
00120 SetProgressSuccess(progress,iBaseMtm.Entry().Entry().Id());
00121
00122 CMsvCompletedOperation* op=CMsvCompletedOperation::NewL(Session(), Type(),
00123 progress, KMsvLocalServiceIndexEntryId,aStatus);
00124 return op;
00125 }
00126
00127 CMsvOperation* CTextMtmUi::CloseL(TRequestStatus& aStatus, const CMsvEntrySelection& aSelection)
00128 {
00129
00130 __ASSERT_DEBUG(aSelection.Count(), Panic(ETextMtmUiEmptySelection));
00131 iBaseMtm.SwitchCurrentEntryL(aSelection.At(0));
00132 return CloseL(aStatus);
00133 }
00134
00135 CMsvOperation* CTextMtmUi::CreateL(const TMsvEntry& aEntry, CMsvEntry& aParent,
00136 TRequestStatus& aStatus)
00137
00138 {
00139 TMsvId oldId=0;
00140 if (iBaseMtm.HasContext())
00141 oldId = iBaseMtm.Entry().Entry().Id();
00142 else
00143 iBaseMtm.SwitchCurrentEntryL(KMsvRootIndexEntryId);
00144
00145
00146 TMsvEntry newEntry=aEntry;
00147 if (newEntry.iType.iUid == KUidMsvMessageEntryValue)
00148 {
00149
00150 _LIT(KNewText,"New Text");
00151 newEntry.iServiceId=KMsvLocalServiceIndexEntryId;
00152 newEntry.iDescription.Set(KNewText);
00153 }
00154 CMsvOperationActiveSchedulerWait* wait=CMsvOperationActiveSchedulerWait::NewLC();
00155 CMsvOperation* op=CBaseMtmUi::CreateL(newEntry, aParent, wait->iStatus);
00156 CleanupStack::PushL(op);
00157 wait->Start();
00158
00159 TPckgBuf<TMsvLocalOperationProgress> progressPack;
00160 progressPack.Copy(op->ProgressL());
00161 TMsvLocalOperationProgress progress = progressPack();
00162 User::LeaveIfError(progress.iError);
00163
00164 CleanupStack::PopAndDestroy(2);
00165
00166
00167 iBaseMtm.SwitchCurrentEntryL(progress.iId);
00168 TRAPD(ret, op=EditL(aStatus));
00169 if (ret!=KErrNone)
00170 {
00171
00172 wait = CMsvOperationActiveSchedulerWait::NewLC();
00173 CMsvEntry* entry=Session().GetEntryL(iBaseMtm.Entry().Entry().Parent());
00174 CleanupStack::PushL(entry);
00175 wait->Start();
00176 entry->DeleteL(progress.iId);
00177 CleanupStack::PopAndDestroy(2);
00178 if (oldId)
00179 iBaseMtm.SwitchCurrentEntryL(oldId);
00180 User::Leave(ret);
00181 }
00182 return op;
00183 }
00184
00185
00186 CMsvOperation* CTextMtmUi::EditL(TRequestStatus& aStatus)
00187
00188 {
00189 TUid type = iBaseMtm.Entry().Entry().iType;
00190 iServiceId = iBaseMtm.Entry().Entry().iServiceId;
00191
00192 __ASSERT_DEBUG(type==KUidMsvMessageEntry || type==KUidMsvServiceEntry,
00193 Panic(ETextMtmUiWrongEntryType));
00194
00195 if ( type == KUidMsvMessageEntry )
00196 return MessageEditL(aStatus);
00197 else
00198 return ServiceEditL(aStatus);
00199 }
00200
00201 CMsvOperation* CTextMtmUi::MessageEditL(TRequestStatus& aStatus)
00202
00203 {
00204 CMsvOperation* op=NULL;
00205
00206
00207 if ( iServiceId == KMsvLocalServiceIndexEntryId )
00208 {
00209 return LaunchEditorApplicationL(aStatus, iBaseMtm.Entry().Entry().Id(), EFalse);
00210 }
00211
00212
00213 CEikDialog* dialog=new(ELeave) CEikDialog;
00214 if (dialog->ExecuteLD(R_DIALOG_REFUSE_EDIT_REMOTE_MESSAGE))
00215 {
00216 TMsvEntry tEntry = iBaseMtm.Entry().Entry();
00217 CEditRemoteOperation* edop = new (ELeave)CEditRemoteOperation(*this, Session(), 0, aStatus);
00218 edop->StartL(tEntry);
00219 op = edop;
00220 }
00221 else
00222 {
00223 TPckgBuf<TMsvLocalOperationProgress> progress;
00224 SetProgressSuccess(progress,iBaseMtm.Entry().Entry().Id());
00225
00226 op=CMsvCompletedOperation::NewL(Session(), Type(), progress, iServiceId, aStatus);
00227 }
00228
00229 __ASSERT_DEBUG(op != NULL, Panic(ETextMtmUiInvalidNullPointer));
00230 return op;
00231 }
00232
00233
00234 CMsvOperation* CTextMtmUi::ServiceEditL(TRequestStatus& aStatus)
00235
00236 {
00237 TMTMTxtSettings settings;
00238
00239
00240 CTextMtmClient& mtm = static_cast<CTextMtmClient&>(BaseMtm());
00241
00242 TRAP_IGNORE(mtm.Settings().LoadSettingsL(iBaseMtm.Entry().Entry().Id(), settings));
00243
00244
00245 CEikDialog* dialog=new(ELeave) CTextMtmEditServiceDialog(settings);
00246 TPckgBuf<TMsvLocalOperationProgress> progress;
00247 if (dialog->ExecuteLD(R_DIALOG_SERVICE_SETTINGS))
00248 {
00249 mtm.Settings().SaveSettingsL(iBaseMtm.Entry().Entry().Id(), settings);
00250
00251 TMsvEntry entry = iBaseMtm.Entry().Entry();
00252 entry.iDetails.Set(settings.RootFolder());
00253 iBaseMtm.Entry().ChangeL(entry);
00254
00255 CMsvEntrySelection* selection=new (ELeave) CMsvEntrySelection;
00256 CleanupStack::PushL(selection);
00257 selection->AppendL(iBaseMtm.Entry().Entry().Id());
00258 CleanupStack::Pop();
00259 TBuf8<1> scrap;
00260 InvokeSyncFunctionL(ETxtuCommandRefreshMBox, *selection, scrap);
00261 delete selection;
00262 SetProgressSuccess(progress,iBaseMtm.Entry().Entry().Id());
00263 }
00264 else
00265 {
00266 progress().iTotalNumberOfEntries=1;
00267 progress().iNumberCompleted=0;
00268 }
00269
00270 return CMsvCompletedOperation::NewL(Session(), Type(), progress, iServiceId, aStatus);
00271 }
00272
00273 CMsvOperation* CTextMtmUi::EditL(TRequestStatus& aStatus, const CMsvEntrySelection& aSelection)
00274
00275 {
00276 __ASSERT_DEBUG(aSelection.Count(), Panic(ETextMtmUiEmptySelection));
00277 iBaseMtm.SwitchCurrentEntryL(aSelection.At(0));
00278 return EditL(aStatus);
00279 }
00280
00281 CMsvOperation* CTextMtmUi::ViewL(TRequestStatus& aStatus)
00282
00283 {
00284 __ASSERT_DEBUG(iBaseMtm.Entry().Entry().iType==KUidMsvMessageEntry,
00285 Panic(ETextMtmUiOnlyWorksWithMessageEntries));
00286 return LaunchEditorApplicationL(aStatus, iBaseMtm.Entry().Entry().Id(), ETrue);
00287 }
00288
00289 CMsvOperation* CTextMtmUi::ViewL(TRequestStatus& aStatus, const CMsvEntrySelection& aSelection)
00290
00291 {
00292 __ASSERT_DEBUG(aSelection.Count(), Panic(ETextMtmUiEmptySelection));
00293 iBaseMtm.SwitchCurrentEntryL(aSelection.At(0));
00294 return ViewL(aStatus);
00295 }
00296
00297
00298
00299
00300
00301
00302 CMsvOperation* CTextMtmUi::DeleteFromL(const CMsvEntrySelection& aSelection,
00303 TRequestStatus& aStatus)
00304 {
00305 __ASSERT_DEBUG(aSelection.Count(), Panic(ETextMtmUiEmptySelection));
00306
00307 CheckValidCopyMoveDelSelectionL(BaseMtm().Entry(),aSelection);
00308 return BaseMtm().Entry().DeleteL(aSelection, aStatus);
00309 }
00310
00311 CMsvOperation* CTextMtmUi::DeleteServiceL(const TMsvEntry& aService, TRequestStatus& aStatus)
00312 {
00313
00314 CTextMtmClient& mtm = static_cast<CTextMtmClient&>(BaseMtm());
00315 mtm.Settings().DeleteSettingsL(aService.Id());
00316 return CBaseMtmUi::DeleteServiceL(aService, aStatus);
00317 }
00318
00319 CMsvOperation* CTextMtmUi::CopyToL(const CMsvEntrySelection& aSelection,
00320 TRequestStatus& aStatus)
00321
00322 {
00323 return DoCopyMoveToL(aSelection, aStatus, ETrue);
00324 }
00325
00326
00327 CMsvOperation* CTextMtmUi::MoveToL(const CMsvEntrySelection& aSelection,
00328 TRequestStatus& aStatus)
00329
00330 {
00331 return DoCopyMoveToL(aSelection, aStatus, EFalse);
00332 }
00333
00334
00335 CMsvOperation* CTextMtmUi::CopyFromL(const CMsvEntrySelection& aSelection,
00336 TMsvId aTargetId, TRequestStatus& aStatus)
00337
00338 {
00339 return DoCopyMoveFromL(aSelection, aTargetId, aStatus, ETrue);
00340 }
00341
00342
00343 CMsvOperation* CTextMtmUi::MoveFromL(const CMsvEntrySelection& aSelection,
00344 TMsvId aTargetId, TRequestStatus& aStatus)
00345
00346 {
00347 return DoCopyMoveFromL(aSelection, aTargetId, aStatus, EFalse);
00348 }
00349
00350
00351 CMsvOperation* CTextMtmUi::DoCopyMoveFromL(const CMsvEntrySelection& aSelection,
00352 TMsvId aTargetId, TRequestStatus& aStatus, TBool aAction)
00353
00354 {
00355 __ASSERT_DEBUG(aSelection.Count(), Panic(ETextMtmUiEmptySelection));
00356
00357 const TMsvEntry& context=BaseMtm().Entry().Entry();
00358 __ASSERT_ALWAYS(context.iType.iUid==KUidMsvServiceEntryValue ||
00359 context.iType.iUid==KUidMsvFolderEntryValue, Panic(ETextMtmUiWrongEntryType));
00360
00361 CheckValidCopyMoveDelSelectionL(BaseMtm().Entry(),aSelection);
00362
00363
00364 CMsvOperation* op=NULL;
00365 if (aAction)
00366 op=BaseMtm().Entry().CopyL(aSelection, aTargetId, aStatus);
00367 else
00368 op=BaseMtm().Entry().MoveL(aSelection, aTargetId, aStatus);
00369
00370 return op;
00371 }
00372
00373
00374 CMsvOperation* CTextMtmUi::DoCopyMoveToL(const CMsvEntrySelection& aSelection,
00375 TRequestStatus& aStatus, TBool aAction)
00376
00377 {
00378 __ASSERT_DEBUG(aSelection.Count(), Panic(ETextMtmUiEmptySelection));
00379
00380 const TMsvEntry& context=BaseMtm().Entry().Entry();
00381 __ASSERT_ALWAYS(context.iType.iUid==KUidMsvServiceEntryValue ||
00382 context.iType.iUid==KUidMsvFolderEntryValue, Panic(ETextMtmUiWrongEntryType));
00383
00384
00385 CMsvEntry* sourceEntry=Session().GetEntryL(aSelection.At(0));
00386 CleanupStack::PushL(sourceEntry);
00387
00388 TMsvId parent=sourceEntry->Entry().Parent();
00389 sourceEntry->SetEntryL(parent);
00390
00391 CheckValidCopyMoveDelSelectionL(*sourceEntry,aSelection);
00392
00393
00394 CMsvOperation* op=NULL;
00395 if (aAction)
00396 op=sourceEntry->CopyL(aSelection, context.Id(), aStatus);
00397 else
00398 op=sourceEntry->MoveL(aSelection, context.Id(), aStatus);
00399
00400 CleanupStack::PopAndDestroy();
00401
00402 return op;
00403 }
00404
00405 void CTextMtmUi::CheckValidCopyMoveDelSelectionL(const CMsvEntry& aParent,
00406 const CMsvEntrySelection& aSelection)
00407
00408
00409 {
00410
00411 CMsvEntrySelection* msgChildren=aParent.ChildrenWithTypeL(KUidMsvMessageEntry);
00412 CleanupStack::PushL(msgChildren);
00413
00414
00415 TInt nChildren=aSelection.Count();
00416 for (TInt i=0; i<nChildren; i++)
00417 if ( msgChildren->Find(aSelection[i] ) == KErrNotFound )
00418 User::Leave(KErrNotSupported);
00419 CleanupStack::PopAndDestroy();
00420 }
00421
00422
00423
00424
00425
00426
00427 void CTextMtmUi::InvokeSyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection,
00428 TDes8& aParameter)
00429
00430 {
00431 if (aFunctionId==ETxtuCommandExportText)
00432 {
00433 __ASSERT_DEBUG(aSelection.Count()==1, Panic(ETextMtmUiSelectionIsNotOneMessage));
00434 DoExportTextFromMessageL(aSelection.At(0));
00435 }
00436 else if (aFunctionId==ETxtuCommandRefreshMBox)
00437 {
00438 CBaseMtmUi::InvokeSyncFunctionL(KTXTMTMRefresh, aSelection, aParameter);
00439 }
00440 else
00441 {
00442 CBaseMtmUi::InvokeSyncFunctionL(aFunctionId, aSelection, aParameter);
00443 }
00444 }
00445
00446 CMsvOperation* CTextMtmUi::InvokeAsyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection,
00447 TRequestStatus& aCompletionStatus, TDes8& aParameter)
00448
00449 {
00450 return CBaseMtmUi::InvokeAsyncFunctionL(aFunctionId, aSelection, aCompletionStatus, aParameter);
00451 }
00452
00453
00454
00455
00456
00457 CMsvOperation* CTextMtmUi::ReplyL(TMsvId , TMsvPartList , TRequestStatus& )
00458
00459 {
00460 User::Leave(KErrNotSupported);
00461 return NULL;
00462 }
00463
00464 CMsvOperation* CTextMtmUi::ForwardL(TMsvId , TMsvPartList , TRequestStatus& )
00465
00466 {
00467 User::Leave(KErrNotSupported);
00468 return NULL;
00469 }
00470
00471
00472
00473
00474
00475 TInt CTextMtmUi::GetProgress(const TDesC8& aProgress, TBuf<EProgressStringMaxLen>& aReturnString,
00476 TInt& aTotalEntryCount, TInt& aEntriesDone,TInt& aCurrentEntrySize, TInt& aCurrentBytesTrans) const
00477
00478 {
00479 TTxtProgressBuf paramPack;
00480 if (aProgress.Length()!=paramPack.Length())
00481 return KErrNone;
00482
00483
00484
00485 paramPack.Copy(aProgress);
00486 TTxtProgress progress=paramPack();
00487 aReturnString.Zero();
00488 _LIT(KWorking,"Working");
00489 _LIT(KError,"Error: ");
00490
00491
00492
00493 if (progress.iErrorCode==KErrNone)
00494 aReturnString.Append(KWorking);
00495 else
00496 {
00497 aReturnString.Append(KError);
00498 aReturnString.AppendNum(progress.iErrorCode);
00499 }
00500
00501
00502 aTotalEntryCount=progress.iTotalMsgs;
00503 aEntriesDone=progress.iMsgsProcessed;
00504
00505
00506 aCurrentEntrySize=0;
00507 aCurrentBytesTrans=0;
00508
00509 return KErrNone;
00510 }
00511
00512
00513
00514
00515
00516 void CTextMtmUi::DoExportTextFromMessageL(TMsvId anId)
00517
00518 {
00519 TFileName filename(_S("\\"));
00520 HBufC* title=iCoeEnv->AllocReadResourceLC(R_TEXT_MTMUI_EXPORT_DIALOG_TITLE);
00521 CEikDialog* dialog=new(ELeave) CTextMtmExportToFileDialog(&filename, title);
00522 if (dialog->ExecuteLD(R_EIK_DIALOG_FILE_SAVEAS))
00523 {
00524
00525 CMsvEntry* messageEntry=GetMessageEntryLC(anId);
00526
00527
00528 CMsvStore* store=messageEntry->ReadStoreL();
00529 CleanupStack::PushL(store);
00530
00531
00532 CRichText* text=GetTextFromMessageStoreL(store);
00533
00534
00535 CleanupStack::PopAndDestroy(2);
00536
00537
00538 CleanupStack::PushL(text);
00539 text->ExportAsTextL(filename, CPlainText::EOrganiseByParagraph, 80);
00540 CleanupStack::PopAndDestroy();
00541 }
00542 CleanupStack::PopAndDestroy();
00543 }
00544
00545 CMsvEntry* CTextMtmUi::GetMessageEntryLC(TMsvId anId) const
00546 {
00547 CMsvEntry* messageEntry=Session().GetEntryL(anId);
00548 CleanupStack::PushL(messageEntry);
00549 return messageEntry;
00550 }
00551
00552 CRichText* CTextMtmUi::GetTextFromMessageStoreL(CMsvStore* aStore) const
00553 {
00554 CRichText* text=CRichText::NewL(iEikonEnv->SystemParaFormatLayerL(),
00555 iEikonEnv->SystemCharFormatLayerL());
00556 CleanupStack::PushL(text);
00557 aStore->RestoreBodyTextL(*text);
00558 CleanupStack::Pop();
00559 return text;
00560 }
00561
00562 CMsvOperation* CTextMtmUi::LaunchEditorApplicationL(TRequestStatus& aStatus, TMsvId aId,
00563 TBool aReadOnly)
00564 {
00565
00566
00567 if (aReadOnly)
00568 iEikonEnv->InfoMsg(R_TEXT_MTMUI_VIEWER_MESSAGE);
00569 else
00570 {
00571
00572 iEikonEnv->InfoMsg(R_TEXT_MTMUI_EDIT_MESSAGE);
00573
00574 _LIT(KEdited,"Edited document\n");
00575 iBaseMtm.SwitchCurrentEntryL(aId);
00576 CreateBodyIfNoneL();
00577 iBaseMtm.LoadMessageL();
00578 TInt docEnd=iBaseMtm.Body().DocumentLength();
00579 iBaseMtm.Body().InsertL(docEnd,KEdited);
00580 iBaseMtm.SaveMessageL();
00581 }
00582
00583 TPckgBuf<TMsvLocalOperationProgress> progress;
00584 SetProgressSuccess(progress,aId);
00585
00586 return CMsvCompletedOperation::NewL(Session(), Type(), progress, iServiceId, aStatus);
00587 }
00588
00589 void CTextMtmUi::SetProgressSuccess(TPckgBuf<TMsvLocalOperationProgress>& aProgress,TMsvId aId)
00590
00591 {
00592 aProgress().iTotalNumberOfEntries=1;
00593 aProgress().iNumberCompleted=1;
00594 aProgress().iId=aId;
00595 }
00596
00597 void CTextMtmUi::CreateBodyIfNoneL()
00598
00599 {
00600 __ASSERT_DEBUG(iBaseMtm.Entry().Entry().iType.iUid == KUidMsvMessageEntryValue,
00601 Panic(ETextMtmUiOnlyWorksWithMessageEntries));
00602
00603 CMsvStore* store=iBaseMtm.Entry().EditStoreL();
00604 CleanupStack::PushL(store);
00605
00606 if (!store->HasBodyTextL())
00607 {
00608
00609 CRichText* body = CRichText::NewL(iEikonEnv->SystemParaFormatLayerL(),
00610 iEikonEnv->SystemCharFormatLayerL());
00611 CleanupStack::PushL(body);
00612
00613
00614 store->StoreBodyTextL(*body);
00615 store->CommitL();
00616
00617 CleanupStack::PopAndDestroy();
00618 }
00619 CleanupStack::PopAndDestroy();
00620 }
00621
00622
00623
00624
00625
00626 CEditRemoteOperation::CEditRemoteOperation(CTextMtmUi& aMtmUi, CMsvSession& aMsvSession,
00627 TInt aPriority, TRequestStatus& aObserverRequestStatus)
00628 : CMsvOperation(aMsvSession, aPriority, aObserverRequestStatus), iMtmUi(aMtmUi)
00629 {
00630 CActiveScheduler::Add(this);
00631 }
00632
00633 CEditRemoteOperation::~CEditRemoteOperation()
00634 {
00635 Cancel();
00636 delete iCopyOperation;
00637 delete iEditOperation;
00638 }
00639
00640 const TDesC8& CEditRemoteOperation::ProgressL()
00641 {
00642 return progress;
00643 }
00644
00645 void CEditRemoteOperation::DoCancel()
00646 {
00647 switch (iState)
00648 {
00649 case EStateCopying:
00650 iCopyOperation->Cancel();
00651 break;
00652 case EStateEditing:
00653 iEditOperation->Cancel();
00654 break;
00655 default:
00656 break;
00657 }
00658 }
00659
00660 void CEditRemoteOperation::StartL(TMsvEntry& aSourceEntry)
00661 {
00662 CMsvEntry* cEntry=iMsvSession.GetEntryL(aSourceEntry.Parent());
00663 CleanupStack::PushL(cEntry);
00664 iObserverRequestStatus = KRequestPending;
00665 SetActive();
00666 iCopyOperation=cEntry->CopyL(aSourceEntry.Id(), KMsvGlobalInBoxIndexEntryId, iStatus);
00667 CleanupStack::PopAndDestroy();
00668 iState = EStateCopying;
00669 }
00670
00671 void CEditRemoteOperation::RunL()
00672 {
00673 switch (iState)
00674 {
00675 case EStateCopying:
00676 {
00677 TTxtProgressBuf package;
00678 package.Copy(iCopyOperation->ProgressL());
00679 TMsvId newid = package().iNewId;
00680
00681 iStatus = KRequestPending;
00682 SetActive();
00683 iEditOperation = iMtmUi.LaunchEditorApplicationL(iStatus, newid, EFalse);
00684 iState = EStateEditing;
00685 }
00686 break;
00687 case EStateEditing:
00688 {
00689 iState = EStateFinished;
00690 TRequestStatus *sP = &iObserverRequestStatus;
00691 User::RequestComplete(sP,iStatus.Int());
00692 }
00693 break;
00694 default:
00695 break;
00696 }
00697 }
00698
00699
00700
00701
00702
00703 CTextMtmExportToFileDialog::CTextMtmExportToFileDialog(TDes* aFileName, const TDesC* aTitle)
00704 : CEikFileSaveAsDialog(aFileName, aTitle, NULL, EFalse),
00705 iTitleBuf(*aTitle)
00706 {
00707 }
00708
00709 void CTextMtmExportToFileDialog::PreLayoutDynInitL()
00710 {
00711 CEikFileSaveAsDialog::PreLayoutDynInitL();
00712 SetTitleL(iTitleBuf);
00713 }
00714
00715
00716
00717
00718
00719 CTextMtmEditServiceDialog::CTextMtmEditServiceDialog(TMTMTxtSettings& aTxtSettings)
00720 : iTxtSettings(aTxtSettings)
00721 {
00722 }
00723
00724 void CTextMtmEditServiceDialog::PreLayoutDynInitL()
00725 {
00726 TParse parse;
00727 _LIT(KCRoot,"\\");
00728
00729 TDriveUnit sysDrive (RFs::GetSystemDrive());
00730 TDriveName sysDriveName (sysDrive.Name());
00731 TFileName defaultName(sysDriveName);
00732 defaultName.Append(KCRoot);
00733
00734 parse.Set(iTxtSettings.RootFolder(),&defaultName,&defaultName);
00735 CEikFolderNameSelector* fsel = (CEikFolderNameSelector*)Control(ETxtEditServiceFolder);
00736 TFileName fullName = parse.FullName();
00737 fsel->SetFullNameL(fullName);
00738 }
00739
00740 TBool CTextMtmEditServiceDialog::OkToExitL(TInt )
00741 {
00742 CEikFolderNameSelector* fsel = (CEikFolderNameSelector*)Control(ETxtEditServiceFolder);
00743 iTxtSettings.SetRootFolder(fsel->FullName());
00744 return ETrue;
00745 }
00746