From 266b3843b75fb9b8da7d2b3c824224a1b94697a5 Mon Sep 17 00:00:00 2001 From: callum Date: Tue, 21 Sep 2010 16:41:06 -0700 Subject: EXP-94 Disable local file system access --- indra/newview/llfilepicker.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'indra/newview/llfilepicker.cpp') diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index c14be89641..f0840774bd 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -33,6 +33,7 @@ #include "lldir.h" #include "llframetimer.h" #include "lltrans.h" +#include "llviewercontrol.h" #include "llwindow.h" // beforeDialog() #if LL_SDL @@ -104,6 +105,20 @@ LLFilePicker::~LLFilePicker() // nothing } +// utility function to check if access to local file system via file browser +// is enabled and if not, tidy up and indicate we're not allowed to do this. +bool LLFilePicker::check_local_file_access_enabled() +{ + // if local file browsing is turned off, return without opening dialog + bool local_file_system_browsing_enabled = gSavedSettings.getBOOL("LocalFileSystemBrowsingEnabled"); + if ( ! local_file_system_browsing_enabled ) + { + mFiles.clear(); + return false; + } + + return true; +} const std::string LLFilePicker::getFirstFile() { @@ -203,6 +218,12 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter) } BOOL success = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + // don't provide default file selection mFilesW[0] = '\0'; @@ -241,6 +262,12 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) } BOOL success = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + // don't provide default file selection mFilesW[0] = '\0'; @@ -304,6 +331,12 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) } BOOL success = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + mOFN.lpstrFile = mFilesW; if (!filename.empty()) { @@ -581,6 +614,12 @@ OSStatus LLFilePicker::doNavChooseDialog(ELoadFilter filter) NavDialogRef navRef = NULL; NavReplyRecord navReply; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + memset(&navReply, 0, sizeof(navReply)); // NOTE: we are passing the address of a local variable here. @@ -809,6 +848,12 @@ BOOL LLFilePicker::getOpenFile(ELoadFilter filter) BOOL success = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + OSStatus error = noErr; reset(); @@ -845,6 +890,12 @@ BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) BOOL success = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + OSStatus error = noErr; reset(); @@ -876,6 +927,12 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) BOOL success = FALSE; OSStatus error = noErr; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + reset(); mNavOptions.optionFlags &= ~kNavAllowMultipleFiles; @@ -1100,6 +1157,12 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename { BOOL rtn = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + gViewerWindow->mWindow->beforeDialog(); reset(); @@ -1189,6 +1252,12 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) { BOOL rtn = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + gViewerWindow->mWindow->beforeDialog(); reset(); @@ -1233,6 +1302,12 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) { BOOL rtn = FALSE; + // if local file browsing is turned off, return without opening dialog + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + gViewerWindow->mWindow->beforeDialog(); reset(); @@ -1263,6 +1338,13 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename ) { + // if local file browsing is turned off, return without opening dialog + // (Even though this is a stub, I think we still should not return anything at all) + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + reset(); llinfos << "getSaveFile suggested filename is [" << filename @@ -1277,6 +1359,13 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) { + // if local file browsing is turned off, return without opening dialog + // (Even though this is a stub, I think we still should not return anything at all) + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + reset(); // HACK: Static filenames for 'open' until we implement filepicker @@ -1295,6 +1384,13 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter ) BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter ) { + // if local file browsing is turned off, return without opening dialog + // (Even though this is a stub, I think we still should not return anything at all) + if ( check_local_file_access_enabled() == false ) + { + return FALSE; + } + reset(); return FALSE; } -- cgit v1.2.3