diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llplugin/llpluginclassmedia.cpp | 19 | ||||
-rw-r--r-- | indra/llplugin/llpluginclassmedia.h | 6 | ||||
-rw-r--r-- | indra/media_plugins/cef/media_plugin_cef.cpp | 94 | ||||
-rw-r--r-- | indra/newview/llmediactrl.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewermedia.cpp | 34 |
5 files changed, 118 insertions, 37 deletions
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index 680017204c..9d275c5eeb 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -792,15 +792,22 @@ F64 LLPluginClassMedia::getCPUUsage() return result; } -void LLPluginClassMedia::sendPickFileResponse(const std::string &file) +void LLPluginClassMedia::sendPickFileResponse(const std::vector<std::string> files) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "pick_file_response"); - message.setValue("file", file); if(mPlugin && mPlugin->isBlocked()) { // If the plugin sent a blocking pick-file request, the response should unblock it. message.setValueBoolean("blocking_response", true); } + + LLSD file_list = LLSD::emptyArray(); + for (std::vector<std::string>::const_iterator in_iter = files.begin(); in_iter != files.end(); ++in_iter) + { + file_list.append(LLSD::String(*in_iter)); + } + message.setValueLLSD("file_list", file_list); + sendMessage(message); } @@ -1090,6 +1097,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) } else if(message_name == "pick_file") { + mIsMultipleFilePick = message.getValueBoolean("multiple_files"); mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_PICK_FILE_REQUEST); } else if(message_name == "auth_request") @@ -1151,7 +1159,12 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) { mClickURL = message.getValue("uri"); mClickTarget = message.getValue("target"); - mClickUUID = message.getValue("uuid"); + + // need a link to have a UUID that identifies it to a system further + // upstream - plugin could make it but we have access to LLUUID here + // so why don't we use it + mClickUUID = LLUUID::generateNewID().asString(); + mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_CLICK_LINK_HREF); } else if(message_name == "click_nofollow") diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 3b0739d044..98c48cd987 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -176,7 +176,7 @@ public: F64 getCPUUsage(); - void sendPickFileResponse(const std::string &file); + void sendPickFileResponse(const std::vector<std::string> files); void sendAuthResponse(bool ok, const std::string &username, const std::string &password); @@ -277,6 +277,9 @@ public: std::string getAuthURL() const { return mAuthURL; }; std::string getAuthRealm() const { return mAuthRealm; }; + // These are valid during MEDIA_EVENT_PICK_FILE_REQUEST + bool getIsMultipleFilePick() const { return mIsMultipleFilePick; } + // These are valid during MEDIA_EVENT_LINK_HOVERED std::string getHoverText() const { return mHoverText; }; std::string getHoverLink() const { return mHoverLink; }; @@ -435,6 +438,7 @@ protected: std::string mHoverText; std::string mHoverLink; std::string mFileDownloadFilename; + bool mIsMultipleFilePick; ///////////////////////////////////////// // media_time class diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp index f3d7762a08..a8d37a1d0a 100644 --- a/indra/media_plugins/cef/media_plugin_cef.cpp +++ b/indra/media_plugins/cef/media_plugin_cef.cpp @@ -38,6 +38,7 @@ #include "media_plugin_base.h" #include <functional> +#include <chrono> #include "dullahan.h" @@ -64,12 +65,12 @@ private: void onLoadStartCallback(); void onRequestExitCallback(); void onLoadEndCallback(int httpStatusCode); + void onLoadError(int status, const std::string error_text); void onAddressChangeCallback(std::string url); void onNavigateURLCallback(std::string url, std::string target); bool onHTTPAuthCallback(const std::string host, const std::string realm, std::string& username, std::string& password); void onCursorChangedCallback(dullahan::ECursorType type); - void onFileDownloadCallback(std::string filename); - const std::string onFileDialogCallback(); + const std::vector<std::string> onFileDialog(dullahan::EFileDialogType dialog_type, const std::string dialog_title, const std::string default_file, const std::string dialog_accept_filter, bool& use_default); void postDebugMessage(const std::string& msg); void authResponse(LLPluginMessage &message); @@ -95,7 +96,7 @@ private: bool mCanPaste; std::string mCachePath; std::string mCookiePath; - std::string mPickedFile; + std::vector<std::string> mPickedFiles; VolumeCatcher mVolumeCatcher; F32 mCurVolume; dullahan* mCEFLib; @@ -115,7 +116,7 @@ MediaPluginBase(host_send_func, host_user_data) mCookiesEnabled = true; mPluginsEnabled = false; mJavascriptEnabled = true; - mDisableGPU = true; + mDisableGPU = false; mUserAgentSubtring = ""; mAuthUsername = ""; mAuthPassword = ""; @@ -125,7 +126,7 @@ MediaPluginBase(host_send_func, host_user_data) mCanPaste = false; mCachePath = ""; mCookiePath = ""; - mPickedFile = ""; + mPickedFiles.clear(); mCurVolume = 0.0; mCEFLib = new dullahan(); @@ -208,6 +209,21 @@ void MediaPluginCEF::onLoadStartCallback() sendMessage(message); } +///////////////////////////////////////////////////////////////////////////////// +// +void MediaPluginCEF::onLoadError(int status, const std::string error_text) +{ + std::stringstream msg; + + msg << "<b>Loading error!</b>"; + msg << "<p>"; + msg << "Message: " << error_text; + msg << "<br>"; + msg << "Code: " << status; + + mCEFLib->showBrowserMessage(msg.str()); +} + //////////////////////////////////////////////////////////////////////////////// // void MediaPluginCEF::onRequestExitCallback() @@ -246,7 +262,6 @@ void MediaPluginCEF::onNavigateURLCallback(std::string url, std::string target) LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "click_href"); message.setValue("uri", url); message.setValue("target", target); - message.setValue("uuid", ""); // not used right now sendMessage(message); } @@ -285,30 +300,52 @@ bool MediaPluginCEF::onHTTPAuthCallback(const std::string host, const std::strin //////////////////////////////////////////////////////////////////////////////// // -void MediaPluginCEF::onFileDownloadCallback(const std::string filename) +const std::vector<std::string> MediaPluginCEF::onFileDialog(dullahan::EFileDialogType dialog_type, const std::string dialog_title, const std::string default_file, std::string dialog_accept_filter, bool& use_default) { - mAuthOK = false; + // do not use the default CEF file picker + use_default = false; - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "file_download"); - message.setValue("filename", filename); + if (dialog_type == dullahan::FD_OPEN_FILE) + { + mPickedFiles.clear(); - sendMessage(message); -} + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "pick_file"); + message.setValueBoolean("blocking_request", true); + message.setValueBoolean("multiple_files", false); -//////////////////////////////////////////////////////////////////////////////// -// -const std::string MediaPluginCEF::onFileDialogCallback() -{ - mPickedFile.clear(); + sendMessage(message); - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "pick_file"); - message.setValueBoolean("blocking_request", true); + return mPickedFiles; + } + else if (dialog_type == dullahan::FD_OPEN_MULTIPLE_FILES) + { + mPickedFiles.clear(); - sendMessage(message); + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "pick_file"); + message.setValueBoolean("blocking_request", true); + message.setValueBoolean("multiple_files", true); - return mPickedFile; + sendMessage(message); + + return mPickedFiles; + } + else if (dialog_type == dullahan::FD_SAVE_FILE) + { + mAuthOK = false; + + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "file_download"); + message.setValue("filename", default_file); + + sendMessage(message); + + return std::vector<std::string>(); + } + + return std::vector<std::string>(); } +//////////////////////////////////////////////////////////////////////////////// +// void MediaPluginCEF::onCursorChangedCallback(dullahan::ECursorType type) { std::string name = ""; @@ -341,6 +378,8 @@ void MediaPluginCEF::onCursorChangedCallback(dullahan::ECursorType type) sendMessage(message); } +//////////////////////////////////////////////////////////////////////////////// +// void MediaPluginCEF::authResponse(LLPluginMessage &message) { mAuthOK = message.getValueBoolean("ok"); @@ -439,11 +478,11 @@ void MediaPluginCEF::receiveMessage(const char* message_string) mCEFLib->setOnTitleChangeCallback(std::bind(&MediaPluginCEF::onTitleChangeCallback, this, std::placeholders::_1)); mCEFLib->setOnLoadStartCallback(std::bind(&MediaPluginCEF::onLoadStartCallback, this)); mCEFLib->setOnLoadEndCallback(std::bind(&MediaPluginCEF::onLoadEndCallback, this, std::placeholders::_1)); + mCEFLib->setOnLoadErrorCallback(std::bind(&MediaPluginCEF::onLoadError, this, std::placeholders::_1, std::placeholders::_2)); mCEFLib->setOnAddressChangeCallback(std::bind(&MediaPluginCEF::onAddressChangeCallback, this, std::placeholders::_1)); mCEFLib->setOnNavigateURLCallback(std::bind(&MediaPluginCEF::onNavigateURLCallback, this, std::placeholders::_1, std::placeholders::_2)); mCEFLib->setOnHTTPAuthCallback(std::bind(&MediaPluginCEF::onHTTPAuthCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); - mCEFLib->setOnFileDownloadCallback(std::bind(&MediaPluginCEF::onFileDownloadCallback, this, std::placeholders::_1)); - mCEFLib->setOnFileDialogCallback(std::bind(&MediaPluginCEF::onFileDialogCallback, this)); + mCEFLib->setOnFileDialogCallback(std::bind(&MediaPluginCEF::onFileDialog, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); mCEFLib->setOnCursorChangedCallback(std::bind(&MediaPluginCEF::onCursorChangedCallback, this, std::placeholders::_1)); mCEFLib->setOnRequestExitCallback(std::bind(&MediaPluginCEF::onRequestExitCallback, this)); @@ -650,7 +689,14 @@ void MediaPluginCEF::receiveMessage(const char* message_string) } if (message_name == "pick_file_response") { - mPickedFile = message_in.getValue("file"); + LLSD file_list_llsd = message_in.getValueLLSD("file_list"); + + LLSD::array_const_iterator iter = file_list_llsd.beginArray(); + LLSD::array_const_iterator end = file_list_llsd.endArray(); + for (; iter != end; ++iter) + { + mPickedFiles.push_back(((*iter).asString())); + } } if (message_name == "auth_response") { diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index a8025906c7..7f6955d08c 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -1022,7 +1022,7 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) // try as slurl first if (!LLURLDispatcher::dispatch(url, "clicked", NULL, mTrusted)) { - LLWeb::loadURL(url, target, std::string()); + LLWeb::loadURL(url, target, uuid); } // CP: removing this code because we no longer support popups so this breaks the flow. diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 114f1d327b..9dd8b00ef6 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -3480,22 +3480,40 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla case LLViewerMediaObserver::MEDIA_EVENT_PICK_FILE_REQUEST: { - // Display a file picker - std::string response; - LLFilePicker& picker = LLFilePicker::instance(); - if (!picker.getOpenFile(LLFilePicker::FFLOAD_ALL)) + std::vector<std::string> responses; + + bool pick_multiple_files = plugin->getIsMultipleFilePick(); + if (pick_multiple_files == false) { - // The user didn't pick a file -- the empty response string will indicate this. + picker.getOpenFile(LLFilePicker::FFLOAD_ALL); + + std::string filename = picker.getFirstFile(); + responses.push_back(filename); } + else + { + if (picker.getMultipleOpenFiles()) + { + std::string filename = picker.getFirstFile(); - response = picker.getFirstFile(); + responses.push_back(filename); - plugin->sendPickFileResponse(response); + while (!filename.empty()) + { + filename = picker.getNextFile(); + + if (!filename.empty()) + { + responses.push_back(filename); + } + } + } + } + plugin->sendPickFileResponse(responses); } break; - case LLViewerMediaObserver::MEDIA_EVENT_AUTH_REQUEST: { LLNotification::Params auth_request_params; |