sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // MVSSavaAeDialog.cpp sl@0: // Part of the MVS Application for TechView sl@0: // sl@0: sl@0: #include "MVSSaveAsDialog.h" sl@0: #include "MVSApp.hrh" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: _LIT(KAnyFile,"*"); sl@0: const TInt KShortErrorMessageLength = 64; sl@0: const TInt KMaxDisplayedFullNameLen = 35; sl@0: sl@0: TInt CMVSSaveAsDialog::SetupDialogLD(TDes& aFileName, TBool* aReplace) sl@0: { sl@0: CMVSSaveAsDialog* dialog = new(ELeave) CMVSSaveAsDialog(aFileName, aReplace); sl@0: TInt val = dialog->ExecuteLD(R_EIK_DIALOG_FILE_SAVEAS); sl@0: return val; sl@0: } sl@0: sl@0: CMVSSaveAsDialog::CMVSSaveAsDialog(TDes& aFilename, TBool* aReplace):CEikFileSaveAsDialog(&aFilename),iFilename(aFilename) sl@0: { sl@0: iReplace = aReplace; sl@0: } sl@0: sl@0: TBool CMVSSaveAsDialog::OkToExitL(TInt aButtonId) sl@0: sl@0: { sl@0: if (aButtonId==EEikBidBrowse) sl@0: { sl@0: HandleBrowseButtonL(); sl@0: return EFalse; sl@0: } sl@0: else sl@0: { sl@0: CEikFileNameEditor* fileNameEditor=(CEikFileNameEditor*)(Control(EEikCidFileNameEd)); sl@0: TFileName* fullName=new(ELeave) TFileName; sl@0: CleanupStack::PushL(fullName); sl@0: fileNameEditor->GetFullNameL(*fullName); sl@0: TUint attributes=0; sl@0: if (!ConeUtils::FileExists(*fullName)) sl@0: { sl@0: ConeUtils::EnsurePathExistsL(*fullName); sl@0: } sl@0: else sl@0: { sl@0: TBuf<32> infoDialogTitle; sl@0: iEikonEnv->ReadResource(infoDialogTitle,R_EIK_TBUF_DIALOG_TITLE_CONFIRM_FILE_REPLACE); sl@0: TBuf formatStr; sl@0: User::LeaveIfError(iEikonEnv->FsSession().Att(*fullName,attributes)); sl@0: if (attributes&KEntryAttReadOnly) sl@0: { sl@0: iEikonEnv->LeaveWithInfoMsg(R_EIK_TBUF_CANNOT_REPLACE_READONLY_FILE); sl@0: } sl@0: else sl@0: { sl@0: iEikonEnv->ReadResource(formatStr,R_EIK_TBUF_FILE_REPLACE_CONFIRM1); sl@0: } sl@0: TBuf abbrevName; sl@0: User::LeaveIfError(EikFileUtils::Parse(*fullName)); sl@0: TParsePtr parse(*fullName); sl@0: EikFileUtils::AbbreviateFileName(parse.NameAndExt(),abbrevName); sl@0: TBuf textMsg; sl@0: textMsg.Format(formatStr,&abbrevName); sl@0: CEikDialog* infoDialog=new(ELeave) CEikInfoDialog(infoDialogTitle,textMsg,CEikInfoDialog::EIgnoreEnter); sl@0: *iReplace = infoDialog->ExecuteLD(R_EIK_DIALOG_SINGLE_FILE_REPLACE); sl@0: } sl@0: // check disk is present in selected drive sl@0: TParsePtrC parse(*fullName); sl@0: TPtrC drv=parse.Drive(); sl@0: TBuf<4> root(drv); sl@0: root.Append(TChar(KPathDelimiter)); sl@0: root.Append(KAnyFile); sl@0: RDir dir; sl@0: const TInt ret=dir.Open(iEikonEnv->FsSession(),root,EFileRead|EFileShareAny); sl@0: if (ret==KErrNotReady) sl@0: { sl@0: iEikonEnv->LeaveWithInfoMsg(R_EIK_TBUF_DISK_NOT_PRESENT); sl@0: } sl@0: if (ret==KErrNone) sl@0: { sl@0: dir.Close(); sl@0: } sl@0: // sl@0: iFilename=*fullName; sl@0: CleanupStack::PopAndDestroy(); // fullName sl@0: return ETrue; sl@0: } sl@0: }