summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermenufile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewermenufile.cpp')
-rw-r--r--indra/newview/llviewermenufile.cpp117
1 files changed, 110 insertions, 7 deletions
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 4efc3d1cb3..28ff69eaf5 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -46,6 +46,7 @@
#include "llimagejpeg.h"
#include "llimagetga.h"
#include "llinventorymodel.h" // gInventory
+#include "llpluginclassmedia.h"
#include "llresourcedata.h"
#include "lltoast.h"
#include "llfloaterperms.h"
@@ -251,6 +252,25 @@ void LLFilePickerReplyThread::notify(const std::vector<std::string>& filenames)
}
}
+
+LLMediaFilePicker::LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple)
+ : LLFilePickerThread(filter, get_multiple),
+ mPlugin(plugin->getSharedPrt())
+{
+}
+
+LLMediaFilePicker::LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name)
+ : LLFilePickerThread(filter, proposed_name),
+ mPlugin(plugin->getSharedPrt())
+{
+}
+
+void LLMediaFilePicker::notify(const std::vector<std::string>& filenames)
+{
+ mPlugin->sendPickFileResponse(mResponses);
+ mPlugin = NULL;
+}
+
//============================================================================
#if LL_WINDOWS
@@ -549,13 +569,8 @@ class LLFileUploadModel : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
- LLFloaterModelPreview* fmp = (LLFloaterModelPreview*) LLFloaterReg::getInstance("upload_model");
- if (fmp && !fmp->isModelLoading())
- {
- fmp->loadHighLodModel();
- }
-
- return TRUE;
+ LLFloaterModelPreview::showModelPreview();
+ return TRUE;
}
};
@@ -773,6 +788,94 @@ void handle_compress_image(void*)
}
}
+// No convinient check in LLFile, and correct way would be something
+// like GetFileSizeEx, which is too OS specific for current purpose
+// so doing dirty, but OS independent fopen and fseek
+size_t get_file_size(std::string &filename)
+{
+ LLFILE* file = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/
+ if (!file)
+ {
+ LL_WARNS() << "Error opening " << filename << LL_ENDL;
+ return 0;
+ }
+
+ // read in the whole file
+ fseek(file, 0L, SEEK_END);
+ size_t file_length = (size_t)ftell(file);
+ fclose(file);
+ return file_length;
+}
+
+void handle_compress_file_test(void*)
+{
+ LLFilePicker& picker = LLFilePicker::instance();
+ if (picker.getOpenFile())
+ {
+ std::string infile = picker.getFirstFile();
+ if (!infile.empty())
+ {
+ std::string packfile = infile + ".pack_test";
+ std::string unpackfile = infile + ".unpack_test";
+
+ S64Bytes initial_size = S64Bytes(get_file_size(infile));
+
+ BOOL success;
+
+ F64 total_seconds = LLTimer::getTotalSeconds();
+ success = gzip_file(infile, packfile);
+ F64 result_pack_seconds = LLTimer::getTotalSeconds() - total_seconds;
+
+ if (success)
+ {
+ S64Bytes packed_size = S64Bytes(get_file_size(packfile));
+
+ LL_INFOS() << "Packing complete, time: " << result_pack_seconds << " size: " << packed_size << LL_ENDL;
+ total_seconds = LLTimer::getTotalSeconds();
+ success = gunzip_file(packfile, unpackfile);
+ F64 result_unpack_seconds = LLTimer::getTotalSeconds() - total_seconds;
+
+ if (success)
+ {
+ S64Bytes unpacked_size = S64Bytes(get_file_size(unpackfile));
+
+ LL_INFOS() << "Unpacking complete, time: " << result_unpack_seconds << " size: " << unpacked_size << LL_ENDL;
+
+ LLSD args;
+ args["FILE"] = infile;
+ args["PACK_TIME"] = result_pack_seconds;
+ args["UNPACK_TIME"] = result_unpack_seconds;
+ args["SIZE"] = LLSD::Integer(initial_size.valueInUnits<LLUnits::Kilobytes>());
+ args["PSIZE"] = LLSD::Integer(packed_size.valueInUnits<LLUnits::Kilobytes>());
+ args["USIZE"] = LLSD::Integer(unpacked_size.valueInUnits<LLUnits::Kilobytes>());
+ LLNotificationsUtil::add("CompressionTestResults", args);
+
+ LLFile::remove(packfile);
+ LLFile::remove(unpackfile);
+ }
+ else
+ {
+ LL_INFOS() << "Failed to uncompress file: " << packfile << LL_ENDL;
+ LLFile::remove(packfile);
+ }
+
+ }
+ else
+ {
+ LL_INFOS() << "Failed to compres file: " << infile << LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_INFOS() << "Failed to open file" << LL_ENDL;
+ }
+ }
+ else
+ {
+ LL_INFOS() << "Failed to open file" << LL_ENDL;
+ }
+}
+
LLUUID upload_new_resource(
const std::string& src_filename,