void CFileSelectionSettingItem::EditItemL(TBool /*aCalledFromMenu*/)
{
	// Select memory
	CAknMemorySelectionDialog* memSelectionDialog = CAknMemorySelectionDialog::NewL
		(ECFDDialogTypeNormal, /*aShowUnavailableDrives*/EFalse);
	CleanupStack::PushL(memSelectionDialog);

	CAknMemorySelectionDialog::TMemory mem(CAknMemorySelectionDialog::EPhoneMemory);

	TInt ret = memSelectionDialog->ExecuteL(mem);
	CleanupStack::PopAndDestroy(memSelectionDialog);
	if (!ret) return;

	CAknFileSelectionDialog* fileSelectionDialog = 
		CAknFileSelectionDialog::NewL(iDialogType);	
	CleanupStack::PushL(fileSelectionDialog);
	
	fileSelectionDialog->SetTitleL(_L("Download files to"));
	fileSelectionDialog->SetLeftSoftkeyFileL(_L("Select"));	
	
	if (mem == CAknMemorySelectionDialog::EMemoryCard)	
		iOwnedFileName = _L("E:\\");
	else
		iOwnedFileName = _L("C:\\");

	// launch file select dialog
	TBool result = fileSelectionDialog->ExecuteL(iOwnedFileName);
	CleanupStack::PopAndDestroy(); // fileSelectionDialog
	
	if (result)
		iFileName = iOwnedFileName;
}
Exemplo n.º 2
0
void CAafAppCameraView::SaveCapturedImageL()
{
	if (IsImageCaptured())
	{
		TFileName filePath(KNullDesC);
		
		// Create select memory dialog
		CAknMemorySelectionDialog* memDlg = 
			CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, ETrue);
		CAknMemorySelectionDialog::TMemory memory = 
			CAknMemorySelectionDialog::EPhoneMemory;

		// Create select folder dialog
		CAknFileSelectionDialog* dlg = 
			CAknFileSelectionDialog::NewL(ECFDDialogTypeCopy);

		// some dialog customizations:
		CEikonEnv* eikonEnv = CEikonEnv::Static();

		HBufC* stringHolder = StringLoader::LoadL(R_SELECT_FOLDER_DIALOG, eikonEnv );

		dlg->SetTitleL(*stringHolder);

		// Free dynamically allocated memory
		delete stringHolder;
		stringHolder = NULL;

		stringHolder = StringLoader::LoadL(R_BACK, eikonEnv );

		dlg->SetRightSoftkeyRootFolderL(*stringHolder); // for root folder

		// Free dynamically allocated memory
		delete stringHolder;
		stringHolder = NULL;

		TBool result = EFalse;

		for (;;)
		{
			if ( memDlg->ExecuteL(memory) == CAknFileSelectionDialog::ERightSoftkey )
			{
				// cancel selection
				break;
			}

			if (memory == CAknMemorySelectionDialog::EMemoryCard)
			{
				// Open images folder
				filePath = PathInfo::MemoryCardRootPath();
				filePath.Append(PathInfo::ImagesPath());
			}
			else
			{
				// Open images folder
				filePath = PathInfo::PhoneMemoryRootPath();
				filePath.Append(PathInfo::ImagesPath());
			}

			
			if (dlg->ExecuteL(filePath))
			{
				// we got our folder and finish loop
				result = ETrue;
				break;
			}
		}

		delete memDlg;
		delete dlg;

		if (filePath.Length() > 0)
		{
			// The descriptor used for the editor 
			TBuf<255> fileName; 
			// create dialog instance  
			CAknTextQueryDialog* dlgFilename = new( ELeave )CAknTextQueryDialog( fileName); 
			// Prepares the dialog, constructing it from the specified resource 
			dlgFilename->PrepareLC( R_FILENAME_QUERY ); 
			// Sets the maximum length of the text editor 
			dlgFilename->SetMaxLength(255); 
			// Launch the dialog 
			if (dlgFilename->RunLD()) 
			{ 
				// ok pressed,  text is the descriptor containing the entered text 
				// in the editor.
				filePath.Append(fileName);

				// ensure that saved file would have .jpg extension
				if (filePath.Right(4).Compare(KJpgExt) != 0)
					filePath.Append(KJpgExt);

				iContainer->SaveImage(filePath);
			} 
		}
	}	
}