os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSSaveAsDialog.cpp
Update contrib.
1 // Copyright (c) 2005-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // MVSSavaAeDialog.cpp
15 // Part of the MVS Application for TechView
18 #include "MVSSaveAsDialog.h"
20 #include <techview/eikcfdlg.h>
21 #include <techview/eikon.hrh>
22 #include <techview/eikfbrow.h>
23 #include <techview/eikedwin.h>
27 #include <techview/eikfsel.h>
30 #include <techview/eikinfo.h>
35 #include <techview/eikinfo.h>
36 #include <uiklafgt/eikcore.rsg>
37 #include <eikfile.rsg>
40 const TInt KShortErrorMessageLength = 64;
41 const TInt KMaxDisplayedFullNameLen = 35;
43 TInt CMVSSaveAsDialog::SetupDialogLD(TDes& aFileName, TBool* aReplace)
45 CMVSSaveAsDialog* dialog = new(ELeave) CMVSSaveAsDialog(aFileName, aReplace);
46 TInt val = dialog->ExecuteLD(R_EIK_DIALOG_FILE_SAVEAS);
50 CMVSSaveAsDialog::CMVSSaveAsDialog(TDes& aFilename, TBool* aReplace):CEikFileSaveAsDialog(&aFilename),iFilename(aFilename)
55 TBool CMVSSaveAsDialog::OkToExitL(TInt aButtonId)
58 if (aButtonId==EEikBidBrowse)
60 HandleBrowseButtonL();
65 CEikFileNameEditor* fileNameEditor=(CEikFileNameEditor*)(Control(EEikCidFileNameEd));
66 TFileName* fullName=new(ELeave) TFileName;
67 CleanupStack::PushL(fullName);
68 fileNameEditor->GetFullNameL(*fullName);
70 if (!ConeUtils::FileExists(*fullName))
72 ConeUtils::EnsurePathExistsL(*fullName);
76 TBuf<32> infoDialogTitle;
77 iEikonEnv->ReadResource(infoDialogTitle,R_EIK_TBUF_DIALOG_TITLE_CONFIRM_FILE_REPLACE);
78 TBuf<KShortErrorMessageLength> formatStr;
79 User::LeaveIfError(iEikonEnv->FsSession().Att(*fullName,attributes));
80 if (attributes&KEntryAttReadOnly)
82 iEikonEnv->LeaveWithInfoMsg(R_EIK_TBUF_CANNOT_REPLACE_READONLY_FILE);
86 iEikonEnv->ReadResource(formatStr,R_EIK_TBUF_FILE_REPLACE_CONFIRM1);
88 TBuf<KMaxDisplayedFullNameLen> abbrevName;
89 User::LeaveIfError(EikFileUtils::Parse(*fullName));
90 TParsePtr parse(*fullName);
91 EikFileUtils::AbbreviateFileName(parse.NameAndExt(),abbrevName);
92 TBuf<KShortErrorMessageLength + KMaxDisplayedFullNameLen> textMsg;
93 textMsg.Format(formatStr,&abbrevName);
94 CEikDialog* infoDialog=new(ELeave) CEikInfoDialog(infoDialogTitle,textMsg,CEikInfoDialog::EIgnoreEnter);
95 *iReplace = infoDialog->ExecuteLD(R_EIK_DIALOG_SINGLE_FILE_REPLACE);
97 // check disk is present in selected drive
98 TParsePtrC parse(*fullName);
99 TPtrC drv=parse.Drive();
101 root.Append(TChar(KPathDelimiter));
102 root.Append(KAnyFile);
104 const TInt ret=dir.Open(iEikonEnv->FsSession(),root,EFileRead|EFileShareAny);
105 if (ret==KErrNotReady)
107 iEikonEnv->LeaveWithInfoMsg(R_EIK_TBUF_DISK_NOT_PRESENT);
115 CleanupStack::PopAndDestroy(); // fullName