From ac0bbba7a554834f763a0ffcd03fd25897bc374e Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 12 Nov 2019 11:45:39 +0200 Subject: SL-9699 Updated tooltip and initial checkbox value --- indra/newview/llfloaterforgetuser.cpp | 4 +++- indra/newview/skins/default/xui/en/floater_forget_user.xml | 1 - indra/newview/skins/default/xui/en/panel_login.xml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterforgetuser.cpp b/indra/newview/llfloaterforgetuser.cpp index 5659cb2f79..55e25ace9a 100644 --- a/indra/newview/llfloaterforgetuser.cpp +++ b/indra/newview/llfloaterforgetuser.cpp @@ -99,7 +99,9 @@ BOOL LLFloaterForgetUser::postBuild() } bool enable_button = scroll_list->getFirstSelectedIndex() != -1; - getChild("delete_data")->setEnabled(enable_button); + LLCheckBoxCtrl *chk_box = getChild("delete_data"); + chk_box->setEnabled(enable_button); + chk_box->set(FALSE); LLButton *button = getChild("forget"); button->setEnabled(enable_button); button->setCommitCallback(boost::bind(&LLFloaterForgetUser::onForgetClicked, this)); diff --git a/indra/newview/skins/default/xui/en/floater_forget_user.xml b/indra/newview/skins/default/xui/en/floater_forget_user.xml index 0673901a96..86228d49ee 100644 --- a/indra/newview/skins/default/xui/en/floater_forget_user.xml +++ b/indra/newview/skins/default/xui/en/floater_forget_user.xml @@ -35,6 +35,5 @@ name="delete_data" top_pad="5" width="260" - initial_value="1" tool_tip="Deletes local files: chat history, last session screenshot, browser cookies, teleport history, toolbar settings, e t c"/> diff --git a/indra/newview/skins/default/xui/en/panel_login.xml b/indra/newview/skins/default/xui/en/panel_login.xml index 873f03aae9..766406e1d8 100644 --- a/indra/newview/skins/default/xui/en/panel_login.xml +++ b/indra/newview/skins/default/xui/en/panel_login.xml @@ -137,7 +137,7 @@ label="Remember me" check_button.bottom="3" name="remember_name" - tool_tip="Already recorded user can be forgotten from preferences." + tool_tip="Already remembered user can be forgotten from Me > Preferences > Advanced > Remembered Usernames." width="145" /> Date: Wed, 13 Nov 2019 05:32:05 +0200 Subject: SL-11964 Removed SL Share from the viewer --- indra/newview/CMakeLists.txt | 8 - indra/newview/app_settings/commands.xml | 20 - indra/newview/llflickrconnect.cpp | 538 -------------- indra/newview/llflickrconnect.h | 108 --- indra/newview/llfloaterbigpreview.h | 2 +- indra/newview/llfloaterflickr.cpp | 787 -------------------- indra/newview/llfloaterflickr.h | 134 ---- indra/newview/llfloateroutfitsnapshot.cpp | 2 - indra/newview/llfloatersnapshot.cpp | 7 +- indra/newview/llfloatertwitter.cpp | 810 --------------------- indra/newview/llfloatertwitter.h | 138 ---- indra/newview/llfloaterwebcontent.cpp | 22 - indra/newview/llimagefiltersmanager.cpp | 2 +- indra/newview/llimagefiltersmanager.h | 2 +- indra/newview/llpanelsnapshotoptions.cpp | 30 +- indra/newview/llsnapshotlivepreview.cpp | 2 - indra/newview/lltwitterconnect.cpp | 576 --------------- indra/newview/lltwitterconnect.h | 107 --- indra/newview/llviewerfloaterreg.cpp | 7 - indra/newview/llviewerregion.cpp | 2 - indra/newview/skins/default/textures/textures.xml | 2 - .../skins/default/xui/en/floater_flickr.xml | 90 --- .../skins/default/xui/en/floater_twitter.xml | 75 -- indra/newview/skins/default/xui/en/menu_viewer.xml | 15 - .../newview/skins/default/xui/en/notifications.xml | 14 - .../skins/default/xui/en/panel_flickr_account.xml | 79 -- .../skins/default/xui/en/panel_flickr_photo.xml | 259 ------- .../default/xui/en/panel_snapshot_options.xml | 34 - .../skins/default/xui/en/panel_twitter_account.xml | 81 --- .../skins/default/xui/en/panel_twitter_photo.xml | 196 ----- indra/newview/skins/default/xui/en/strings.xml | 27 +- 31 files changed, 6 insertions(+), 4170 deletions(-) delete mode 100644 indra/newview/llflickrconnect.cpp delete mode 100644 indra/newview/llflickrconnect.h delete mode 100644 indra/newview/llfloaterflickr.cpp delete mode 100644 indra/newview/llfloaterflickr.h delete mode 100644 indra/newview/llfloatertwitter.cpp delete mode 100644 indra/newview/llfloatertwitter.h delete mode 100644 indra/newview/lltwitterconnect.cpp delete mode 100644 indra/newview/lltwitterconnect.h delete mode 100644 indra/newview/skins/default/xui/en/floater_flickr.xml delete mode 100644 indra/newview/skins/default/xui/en/floater_twitter.xml delete mode 100644 indra/newview/skins/default/xui/en/panel_flickr_account.xml delete mode 100644 indra/newview/skins/default/xui/en/panel_flickr_photo.xml delete mode 100644 indra/newview/skins/default/xui/en/panel_twitter_account.xml delete mode 100644 indra/newview/skins/default/xui/en/panel_twitter_photo.xml (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 694e89ab99..04f6c9b7f0 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -208,7 +208,6 @@ set(viewer_SOURCE_FILES llfilteredwearablelist.cpp llfirstuse.cpp llflexibleobject.cpp - llflickrconnect.cpp llfloaterabout.cpp llfloaterbvhpreview.cpp llfloaterauction.cpp @@ -244,7 +243,6 @@ set(viewer_SOURCE_FILES llfloaterexperiencepicker.cpp llfloaterexperienceprofile.cpp llfloaterexperiences.cpp - llfloaterflickr.cpp llfloaterfonttest.cpp llfloatergesture.cpp llfloatergodtools.cpp @@ -317,7 +315,6 @@ set(viewer_SOURCE_FILES llfloatertos.cpp llfloatertoybox.cpp llfloatertranslationsettings.cpp - llfloatertwitter.cpp llfloateruipreview.cpp llfloaterurlentry.cpp llfloatervoiceeffect.cpp @@ -615,7 +612,6 @@ set(viewer_SOURCE_FILES lltransientdockablefloater.cpp lltransientfloatermgr.cpp lltranslate.cpp - lltwitterconnect.cpp lluiavatar.cpp lluilistener.cpp lluploaddialog.cpp @@ -833,7 +829,6 @@ set(viewer_HEADER_FILES llfilteredwearablelist.h llfirstuse.h llflexibleobject.h - llflickrconnect.h llfloaterabout.h llfloaterbvhpreview.h llfloaterauction.h @@ -869,7 +864,6 @@ set(viewer_HEADER_FILES llfloaterexperiencepicker.h llfloaterexperienceprofile.h llfloaterexperiences.h - llfloaterflickr.h llfloaterfonttest.h llfloatergesture.h llfloatergodtools.h @@ -945,7 +939,6 @@ set(viewer_HEADER_FILES llfloatertos.h llfloatertoybox.h llfloatertranslationsettings.h - llfloatertwitter.h llfloateruipreview.h llfloaterurlentry.h llfloatervoiceeffect.h @@ -1233,7 +1226,6 @@ set(viewer_HEADER_FILES lltransientdockablefloater.h lltransientfloatermgr.h lltranslate.h - lltwitterconnect.h lluiconstants.h lluiavatar.h lluilistener.h diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index cab0c523b2..fa37dea51b 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -228,26 +228,6 @@ is_running_function="Floater.IsOpen" is_running_parameters="snapshot" /> - - LLFlickrConnect::sStateWatcher(new LLEventStream("FlickrConnectState")); -boost::scoped_ptr LLFlickrConnect::sInfoWatcher(new LLEventStream("FlickrConnectInfo")); -boost::scoped_ptr LLFlickrConnect::sContentWatcher(new LLEventStream("FlickrConnectContent")); - -// Local functions -void log_flickr_connect_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description) -{ - // Note: 302 (redirect) is *not* an error that warrants logging - if (status != 302) - { - LL_WARNS("FlickrConnect") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << " (" << description << ")" << LL_ENDL; - } -} - -void toast_user_for_flickr_success() -{ - LLSD args; - args["MESSAGE"] = LLTrans::getString("flickr_post_success"); - LLNotificationsUtil::add("FlickrConnect", args); -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLFlickrConnect::flickrConnectCoro(std::string requestToken, std::string oauthVerifier) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - LLSD body; - if (!requestToken.empty()) - body["request_token"] = requestToken; - if (!oauthVerifier.empty()) - body["oauth_verifier"] = oauthVerifier; - - setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); - - LLSD result = httpAdapter->putAndSuspend(httpRequest, getFlickrConnectURL("/connection"), body, httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - if ( status == LLCore::HttpStatus(HTTP_FOUND) ) - { - std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; - if (location.empty()) - { - LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; - } - else - { - openFlickrWeb(location); - } - } - else - { - LL_WARNS("FlickrConnect") << "Connection failed " << status.toString() << LL_ENDL; - setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); - log_flickr_connect_error("Connect", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - } - else - { - LL_DEBUGS("FlickrConnect") << "Connect successful. " << LL_ENDL; - setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -bool LLFlickrConnect::testShareStatus(LLSD &result) -{ - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (status) - return true; - - if (status == LLCore::HttpStatus(HTTP_FOUND)) - { - std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; - if (location.empty()) - { - LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; - } - else - { - openFlickrWeb(location); - } - } - if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) - { - LL_DEBUGS("FlickrConnect") << "Not connected. " << LL_ENDL; - connectToFlickr(); - } - else - { - LL_WARNS("FlickrConnect") << "HTTP Status error " << status.toString() << LL_ENDL; - setConnectionState(LLFlickrConnect::FLICKR_POST_FAILED); - log_flickr_connect_error("Share", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - return false; -} - -void LLFlickrConnect::flickrShareCoro(LLSD share) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - LLSD result = httpAdapter->postAndSuspend(httpRequest, getFlickrConnectURL("/share/photo", true), share, httpOpts); - - if (testShareStatus(result)) - { - toast_user_for_flickr_success(); - LL_DEBUGS("FlickrConnect") << "Post successful. " << LL_ENDL; - setConnectionState(LLFlickrConnect::FLICKR_POSTED); - } - -} - -void LLFlickrConnect::flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - std::string imageFormat; - if (dynamic_cast(image.get())) - { - imageFormat = "png"; - } - else if (dynamic_cast(image.get())) - { - imageFormat = "jpg"; - } - else - { - LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; - return; - } - - // All this code is mostly copied from LLWebProfile::post() - const std::string boundary = "----------------------------0123abcdefab"; - - std::string contentType = "multipart/form-data; boundary=" + boundary; - httpHeaders->append("Content-Type", contentType.c_str()); - - LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // - LLCore::BufferArrayStream body(raw.get()); - - // *NOTE: The order seems to matter. - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"title\"\r\n\r\n" - << title << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"description\"\r\n\r\n" - << description << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"tags\"\r\n\r\n" - << tags << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"safety_level\"\r\n\r\n" - << safetyLevel << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" - << "Content-Type: image/" << imageFormat << "\r\n\r\n"; - - // Insert the image data. - // *FIX: Treating this as a string will probably screw it up ... - U8* image_data = image->getData(); - for (S32 i = 0; i < image->getDataSize(); ++i) - { - body << image_data[i]; - } - - body << "\r\n--" << boundary << "--\r\n"; - - LLSD result = httpAdapter->postAndSuspend(httpRequest, getFlickrConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); - - if (testShareStatus(result)) - { - toast_user_for_flickr_success(); - LL_DEBUGS("FlickrConnect") << "Post successful. " << LL_ENDL; - setConnectionState(LLFlickrConnect::FLICKR_POSTED); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLFlickrConnect::flickrDisconnectCoro() -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - setConnectionState(LLFlickrConnect::FLICKR_DISCONNECTING); - httpOpts->setFollowRedirects(false); - - LLSD result = httpAdapter->deleteAndSuspend(httpRequest, getFlickrConnectURL("/connection"), httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND))) - { - LL_WARNS("FlickrConnect") << "Disconnect failed!" << LL_ENDL; - setConnectionState(LLFlickrConnect::FLICKR_DISCONNECT_FAILED); - - log_flickr_connect_error("Disconnect", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - else - { - LL_DEBUGS("FlickrConnect") << "Disconnect successful. " << LL_ENDL; - clearInfo(); - setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLFlickrConnect::flickrConnectedCoro(bool autoConnect) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS); - - httpOpts->setFollowRedirects(false); - - LLSD result = httpAdapter->getAndSuspend(httpRequest, getFlickrConnectURL("/connection", true), httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) - { - LL_DEBUGS("FlickrConnect") << "Not connected. " << LL_ENDL; - if (autoConnect) - { - connectToFlickr(); - } - else - { - setConnectionState(LLFlickrConnect::FLICKR_NOT_CONNECTED); - } - } - else - { - LL_WARNS("FlickrConnect") << "Failed to test connection:" << status.toTerseString() << LL_ENDL; - - setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); - log_flickr_connect_error("Connected", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - } - else - { - LL_DEBUGS("FlickrConnect") << "Connect successful. " << LL_ENDL; - setConnectionState(LLFlickrConnect::FLICKR_CONNECTED); - } - -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLFlickrConnect::flickrInfoCoro() -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - LLSD result = httpAdapter->getAndSuspend(httpRequest, getFlickrConnectURL("/info", true), httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (status == LLCore::HttpStatus(HTTP_FOUND)) - { - std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; - if (location.empty()) - { - LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; - } - else - { - openFlickrWeb(location); - } - } - else if (!status) - { - LL_WARNS("FlickrConnect") << "Flickr Info failed: " << status.toString() << LL_ENDL; - log_flickr_connect_error("Info", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - else - { - LL_INFOS("FlickrConnect") << "Flickr: Info received" << LL_ENDL; - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - storeInfo(result); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -LLFlickrConnect::LLFlickrConnect() -: mConnectionState(FLICKR_NOT_CONNECTED), - mConnected(false), - mInfo(), - mRefreshInfo(false), - mReadFromMaster(false) -{ -} - -void LLFlickrConnect::openFlickrWeb(std::string url) -{ - LLFloaterWebContent::Params p; - p.url(url); - p.show_chrome(true); - p.allow_back_forward_navigation(false); - p.clean_browser(true); - LLFloater *floater = LLFloaterReg::showInstance("flickr_web", p); - //the internal web browser has a bug that prevents it from gaining focus unless a mouse event occurs first (it seems). - //So when showing the internal web browser, set focus to it's containing floater "flickr_web". When a mouse event - //occurs on the "webbrowser" panel part of the floater, a mouse cursor will properly show and the "webbrowser" will gain focus. - //flickr_web floater contains the "webbrowser" panel. JIRA: ACME-744 - gFocusMgr.setKeyboardFocus( floater ); - - //LLUrlAction::openURLExternal(url); -} - -std::string LLFlickrConnect::getFlickrConnectURL(const std::string& route, bool include_read_from_master) -{ - std::string url(""); - LLViewerRegion *regionp = gAgent.getRegion(); - if (regionp) - { - //url = "http://pdp15.lindenlab.com/flickr/agent/" + gAgentID.asString(); // TEMPORARY FOR TESTING - CHO - url = regionp->getCapability("FlickrConnect"); - url += route; - - if (include_read_from_master && mReadFromMaster) - { - url += "?read_from_master=true"; - } - } - return url; -} - -void LLFlickrConnect::connectToFlickr(const std::string& request_token, const std::string& oauth_verifier) -{ - LLCoros::instance().launch("LLFlickrConnect::flickrConnectCoro", - boost::bind(&LLFlickrConnect::flickrConnectCoro, this, request_token, oauth_verifier)); -} - -void LLFlickrConnect::disconnectFromFlickr() -{ - LLCoros::instance().launch("LLFlickrConnect::flickrDisconnectCoro", - boost::bind(&LLFlickrConnect::flickrDisconnectCoro, this)); -} - -void LLFlickrConnect::checkConnectionToFlickr(bool auto_connect) -{ - LLCoros::instance().launch("LLFlickrConnect::flickrConnectedCoro", - boost::bind(&LLFlickrConnect::flickrConnectedCoro, this, auto_connect)); -} - -void LLFlickrConnect::loadFlickrInfo() -{ - if(mRefreshInfo) - { - LLCoros::instance().launch("LLFlickrConnect::flickrInfoCoro", - boost::bind(&LLFlickrConnect::flickrInfoCoro, this)); - } -} - -void LLFlickrConnect::uploadPhoto(const std::string& image_url, const std::string& title, const std::string& description, const std::string& tags, int safety_level) -{ - LLSD body; - body["image"] = image_url; - body["title"] = title; - body["description"] = description; - body["tags"] = tags; - body["safety_level"] = safety_level; - - setConnectionState(LLFlickrConnect::FLICKR_POSTING); - - LLCoros::instance().launch("LLFlickrConnect::flickrShareCoro", - boost::bind(&LLFlickrConnect::flickrShareCoro, this, body)); -} - -void LLFlickrConnect::uploadPhoto(LLPointer image, const std::string& title, const std::string& description, const std::string& tags, int safety_level) -{ - setConnectionState(LLFlickrConnect::FLICKR_POSTING); - - LLCoros::instance().launch("LLFlickrConnect::flickrShareImageCoro", - boost::bind(&LLFlickrConnect::flickrShareImageCoro, this, image, - title, description, tags, safety_level)); -} - -void LLFlickrConnect::storeInfo(const LLSD& info) -{ - mInfo = info; - mRefreshInfo = false; - - sInfoWatcher->post(info); -} - -const LLSD& LLFlickrConnect::getInfo() const -{ - return mInfo; -} - -void LLFlickrConnect::clearInfo() -{ - mInfo = LLSD(); -} - -void LLFlickrConnect::setDataDirty() -{ - mRefreshInfo = true; -} - -void LLFlickrConnect::setConnectionState(LLFlickrConnect::EConnectionState connection_state) -{ - if(connection_state == FLICKR_CONNECTED) - { - mReadFromMaster = true; - setConnected(true); - setDataDirty(); - } - else if(connection_state == FLICKR_NOT_CONNECTED) - { - setConnected(false); - } - else if(connection_state == FLICKR_POSTED) - { - mReadFromMaster = false; - } - - if (mConnectionState != connection_state) - { - // set the connection state before notifying watchers - mConnectionState = connection_state; - - LLSD state_info; - state_info["enum"] = connection_state; - sStateWatcher->post(state_info); - } -} - -void LLFlickrConnect::setConnected(bool connected) -{ - mConnected = connected; -} diff --git a/indra/newview/llflickrconnect.h b/indra/newview/llflickrconnect.h deleted file mode 100644 index 43cadca708..0000000000 --- a/indra/newview/llflickrconnect.h +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file llflickrconnect.h - * @author Merov, Cho - * @brief Connection to Flickr Service - * - * $LicenseInfo:firstyear=2013&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2013, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFLICKRCONNECT_H -#define LL_LLFLICKRCONNECT_H - -#include "llsingleton.h" -#include "llimage.h" -#include "llcoros.h" -#include "lleventcoro.h" - -class LLEventPump; - -/** - * @class LLFlickrConnect - * - * Manages authentication to, and interaction with, a web service allowing the - * the viewer to upload photos to Flickr. - */ -class LLFlickrConnect : public LLSingleton -{ - LLSINGLETON(LLFlickrConnect); - ~LLFlickrConnect() {}; - LOG_CLASS(LLFlickrConnect); -public: - enum EConnectionState - { - FLICKR_NOT_CONNECTED = 0, - FLICKR_CONNECTION_IN_PROGRESS = 1, - FLICKR_CONNECTED = 2, - FLICKR_CONNECTION_FAILED = 3, - FLICKR_POSTING = 4, - FLICKR_POSTED = 5, - FLICKR_POST_FAILED = 6, - FLICKR_DISCONNECTING = 7, - FLICKR_DISCONNECT_FAILED = 8 - }; - - void connectToFlickr(const std::string& request_token = "", const std::string& oauth_verifier = ""); // Initiate the complete Flickr connection. Please use checkConnectionToFlickr() in normal use. - void disconnectFromFlickr(); // Disconnect from the Flickr service. - void checkConnectionToFlickr(bool auto_connect = false); // Check if an access token is available on the Flickr service. If not, call connectToFlickr(). - - void loadFlickrInfo(); - void uploadPhoto(const std::string& image_url, const std::string& title, const std::string& description, const std::string& tags, int safety_level); - void uploadPhoto(LLPointer image, const std::string& title, const std::string& description, const std::string& tags, int safety_level); - - void storeInfo(const LLSD& info); - const LLSD& getInfo() const; - void clearInfo(); - void setDataDirty(); - - void setConnectionState(EConnectionState connection_state); - void setConnected(bool connected); - bool isConnected() { return mConnected; } - bool isTransactionOngoing() { return ((mConnectionState == FLICKR_CONNECTION_IN_PROGRESS) || (mConnectionState == FLICKR_POSTING) || (mConnectionState == FLICKR_DISCONNECTING)); } - EConnectionState getConnectionState() { return mConnectionState; } - - void openFlickrWeb(std::string url); - -private: - - std::string getFlickrConnectURL(const std::string& route = "", bool include_read_from_master = false); - - EConnectionState mConnectionState; - BOOL mConnected; - LLSD mInfo; - bool mRefreshInfo; - bool mReadFromMaster; - - static boost::scoped_ptr sStateWatcher; - static boost::scoped_ptr sInfoWatcher; - static boost::scoped_ptr sContentWatcher; - - bool testShareStatus(LLSD &result); - void flickrConnectCoro(std::string requestToken, std::string oauthVerifier); - void flickrShareCoro(LLSD share); - void flickrShareImageCoro(LLPointer image, std::string title, std::string description, std::string tags, int safetyLevel); - void flickrDisconnectCoro(); - void flickrConnectedCoro(bool autoConnect); - void flickrInfoCoro(); - -}; - -#endif // LL_LLFLICKRCONNECT_H diff --git a/indra/newview/llfloaterbigpreview.h b/indra/newview/llfloaterbigpreview.h index 63c6784d36..513ed8da6e 100644 --- a/indra/newview/llfloaterbigpreview.h +++ b/indra/newview/llfloaterbigpreview.h @@ -1,6 +1,6 @@ /** * @file llfloaterbigpreview.h -* @brief Display of extended (big) preview for snapshots and SL Share +* @brief Display of extended (big) preview for snapshots * @author merov@lindenlab.com * * $LicenseInfo:firstyear=2013&license=viewerlgpl$ diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp deleted file mode 100644 index 69a92b2b54..0000000000 --- a/indra/newview/llfloaterflickr.cpp +++ /dev/null @@ -1,787 +0,0 @@ -/** -* @file llfloaterflickr.cpp -* @brief Implementation of llfloaterflickr -* @author cho@lindenlab.com -* -* $LicenseInfo:firstyear=2013&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2013, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#include "llviewerprecompiledheaders.h" - -#include "llfloaterflickr.h" - -#include "llagent.h" -#include "llagentui.h" -#include "llcheckboxctrl.h" -#include "llcombobox.h" -#include "llflickrconnect.h" -#include "llfloaterreg.h" -#include "lliconctrl.h" -#include "llimagefiltersmanager.h" -#include "llresmgr.h" // LLLocale -#include "llsdserialize.h" -#include "llloadingindicator.h" -#include "llslurl.h" -#include "lltrans.h" -#include "llsnapshotlivepreview.h" -#include "llfloaterbigpreview.h" -#include "llviewerregion.h" -#include "llviewercontrol.h" -#include "llviewermedia.h" -#include "lltabcontainer.h" -#include "llviewerparcelmgr.h" -#include "llviewerregion.h" -#include -static LLPanelInjector t_panel_photo("llflickrphotopanel"); -static LLPanelInjector t_panel_account("llflickraccountpanel"); - -const std::string DEFAULT_PHOTO_QUERY_PARAMETERS = "?sourceid=slshare_photo&utm_source=flickr&utm_medium=photo&utm_campaign=slshare"; -const std::string DEFAULT_TAG_TEXT = "secondlife "; -const std::string FLICKR_MACHINE_TAGS_NAMESPACE = "secondlife"; - -/////////////////////////// -//LLFlickrPhotoPanel/////// -/////////////////////////// - -LLFlickrPhotoPanel::LLFlickrPhotoPanel() : -mResolutionComboBox(NULL), -mRefreshBtn(NULL), -mBtnPreview(NULL), -mWorkingLabel(NULL), -mThumbnailPlaceholder(NULL), -mTitleTextBox(NULL), -mDescriptionTextBox(NULL), -mLocationCheckbox(NULL), -mTagsTextBox(NULL), -mRatingComboBox(NULL), -mBigPreviewFloater(NULL), -mPostButton(NULL) -{ - mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLFlickrPhotoPanel::onSend, this)); - mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLFlickrPhotoPanel::onClickNewSnapshot, this)); - mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLFlickrPhotoPanel::onClickBigPreview, this)); -} - -LLFlickrPhotoPanel::~LLFlickrPhotoPanel() -{ - if(mPreviewHandle.get()) - { - mPreviewHandle.get()->die(); - } -} - -BOOL LLFlickrPhotoPanel::postBuild() -{ - setVisibleCallback(boost::bind(&LLFlickrPhotoPanel::onVisibilityChange, this, _2)); - - mResolutionComboBox = getChild("resolution_combobox"); - mResolutionComboBox->setCommitCallback(boost::bind(&LLFlickrPhotoPanel::updateResolution, this, TRUE)); - mFilterComboBox = getChild("filters_combobox"); - mFilterComboBox->setCommitCallback(boost::bind(&LLFlickrPhotoPanel::updateResolution, this, TRUE)); - mRefreshBtn = getChild("new_snapshot_btn"); - mBtnPreview = getChild("big_preview_btn"); - mWorkingLabel = getChild("working_lbl"); - mThumbnailPlaceholder = getChild("thumbnail_placeholder"); - mTitleTextBox = getChild("photo_title"); - mDescriptionTextBox = getChild("photo_description"); - mLocationCheckbox = getChild("add_location_cb"); - mTagsTextBox = getChild("photo_tags"); - mTagsTextBox->setValue(DEFAULT_TAG_TEXT); - mRatingComboBox = getChild("rating_combobox"); - mPostButton = getChild("post_photo_btn"); - mCancelButton = getChild("cancel_photo_btn"); - mBigPreviewFloater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); - - // Update filter list - std::vector filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); - LLComboBox* filterbox = static_cast(mFilterComboBox); - for (U32 i = 0; i < filter_list.size(); i++) - { - filterbox->add(filter_list[i]); - } - - return LLPanel::postBuild(); -} - -// virtual -S32 LLFlickrPhotoPanel::notify(const LLSD& info) -{ - if (info.has("snapshot-updating")) - { - // Disable the Post button and whatever else while the snapshot is not updated - // updateControls(); - return 1; - } - - if (info.has("snapshot-updated")) - { - // Enable the send/post/save buttons. - updateControls(); - - // The refresh button is initially hidden. We show it after the first update, - // i.e. after snapshot is taken - LLUICtrl * refresh_button = getRefreshBtn(); - if (!refresh_button->getVisible()) - { - refresh_button->setVisible(true); - } - return 1; - } - - return 0; -} - -void LLFlickrPhotoPanel::draw() -{ - LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); - - // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts) - bool no_ongoing_connection = !(LLFlickrConnect::instance().isTransactionOngoing()); - mCancelButton->setEnabled(no_ongoing_connection); - mTitleTextBox->setEnabled(no_ongoing_connection); - mDescriptionTextBox->setEnabled(no_ongoing_connection); - mTagsTextBox->setEnabled(no_ongoing_connection); - mRatingComboBox->setEnabled(no_ongoing_connection); - mResolutionComboBox->setEnabled(no_ongoing_connection); - mFilterComboBox->setEnabled(no_ongoing_connection); - mRefreshBtn->setEnabled(no_ongoing_connection); - mBtnPreview->setEnabled(no_ongoing_connection); - mLocationCheckbox->setEnabled(no_ongoing_connection); - - // Reassign the preview floater if we have the focus and the preview exists - if (hasFocus() && isPreviewVisible()) - { - attachPreview(); - } - - // Toggle the button state as appropriate - bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType())); - mBtnPreview->setToggleState(preview_active); - - // Display the preview if one is available - if (previewp && previewp->getThumbnailImage()) - { - const LLRect& thumbnail_rect = mThumbnailPlaceholder->getRect(); - const S32 thumbnail_w = previewp->getThumbnailWidth(); - const S32 thumbnail_h = previewp->getThumbnailHeight(); - - // calc preview offset within the preview rect - const S32 local_offset_x = (thumbnail_rect.getWidth() - thumbnail_w) / 2 ; - const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ; - S32 offset_x = thumbnail_rect.mLeft + local_offset_x; - S32 offset_y = thumbnail_rect.mBottom + local_offset_y; - - gGL.matrixMode(LLRender::MM_MODELVIEW); - // Apply floater transparency to the texture unless the floater is focused. - F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency(); - LLColor4 color = LLColor4::white; - gl_draw_scaled_image(offset_x, offset_y, - thumbnail_w, thumbnail_h, - previewp->getThumbnailImage(), color % alpha); - } - - // Update the visibility of the working (computing preview) label - mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate())); - - // Enable Post if we have a preview to send and no on going connection being processed - mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate())); - - // Draw the rest of the panel on top of it - LLPanel::draw(); -} - -LLSnapshotLivePreview* LLFlickrPhotoPanel::getPreviewView() -{ - LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get(); - return previewp; -} - -void LLFlickrPhotoPanel::onVisibilityChange(BOOL visible) -{ - if (visible) - { - if (mPreviewHandle.get()) - { - LLSnapshotLivePreview* preview = getPreviewView(); - if(preview) - { - LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; - preview->updateSnapshot(TRUE); - } - } - else - { - LLRect full_screen_rect = getRootView()->getRect(); - LLSnapshotLivePreview::Params p; - p.rect(full_screen_rect); - LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); - mPreviewHandle = previewp->getHandle(); - - previewp->setContainer(this); - previewp->setSnapshotType(LLSnapshotModel::SNAPSHOT_WEB); - previewp->setSnapshotFormat(LLSnapshotModel::SNAPSHOT_FORMAT_PNG); - previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image - previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots - previewp->setAllowFullScreenPreview(FALSE); // No full screen preview in SL Share mode - previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); - - updateControls(); - } - } -} - -void LLFlickrPhotoPanel::onClickNewSnapshot() -{ - LLSnapshotLivePreview* previewp = getPreviewView(); - if (previewp) - { - previewp->updateSnapshot(TRUE); - } -} - -void LLFlickrPhotoPanel::onClickBigPreview() -{ - // Toggle the preview - if (isPreviewVisible()) - { - LLFloaterReg::hideInstance("big_preview"); - } - else - { - attachPreview(); - LLFloaterReg::showInstance("big_preview"); - } -} - -bool LLFlickrPhotoPanel::isPreviewVisible() -{ - return (mBigPreviewFloater && mBigPreviewFloater->getVisible()); -} - -void LLFlickrPhotoPanel::attachPreview() -{ - if (mBigPreviewFloater) - { - LLSnapshotLivePreview* previewp = getPreviewView(); - mBigPreviewFloater->setPreview(previewp); - mBigPreviewFloater->setFloaterOwner(getParentByType()); - } -} - -void LLFlickrPhotoPanel::onSend() -{ - LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrPhotoPanel"); // just in case it is already listening - LLEventPumps::instance().obtain("FlickrConnectState").listen("LLFlickrPhotoPanel", boost::bind(&LLFlickrPhotoPanel::onFlickrConnectStateChange, this, _1)); - - // Connect to Flickr if necessary and then post - if (LLFlickrConnect::instance().isConnected()) - { - sendPhoto(); - } - else - { - LLFlickrConnect::instance().checkConnectionToFlickr(true); - } -} - -bool LLFlickrPhotoPanel::onFlickrConnectStateChange(const LLSD& data) -{ - switch (data.get("enum").asInteger()) - { - case LLFlickrConnect::FLICKR_CONNECTED: - sendPhoto(); - break; - - case LLFlickrConnect::FLICKR_POSTED: - LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrPhotoPanel"); - clearAndClose(); - break; - } - - return false; -} - -void LLFlickrPhotoPanel::sendPhoto() -{ - // Get the title, description, and tags - std::string title = mTitleTextBox->getValue().asString(); - std::string description = mDescriptionTextBox->getValue().asString(); - std::string tags = mTagsTextBox->getValue().asString(); - - // Add the location if required - bool add_location = mLocationCheckbox->getValue().asBoolean(); - if (add_location) - { - // Get the SLURL for the location - LLSLURL slurl; - LLAgentUI::buildSLURL(slurl); - std::string slurl_string = slurl.getSLURLString(); - - // Add query parameters so Google Analytics can track incoming clicks! - slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS; - - std::string photo_link_text = "Visit this location";// at [] in Second Life"; - std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName(); - if (!parcel_name.empty()) - { - boost::regex pattern = boost::regex("\\S\\.[a-zA-Z]{2,}"); - boost::match_results matches; - if(!boost::regex_search(parcel_name, matches, pattern)) - { - photo_link_text += " at " + parcel_name; - } - } - photo_link_text += " in Second Life"; - - slurl_string = "" + photo_link_text + ""; - - // Add it to the description (pretty crude, but we don't have a better option with photos) - if (description.empty()) - description = slurl_string; - else - description = description + "\n\n" + slurl_string; - - // Also add special "machine tags" with location metadata - const LLVector3& agent_pos_region = gAgent.getPositionAgent(); - LLViewerRegion* region = gAgent.getRegion(); - LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (region && parcel) - { - S32 pos_x = S32(agent_pos_region.mV[VX]); - S32 pos_y = S32(agent_pos_region.mV[VY]); - S32 pos_z = S32(agent_pos_region.mV[VZ]); - - std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName(); - std::string region_name = region->getName(); - - if (!region_name.empty()) - { - tags += llformat(" \"%s:region=%s\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), region_name.c_str()); - } - if (!parcel_name.empty()) - { - tags += llformat(" \"%s:parcel=%s\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), parcel_name.c_str()); - } - tags += llformat(" \"%s:x=%d\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), pos_x); - tags += llformat(" \"%s:y=%d\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), pos_y); - tags += llformat(" \"%s:z=%d\"", FLICKR_MACHINE_TAGS_NAMESPACE.c_str(), pos_z); - } - } - - // Get the content rating - int content_rating = mRatingComboBox->getValue().asInteger(); - - // Get the image - LLSnapshotLivePreview* previewp = getPreviewView(); - - // Post to Flickr - LLFlickrConnect::instance().uploadPhoto(previewp->getFormattedImage(), title, description, tags, content_rating); - - updateControls(); -} - -void LLFlickrPhotoPanel::clearAndClose() -{ - mTitleTextBox->setValue(""); - mDescriptionTextBox->setValue(""); - - LLFloater* floater = getParentByType(); - if (floater) - { - floater->closeFloater(); - if (mBigPreviewFloater) - { - mBigPreviewFloater->closeOnFloaterOwnerClosing(floater); - } - } -} - -void LLFlickrPhotoPanel::updateControls() -{ - LLSnapshotLivePreview* previewp = getPreviewView(); - BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); - - // *TODO: Separate maximum size for Web images from postcards - LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; - - updateResolution(FALSE); -} - -void LLFlickrPhotoPanel::updateResolution(BOOL do_update) -{ - LLComboBox* combobox = static_cast(mResolutionComboBox); - LLComboBox* filterbox = static_cast(mFilterComboBox); - - std::string sdstring = combobox->getSelectedValue(); - LLSD sdres; - std::stringstream sstream(sdstring); - LLSDSerialize::fromNotation(sdres, sstream, sdstring.size()); - - S32 width = sdres[0]; - S32 height = sdres[1]; - - // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale - std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : ""); - - LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); - if (previewp && combobox->getCurrentIndex() >= 0) - { - S32 original_width = 0 , original_height = 0 ; - previewp->getSize(original_width, original_height) ; - - if (width == 0 || height == 0) - { - // take resolution from current window size - LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL; - previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); - } - else - { - // use the resolution from the selected pre-canned drop-down choice - LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL; - previewp->setSize(width, height); - } - - checkAspectRatio(width); - - previewp->getSize(width, height); - if ((original_width != width) || (original_height != height)) - { - previewp->setSize(width, height); - if (do_update) - { - previewp->updateSnapshot(TRUE); - updateControls(); - } - } - // Get the old filter, compare to the current one "filter_name" and set if changed - std::string original_filter = previewp->getFilter(); - if (original_filter != filter_name) - { - previewp->setFilter(filter_name); - if (do_update) - { - previewp->updateSnapshot(FALSE, TRUE); - updateControls(); - } - } - } -} - -void LLFlickrPhotoPanel::checkAspectRatio(S32 index) -{ - LLSnapshotLivePreview *previewp = getPreviewView() ; - - BOOL keep_aspect = FALSE; - - if (0 == index) // current window size - { - keep_aspect = TRUE; - } - else // predefined resolution - { - keep_aspect = FALSE; - } - - if (previewp) - { - previewp->mKeepAspectRatio = keep_aspect; - } -} - -LLUICtrl* LLFlickrPhotoPanel::getRefreshBtn() -{ - return mRefreshBtn; -} - -/////////////////////////// -//LLFlickrAccountPanel////// -/////////////////////////// - -LLFlickrAccountPanel::LLFlickrAccountPanel() : -mAccountCaptionLabel(NULL), -mAccountNameLabel(NULL), -mPanelButtons(NULL), -mConnectButton(NULL), -mDisconnectButton(NULL) -{ - mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLFlickrAccountPanel::onConnect, this)); - mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLFlickrAccountPanel::onDisconnect, this)); - - setVisibleCallback(boost::bind(&LLFlickrAccountPanel::onVisibilityChange, this, _2)); -} - -BOOL LLFlickrAccountPanel::postBuild() -{ - mAccountCaptionLabel = getChild("account_caption_label"); - mAccountNameLabel = getChild("account_name_label"); - mPanelButtons = getChild("panel_buttons"); - mConnectButton = getChild("connect_btn"); - mDisconnectButton = getChild("disconnect_btn"); - - return LLPanel::postBuild(); -} - -void LLFlickrAccountPanel::draw() -{ - LLFlickrConnect::EConnectionState connection_state = LLFlickrConnect::instance().getConnectionState(); - - //Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress - bool disconnecting = connection_state == LLFlickrConnect::FLICKR_DISCONNECTING; - mDisconnectButton->setEnabled(!disconnecting); - - //Disable the 'connect' button when a connection is in progress - bool connecting = connection_state == LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS; - mConnectButton->setEnabled(!connecting); - - LLPanel::draw(); -} - -void LLFlickrAccountPanel::onVisibilityChange(BOOL visible) -{ - if(visible) - { - LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrAccountPanel"); - LLEventPumps::instance().obtain("FlickrConnectState").listen("LLFlickrAccountPanel", boost::bind(&LLFlickrAccountPanel::onFlickrConnectStateChange, this, _1)); - - LLEventPumps::instance().obtain("FlickrConnectInfo").stopListening("LLFlickrAccountPanel"); - LLEventPumps::instance().obtain("FlickrConnectInfo").listen("LLFlickrAccountPanel", boost::bind(&LLFlickrAccountPanel::onFlickrConnectInfoChange, this)); - - //Connected - if(LLFlickrConnect::instance().isConnected()) - { - showConnectedLayout(); - } - //Check if connected (show disconnected layout in meantime) - else - { - showDisconnectedLayout(); - } - if ((LLFlickrConnect::instance().getConnectionState() == LLFlickrConnect::FLICKR_NOT_CONNECTED) || - (LLFlickrConnect::instance().getConnectionState() == LLFlickrConnect::FLICKR_CONNECTION_FAILED)) - { - LLFlickrConnect::instance().checkConnectionToFlickr(); - } - } - else - { - LLEventPumps::instance().obtain("FlickrConnectState").stopListening("LLFlickrAccountPanel"); - LLEventPumps::instance().obtain("FlickrConnectInfo").stopListening("LLFlickrAccountPanel"); - } -} - -bool LLFlickrAccountPanel::onFlickrConnectStateChange(const LLSD& data) -{ - if(LLFlickrConnect::instance().isConnected()) - { - //In process of disconnecting so leave the layout as is - if(data.get("enum").asInteger() != LLFlickrConnect::FLICKR_DISCONNECTING) - { - showConnectedLayout(); - } - } - else - { - showDisconnectedLayout(); - } - - return false; -} - -bool LLFlickrAccountPanel::onFlickrConnectInfoChange() -{ - LLSD info = LLFlickrConnect::instance().getInfo(); - std::string clickable_name; - - //Strings of format [http://www.somewebsite.com Click Me] become clickable text - if(info.has("link") && info.has("name")) - { - clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]"; - } - - mAccountNameLabel->setText(clickable_name); - - return false; -} - -void LLFlickrAccountPanel::showConnectButton() -{ - if(!mConnectButton->getVisible()) - { - mConnectButton->setVisible(TRUE); - mDisconnectButton->setVisible(FALSE); - } -} - -void LLFlickrAccountPanel::hideConnectButton() -{ - if(mConnectButton->getVisible()) - { - mConnectButton->setVisible(FALSE); - mDisconnectButton->setVisible(TRUE); - } -} - -void LLFlickrAccountPanel::showDisconnectedLayout() -{ - mAccountCaptionLabel->setText(getString("flickr_disconnected")); - mAccountNameLabel->setText(std::string("")); - showConnectButton(); -} - -void LLFlickrAccountPanel::showConnectedLayout() -{ - LLFlickrConnect::instance().loadFlickrInfo(); - - mAccountCaptionLabel->setText(getString("flickr_connected")); - hideConnectButton(); -} - -void LLFlickrAccountPanel::onConnect() -{ - LLFlickrConnect::instance().checkConnectionToFlickr(true); -} - -void LLFlickrAccountPanel::onDisconnect() -{ - LLFlickrConnect::instance().disconnectFromFlickr(); -} - -//////////////////////// -//LLFloaterFlickr/////// -//////////////////////// - -LLFloaterFlickr::LLFloaterFlickr(const LLSD& key) : LLFloater(key), - mFlickrPhotoPanel(NULL), - mStatusErrorText(NULL), - mStatusLoadingText(NULL), - mStatusLoadingIndicator(NULL) -{ - mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterFlickr::onCancel, this)); -} - -void LLFloaterFlickr::onClose(bool app_quitting) -{ - LLFloaterBigPreview* big_preview_floater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); - if (big_preview_floater) - { - big_preview_floater->closeOnFloaterOwnerClosing(this); - } - LLFloater::onClose(app_quitting); -} - -void LLFloaterFlickr::onCancel() -{ - LLFloaterBigPreview* big_preview_floater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); - if (big_preview_floater) - { - big_preview_floater->closeOnFloaterOwnerClosing(this); - } - closeFloater(); -} - -BOOL LLFloaterFlickr::postBuild() -{ - // Keep tab of the Photo Panel - mFlickrPhotoPanel = static_cast(getChild("panel_flickr_photo")); - // Connection status widgets - mStatusErrorText = getChild("connection_error_text"); - mStatusLoadingText = getChild("connection_loading_text"); - mStatusLoadingIndicator = getChild("connection_loading_indicator"); - return LLFloater::postBuild(); -} - -void LLFloaterFlickr::showPhotoPanel() -{ - LLTabContainer* parent = dynamic_cast(mFlickrPhotoPanel->getParent()); - if (!parent) - { - LL_WARNS() << "Cannot find panel container" << LL_ENDL; - return; - } - - parent->selectTabPanel(mFlickrPhotoPanel); -} - -void LLFloaterFlickr::draw() -{ - if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator) - { - mStatusErrorText->setVisible(false); - mStatusLoadingText->setVisible(false); - mStatusLoadingIndicator->setVisible(false); - LLFlickrConnect::EConnectionState connection_state = LLFlickrConnect::instance().getConnectionState(); - std::string status_text; - - switch (connection_state) - { - case LLFlickrConnect::FLICKR_NOT_CONNECTED: - // No status displayed when first opening the panel and no connection done - case LLFlickrConnect::FLICKR_CONNECTED: - // When successfully connected, no message is displayed - case LLFlickrConnect::FLICKR_POSTED: - // No success message to show since we actually close the floater after successful posting completion - break; - case LLFlickrConnect::FLICKR_CONNECTION_IN_PROGRESS: - // Connection loading indicator - mStatusLoadingText->setVisible(true); - status_text = LLTrans::getString("SocialFlickrConnecting"); - mStatusLoadingText->setValue(status_text); - mStatusLoadingIndicator->setVisible(true); - break; - case LLFlickrConnect::FLICKR_POSTING: - // Posting indicator - mStatusLoadingText->setVisible(true); - status_text = LLTrans::getString("SocialFlickrPosting"); - mStatusLoadingText->setValue(status_text); - mStatusLoadingIndicator->setVisible(true); - break; - case LLFlickrConnect::FLICKR_CONNECTION_FAILED: - // Error connecting to the service - mStatusErrorText->setVisible(true); - status_text = LLTrans::getString("SocialFlickrErrorConnecting"); - mStatusErrorText->setValue(status_text); - break; - case LLFlickrConnect::FLICKR_POST_FAILED: - // Error posting to the service - mStatusErrorText->setVisible(true); - status_text = LLTrans::getString("SocialFlickrErrorPosting"); - mStatusErrorText->setValue(status_text); - break; - case LLFlickrConnect::FLICKR_DISCONNECTING: - // Disconnecting loading indicator - mStatusLoadingText->setVisible(true); - status_text = LLTrans::getString("SocialFlickrDisconnecting"); - mStatusLoadingText->setValue(status_text); - mStatusLoadingIndicator->setVisible(true); - break; - case LLFlickrConnect::FLICKR_DISCONNECT_FAILED: - // Error disconnecting from the service - mStatusErrorText->setVisible(true); - status_text = LLTrans::getString("SocialFlickrErrorDisconnecting"); - mStatusErrorText->setValue(status_text); - break; - } - } - LLFloater::draw(); -} - diff --git a/indra/newview/llfloaterflickr.h b/indra/newview/llfloaterflickr.h deleted file mode 100644 index 74da3bcea9..0000000000 --- a/indra/newview/llfloaterflickr.h +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @file llfloaterflickr.h -* @brief Header file for llfloaterflickr -* @author cho@lindenlab.com -* -* $LicenseInfo:firstyear=2013&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2013, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ -#ifndef LL_LLFLOATERFLICKR_H -#define LL_LLFLOATERFLICKR_H - -#include "llfloater.h" -#include "lltextbox.h" -#include "llviewertexture.h" - -class LLIconCtrl; -class LLCheckBoxCtrl; -class LLSnapshotLivePreview; -class LLFloaterBigPreview; - -class LLFlickrPhotoPanel : public LLPanel -{ -public: - LLFlickrPhotoPanel(); - ~LLFlickrPhotoPanel(); - - BOOL postBuild(); - S32 notify(const LLSD& info); - void draw(); - - LLSnapshotLivePreview* getPreviewView(); - void onVisibilityChange(BOOL new_visibility); - void onClickNewSnapshot(); - void onClickBigPreview(); - void onSend(); - bool onFlickrConnectStateChange(const LLSD& data); - - void sendPhoto(); - void clearAndClose(); - - void updateControls(); - void updateResolution(BOOL do_update); - void checkAspectRatio(S32 index); - LLUICtrl* getRefreshBtn(); - -private: - bool isPreviewVisible(); - void attachPreview(); - - LLHandle mPreviewHandle; - - LLUICtrl * mResolutionComboBox; - LLUICtrl * mFilterComboBox; - LLUICtrl * mRefreshBtn; - LLUICtrl * mWorkingLabel; - LLUICtrl * mThumbnailPlaceholder; - LLUICtrl * mTitleTextBox; - LLUICtrl * mDescriptionTextBox; - LLUICtrl * mLocationCheckbox; - LLUICtrl * mTagsTextBox; - LLUICtrl * mRatingComboBox; - LLUICtrl * mPostButton; - LLUICtrl * mCancelButton; - LLButton * mBtnPreview; - - LLFloaterBigPreview * mBigPreviewFloater; -}; - -class LLFlickrAccountPanel : public LLPanel -{ -public: - LLFlickrAccountPanel(); - BOOL postBuild(); - void draw(); - -private: - void onVisibilityChange(BOOL new_visibility); - bool onFlickrConnectStateChange(const LLSD& data); - bool onFlickrConnectInfoChange(); - void onConnect(); - void onUseAnotherAccount(); - void onDisconnect(); - - void showConnectButton(); - void hideConnectButton(); - void showDisconnectedLayout(); - void showConnectedLayout(); - - LLTextBox * mAccountCaptionLabel; - LLTextBox * mAccountNameLabel; - LLUICtrl * mPanelButtons; - LLUICtrl * mConnectButton; - LLUICtrl * mDisconnectButton; -}; - - -class LLFloaterFlickr : public LLFloater -{ -public: - LLFloaterFlickr(const LLSD& key); - BOOL postBuild(); - void draw(); - void onClose(bool app_quitting); - void onCancel(); - - void showPhotoPanel(); - -private: - LLFlickrPhotoPanel* mFlickrPhotoPanel; - LLTextBox* mStatusErrorText; - LLTextBox* mStatusLoadingText; - LLUICtrl* mStatusLoadingIndicator; -}; - -#endif // LL_LLFLOATERFLICKR_H - diff --git a/indra/newview/llfloateroutfitsnapshot.cpp b/indra/newview/llfloateroutfitsnapshot.cpp index bfcd1b8b47..dccef88e41 100644 --- a/indra/newview/llfloateroutfitsnapshot.cpp +++ b/indra/newview/llfloateroutfitsnapshot.cpp @@ -31,8 +31,6 @@ #include "llagent.h" #include "llfloaterreg.h" -#include "llfloaterflickr.h" -#include "llfloatertwitter.h" #include "llimagefiltersmanager.h" #include "llcheckboxctrl.h" #include "llcombobox.h" diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 2798e375c7..ef7a9fd536 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -29,8 +29,6 @@ #include "llfloatersnapshot.h" #include "llfloaterreg.h" -#include "llfloaterflickr.h" -#include "llfloatertwitter.h" #include "llimagefiltersmanager.h" #include "llcheckboxctrl.h" #include "llcombobox.h" @@ -1240,10 +1238,7 @@ BOOL LLFloaterSnapshot::isWaitingState() BOOL LLFloaterSnapshotBase::ImplBase::updatePreviewList(bool initialized) { - LLFloaterFlickr* floater_flickr = LLFloaterReg::findTypedInstance("flickr"); - LLFloaterTwitter* floater_twitter = LLFloaterReg::findTypedInstance("twitter"); - - if (!initialized && !floater_flickr && !floater_twitter) + if (!initialized) return FALSE; BOOL changed = FALSE; diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp deleted file mode 100644 index 2b33bc6935..0000000000 --- a/indra/newview/llfloatertwitter.cpp +++ /dev/null @@ -1,810 +0,0 @@ -/** -* @file llfloatertwitter.cpp -* @brief Implementation of llfloatertwitter -* @author cho@lindenlab.com -* -* $LicenseInfo:firstyear=2013&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2013, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#include "llviewerprecompiledheaders.h" - -#include "llfloatertwitter.h" - -#include "llagent.h" -#include "llagentui.h" -#include "llcheckboxctrl.h" -#include "llcombobox.h" -#include "lltwitterconnect.h" -#include "llfloaterbigpreview.h" -#include "llfloaterreg.h" -#include "lliconctrl.h" -#include "llimagefiltersmanager.h" -#include "llresmgr.h" // LLLocale -#include "llsdserialize.h" -#include "llloadingindicator.h" -#include "llslurl.h" -#include "lltrans.h" -#include "llsnapshotlivepreview.h" -#include "llviewerregion.h" -#include "llviewercontrol.h" -#include "llviewermedia.h" -#include "lltabcontainer.h" -#include "lltexteditor.h" - -static LLPanelInjector t_panel_photo("lltwitterphotopanel"); -static LLPanelInjector t_panel_account("lltwitteraccountpanel"); - -const std::string DEFAULT_PHOTO_LOCATION_URL = "http://maps.secondlife.com/"; -const std::string DEFAULT_PHOTO_QUERY_PARAMETERS = "?sourceid=slshare_photo&utm_source=twitter&utm_medium=photo&utm_campaign=slshare"; -const std::string DEFAULT_STATUS_TEXT = " #SecondLife"; - -/////////////////////////// -//LLTwitterPhotoPanel/////// -/////////////////////////// - -LLTwitterPhotoPanel::LLTwitterPhotoPanel() : -mResolutionComboBox(NULL), -mRefreshBtn(NULL), -mBtnPreview(NULL), -mWorkingLabel(NULL), -mThumbnailPlaceholder(NULL), -mStatusCounterLabel(NULL), -mStatusTextBox(NULL), -mLocationCheckbox(NULL), -mPhotoCheckbox(NULL), -mBigPreviewFloater(NULL), -mPostButton(NULL) -{ - mCommitCallbackRegistrar.add("SocialSharing.SendPhoto", boost::bind(&LLTwitterPhotoPanel::onSend, this)); - mCommitCallbackRegistrar.add("SocialSharing.RefreshPhoto", boost::bind(&LLTwitterPhotoPanel::onClickNewSnapshot, this)); - mCommitCallbackRegistrar.add("SocialSharing.BigPreview", boost::bind(&LLTwitterPhotoPanel::onClickBigPreview, this)); -} - -LLTwitterPhotoPanel::~LLTwitterPhotoPanel() -{ - if(mPreviewHandle.get()) - { - mPreviewHandle.get()->die(); - } -} - -BOOL LLTwitterPhotoPanel::postBuild() -{ - setVisibleCallback(boost::bind(&LLTwitterPhotoPanel::onVisibilityChange, this, _2)); - - mResolutionComboBox = getChild("resolution_combobox"); - mResolutionComboBox->setValue("[i800,i600]"); // hardcoded defaults ftw! - mResolutionComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); - mFilterComboBox = getChild("filters_combobox"); - mFilterComboBox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::updateResolution, this, TRUE)); - mRefreshBtn = getChild("new_snapshot_btn"); - mBtnPreview = getChild("big_preview_btn"); - mWorkingLabel = getChild("working_lbl"); - mThumbnailPlaceholder = getChild("thumbnail_placeholder"); - mStatusCounterLabel = getChild("status_counter_label"); - mStatusTextBox = getChild("photo_status"); - mStatusTextBox->setValue(DEFAULT_STATUS_TEXT); - mLocationCheckbox = getChild("add_location_cb"); - mLocationCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddLocationToggled, this)); - mPhotoCheckbox = getChild("add_photo_cb"); - mPhotoCheckbox->setCommitCallback(boost::bind(&LLTwitterPhotoPanel::onAddPhotoToggled, this)); - mPostButton = getChild("post_photo_btn"); - mCancelButton = getChild("cancel_photo_btn"); - mBigPreviewFloater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); - - // Update filter list - std::vector filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); - LLComboBox* filterbox = static_cast(mFilterComboBox); - for (U32 i = 0; i < filter_list.size(); i++) - { - filterbox->add(filter_list[i]); - } - - return LLPanel::postBuild(); -} - -// virtual -S32 LLTwitterPhotoPanel::notify(const LLSD& info) -{ - if (info.has("snapshot-updating")) - { - // Disable the Post button and whatever else while the snapshot is not updated - // updateControls(); - return 1; - } - - if (info.has("snapshot-updated")) - { - // Enable the send/post/save buttons. - updateControls(); - - // The refresh button is initially hidden. We show it after the first update, - // i.e. after snapshot is taken - LLUICtrl * refresh_button = getRefreshBtn(); - if (!refresh_button->getVisible()) - { - refresh_button->setVisible(true); - } - return 1; - } - - return 0; -} - -void LLTwitterPhotoPanel::draw() -{ - LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); - - // Enable interaction only if no transaction with the service is on-going (prevent duplicated posts) - bool no_ongoing_connection = !(LLTwitterConnect::instance().isTransactionOngoing()); - bool photo_checked = mPhotoCheckbox->getValue().asBoolean(); - mCancelButton->setEnabled(no_ongoing_connection); - mStatusTextBox->setEnabled(no_ongoing_connection); - mResolutionComboBox->setEnabled(no_ongoing_connection && photo_checked); - mFilterComboBox->setEnabled(no_ongoing_connection && photo_checked); - mRefreshBtn->setEnabled(no_ongoing_connection && photo_checked); - mBtnPreview->setEnabled(no_ongoing_connection); - mLocationCheckbox->setEnabled(no_ongoing_connection); - mPhotoCheckbox->setEnabled(no_ongoing_connection); - - bool add_location = mLocationCheckbox->getValue().asBoolean(); - bool add_photo = mPhotoCheckbox->getValue().asBoolean(); - updateStatusTextLength(false); - - // Reassign the preview floater if we have the focus and the preview exists - if (hasFocus() && isPreviewVisible()) - { - attachPreview(); - } - - // Toggle the button state as appropriate - bool preview_active = (isPreviewVisible() && mBigPreviewFloater->isFloaterOwner(getParentByType())); - mBtnPreview->setToggleState(preview_active); - - // Display the preview if one is available - if (previewp && previewp->getThumbnailImage()) - { - const LLRect& thumbnail_rect = mThumbnailPlaceholder->getRect(); - const S32 thumbnail_w = previewp->getThumbnailWidth(); - const S32 thumbnail_h = previewp->getThumbnailHeight(); - - // calc preview offset within the preview rect - const S32 local_offset_x = (thumbnail_rect.getWidth() - thumbnail_w) / 2 ; - const S32 local_offset_y = (thumbnail_rect.getHeight() - thumbnail_h) / 2 ; - S32 offset_x = thumbnail_rect.mLeft + local_offset_x; - S32 offset_y = thumbnail_rect.mBottom + local_offset_y; - - gGL.matrixMode(LLRender::MM_MODELVIEW); - // Apply floater transparency to the texture unless the floater is focused. - F32 alpha = (add_photo ? (getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency()) : 0.5f); - LLColor4 color = LLColor4::white; - gl_draw_scaled_image(offset_x, offset_y, - thumbnail_w, thumbnail_h, - previewp->getThumbnailImage(), color % alpha); - } - - // Update the visibility of the working (computing preview) label - mWorkingLabel->setVisible(!(previewp && previewp->getSnapshotUpToDate())); - - // Enable Post if we have a preview to send and no on going connection being processed - mPostButton->setEnabled(no_ongoing_connection && (previewp && previewp->getSnapshotUpToDate()) && (add_photo || add_location || !mStatusTextBox->getValue().asString().empty())); - - // Draw the rest of the panel on top of it - LLPanel::draw(); -} - -LLSnapshotLivePreview* LLTwitterPhotoPanel::getPreviewView() -{ - LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)mPreviewHandle.get(); - return previewp; -} - -void LLTwitterPhotoPanel::onVisibilityChange(BOOL visible) -{ - if (visible) - { - if (mPreviewHandle.get()) - { - LLSnapshotLivePreview* preview = getPreviewView(); - if(preview) - { - LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL; - preview->updateSnapshot(TRUE); - } - } - else - { - LLRect full_screen_rect = getRootView()->getRect(); - LLSnapshotLivePreview::Params p; - p.rect(full_screen_rect); - LLSnapshotLivePreview* previewp = new LLSnapshotLivePreview(p); - mPreviewHandle = previewp->getHandle(); - - previewp->setContainer(this); - previewp->setSnapshotType(LLSnapshotModel::SNAPSHOT_WEB); - previewp->setSnapshotFormat(LLSnapshotModel::SNAPSHOT_FORMAT_JPEG); - previewp->setThumbnailSubsampled(TRUE); // We want the preview to reflect the *saved* image - previewp->setAllowRenderUI(FALSE); // We do not want the rendered UI in our snapshots - previewp->setAllowFullScreenPreview(FALSE); // No full screen preview in SL Share mode - previewp->setThumbnailPlaceholderRect(mThumbnailPlaceholder->getRect()); - - updateControls(); - } - } -} - -void LLTwitterPhotoPanel::onAddLocationToggled() -{ - bool add_location = mLocationCheckbox->getValue().asBoolean(); - updateStatusTextLength(!add_location); -} - -void LLTwitterPhotoPanel::onAddPhotoToggled() -{ - bool add_photo = mPhotoCheckbox->getValue().asBoolean(); - updateStatusTextLength(!add_photo); -} - -void LLTwitterPhotoPanel::onClickNewSnapshot() -{ - LLSnapshotLivePreview* previewp = getPreviewView(); - if (previewp) - { - previewp->updateSnapshot(TRUE); - } -} - -void LLTwitterPhotoPanel::onClickBigPreview() -{ - // Toggle the preview - if (isPreviewVisible()) - { - LLFloaterReg::hideInstance("big_preview"); - } - else - { - attachPreview(); - LLFloaterReg::showInstance("big_preview"); - } -} - -bool LLTwitterPhotoPanel::isPreviewVisible() -{ - return (mBigPreviewFloater && mBigPreviewFloater->getVisible()); -} - -void LLTwitterPhotoPanel::attachPreview() -{ - if (mBigPreviewFloater) - { - LLSnapshotLivePreview* previewp = getPreviewView(); - mBigPreviewFloater->setPreview(previewp); - mBigPreviewFloater->setFloaterOwner(getParentByType()); - } -} - -void LLTwitterPhotoPanel::onSend() -{ - LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterPhotoPanel"); // just in case it is already listening - LLEventPumps::instance().obtain("TwitterConnectState").listen("LLTwitterPhotoPanel", boost::bind(&LLTwitterPhotoPanel::onTwitterConnectStateChange, this, _1)); - - // Connect to Twitter if necessary and then post - if (LLTwitterConnect::instance().isConnected()) - { - sendPhoto(); - } - else - { - LLTwitterConnect::instance().checkConnectionToTwitter(true); - } -} - -bool LLTwitterPhotoPanel::onTwitterConnectStateChange(const LLSD& data) -{ - switch (data.get("enum").asInteger()) - { - case LLTwitterConnect::TWITTER_CONNECTED: - sendPhoto(); - break; - - case LLTwitterConnect::TWITTER_POSTED: - LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterPhotoPanel"); - clearAndClose(); - break; - } - - return false; -} - -void LLTwitterPhotoPanel::sendPhoto() -{ - // Get the status text - std::string status = mStatusTextBox->getValue().asString(); - - // Add the location if required - bool add_location = mLocationCheckbox->getValue().asBoolean(); - if (add_location) - { - // Get the SLURL for the location - LLSLURL slurl; - LLAgentUI::buildSLURL(slurl); - std::string slurl_string = slurl.getSLURLString(); - - // Use a valid http:// URL if the scheme is secondlife:// - LLURI slurl_uri(slurl_string); - if (slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME) - { - slurl_string = DEFAULT_PHOTO_LOCATION_URL; - } - - // Add query parameters so Google Analytics can track incoming clicks! - slurl_string += DEFAULT_PHOTO_QUERY_PARAMETERS; - - // Add it to the status (pretty crude, but we don't have a better option with photos) - if (status.empty()) - status = slurl_string; - else - status = status + " " + slurl_string; - } - - // Add the photo if required - bool add_photo = mPhotoCheckbox->getValue().asBoolean(); - if (add_photo) - { - // Get the image - LLSnapshotLivePreview* previewp = getPreviewView(); - - // Post to Twitter - LLTwitterConnect::instance().uploadPhoto(previewp->getFormattedImage(), status); - } - else - { - // Just post the status to Twitter - LLTwitterConnect::instance().updateStatus(status); - } - - updateControls(); -} - -void LLTwitterPhotoPanel::clearAndClose() -{ - mStatusTextBox->setValue(DEFAULT_STATUS_TEXT); - - LLFloater* floater = getParentByType(); - if (floater) - { - floater->closeFloater(); - if (mBigPreviewFloater) - { - mBigPreviewFloater->closeOnFloaterOwnerClosing(floater); - } - } -} - -void LLTwitterPhotoPanel::updateStatusTextLength(BOOL restore_old_status_text) -{ - bool add_location = mLocationCheckbox->getValue().asBoolean(); - - // Restrict the status text length to Twitter's character limit - LLTextEditor* status_text_box = dynamic_cast(mStatusTextBox); - if (status_text_box) - { - int max_status_length = 280 - (add_location ? 40 : 0); - status_text_box->setMaxTextLength(max_status_length); - if (restore_old_status_text) - { - if (mOldStatusText.length() > status_text_box->getText().length() && status_text_box->getText() == mOldStatusText.substr(0, status_text_box->getText().length())) - { - status_text_box->setText(mOldStatusText); - } - if (mOldStatusText.length() <= max_status_length) - { - mOldStatusText = ""; - } - } - if (status_text_box->getText().length() > max_status_length) - { - if (mOldStatusText.length() < status_text_box->getText().length() || status_text_box->getText() != mOldStatusText.substr(0, status_text_box->getText().length())) - { - mOldStatusText = status_text_box->getText(); - } - status_text_box->setText(mOldStatusText.substr(0, max_status_length)); - } - - // Update the status character counter - int characters_remaining = max_status_length - status_text_box->getText().length(); - mStatusCounterLabel->setValue(characters_remaining); - } - -} - -void LLTwitterPhotoPanel::updateControls() -{ - LLSnapshotLivePreview* previewp = getPreviewView(); - BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); - - // *TODO: Separate maximum size for Web images from postcards - LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; - - updateResolution(FALSE); -} - -void LLTwitterPhotoPanel::updateResolution(BOOL do_update) -{ - LLComboBox* combobox = static_cast(mResolutionComboBox); - LLComboBox* filterbox = static_cast(mFilterComboBox); - - std::string sdstring = combobox->getSelectedValue(); - LLSD sdres; - std::stringstream sstream(sdstring); - LLSDSerialize::fromNotation(sdres, sstream, sdstring.size()); - - S32 width = sdres[0]; - S32 height = sdres[1]; - - // Note : index 0 of the filter drop down is assumed to be "No filter" in whichever locale - std::string filter_name = (filterbox->getCurrentIndex() ? filterbox->getSimple() : ""); - - LLSnapshotLivePreview * previewp = static_cast(mPreviewHandle.get()); - if (previewp && combobox->getCurrentIndex() >= 0) - { - S32 original_width = 0 , original_height = 0 ; - previewp->getSize(original_width, original_height) ; - - if (width == 0 || height == 0) - { - // take resolution from current window size - LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL; - previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw()); - } - else - { - // use the resolution from the selected pre-canned drop-down choice - LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL; - previewp->setSize(width, height); - } - - checkAspectRatio(width); - - previewp->getSize(width, height); - - if (original_width != width || original_height != height) - { - previewp->setSize(width, height); - if (do_update) - { - previewp->updateSnapshot(TRUE); - updateControls(); - } - } - // Get the old filter, compare to the current one "filter_name" and set if changed - std::string original_filter = previewp->getFilter(); - if (original_filter != filter_name) - { - previewp->setFilter(filter_name); - if (do_update) - { - previewp->updateSnapshot(FALSE, TRUE); - updateControls(); - } - } - } -} - -void LLTwitterPhotoPanel::checkAspectRatio(S32 index) -{ - LLSnapshotLivePreview *previewp = getPreviewView() ; - - BOOL keep_aspect = FALSE; - - if (0 == index) // current window size - { - keep_aspect = TRUE; - } - else // predefined resolution - { - keep_aspect = FALSE; - } - - if (previewp) - { - previewp->mKeepAspectRatio = keep_aspect; - } -} - -LLUICtrl* LLTwitterPhotoPanel::getRefreshBtn() -{ - return mRefreshBtn; -} - -/////////////////////////// -//LLTwitterAccountPanel////// -/////////////////////////// - -LLTwitterAccountPanel::LLTwitterAccountPanel() : -mAccountCaptionLabel(NULL), -mAccountNameLabel(NULL), -mPanelButtons(NULL), -mConnectButton(NULL), -mDisconnectButton(NULL) -{ - mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLTwitterAccountPanel::onConnect, this)); - mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLTwitterAccountPanel::onDisconnect, this)); - - setVisibleCallback(boost::bind(&LLTwitterAccountPanel::onVisibilityChange, this, _2)); -} - -BOOL LLTwitterAccountPanel::postBuild() -{ - mAccountCaptionLabel = getChild("account_caption_label"); - mAccountNameLabel = getChild("account_name_label"); - mPanelButtons = getChild("panel_buttons"); - mConnectButton = getChild("connect_btn"); - mDisconnectButton = getChild("disconnect_btn"); - - return LLPanel::postBuild(); -} - -void LLTwitterAccountPanel::draw() -{ - LLTwitterConnect::EConnectionState connection_state = LLTwitterConnect::instance().getConnectionState(); - - //Disable the 'disconnect' button and the 'use another account' button when disconnecting in progress - bool disconnecting = connection_state == LLTwitterConnect::TWITTER_DISCONNECTING; - mDisconnectButton->setEnabled(!disconnecting); - - //Disable the 'connect' button when a connection is in progress - bool connecting = connection_state == LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS; - mConnectButton->setEnabled(!connecting); - - LLPanel::draw(); -} - -void LLTwitterAccountPanel::onVisibilityChange(BOOL visible) -{ - if(visible) - { - LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterAccountPanel"); - LLEventPumps::instance().obtain("TwitterConnectState").listen("LLTwitterAccountPanel", boost::bind(&LLTwitterAccountPanel::onTwitterConnectStateChange, this, _1)); - - LLEventPumps::instance().obtain("TwitterConnectInfo").stopListening("LLTwitterAccountPanel"); - LLEventPumps::instance().obtain("TwitterConnectInfo").listen("LLTwitterAccountPanel", boost::bind(&LLTwitterAccountPanel::onTwitterConnectInfoChange, this)); - - //Connected - if(LLTwitterConnect::instance().isConnected()) - { - showConnectedLayout(); - } - //Check if connected (show disconnected layout in meantime) - else - { - showDisconnectedLayout(); - } - if ((LLTwitterConnect::instance().getConnectionState() == LLTwitterConnect::TWITTER_NOT_CONNECTED) || - (LLTwitterConnect::instance().getConnectionState() == LLTwitterConnect::TWITTER_CONNECTION_FAILED)) - { - LLTwitterConnect::instance().checkConnectionToTwitter(); - } - } - else - { - LLEventPumps::instance().obtain("TwitterConnectState").stopListening("LLTwitterAccountPanel"); - LLEventPumps::instance().obtain("TwitterConnectInfo").stopListening("LLTwitterAccountPanel"); - } -} - -bool LLTwitterAccountPanel::onTwitterConnectStateChange(const LLSD& data) -{ - if(LLTwitterConnect::instance().isConnected()) - { - //In process of disconnecting so leave the layout as is - if(data.get("enum").asInteger() != LLTwitterConnect::TWITTER_DISCONNECTING) - { - showConnectedLayout(); - } - } - else - { - showDisconnectedLayout(); - } - - return false; -} - -bool LLTwitterAccountPanel::onTwitterConnectInfoChange() -{ - LLSD info = LLTwitterConnect::instance().getInfo(); - std::string clickable_name; - - //Strings of format [http://www.somewebsite.com Click Me] become clickable text - if(info.has("link") && info.has("name")) - { - clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]"; - } - - mAccountNameLabel->setText(clickable_name); - - return false; -} - -void LLTwitterAccountPanel::showConnectButton() -{ - if(!mConnectButton->getVisible()) - { - mConnectButton->setVisible(TRUE); - mDisconnectButton->setVisible(FALSE); - } -} - -void LLTwitterAccountPanel::hideConnectButton() -{ - if(mConnectButton->getVisible()) - { - mConnectButton->setVisible(FALSE); - mDisconnectButton->setVisible(TRUE); - } -} - -void LLTwitterAccountPanel::showDisconnectedLayout() -{ - mAccountCaptionLabel->setText(getString("twitter_disconnected")); - mAccountNameLabel->setText(std::string("")); - showConnectButton(); -} - -void LLTwitterAccountPanel::showConnectedLayout() -{ - LLTwitterConnect::instance().loadTwitterInfo(); - - mAccountCaptionLabel->setText(getString("twitter_connected")); - hideConnectButton(); -} - -void LLTwitterAccountPanel::onConnect() -{ - LLTwitterConnect::instance().checkConnectionToTwitter(true); -} - -void LLTwitterAccountPanel::onDisconnect() -{ - LLTwitterConnect::instance().disconnectFromTwitter(); -} - -//////////////////////// -//LLFloaterTwitter/////// -//////////////////////// - -LLFloaterTwitter::LLFloaterTwitter(const LLSD& key) : LLFloater(key), - mTwitterPhotoPanel(NULL), - mStatusErrorText(NULL), - mStatusLoadingText(NULL), - mStatusLoadingIndicator(NULL) -{ - mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterTwitter::onCancel, this)); -} - -void LLFloaterTwitter::onClose(bool app_quitting) -{ - LLFloaterBigPreview* big_preview_floater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); - if (big_preview_floater) - { - big_preview_floater->closeOnFloaterOwnerClosing(this); - } - LLFloater::onClose(app_quitting); -} - -void LLFloaterTwitter::onCancel() -{ - LLFloaterBigPreview* big_preview_floater = dynamic_cast(LLFloaterReg::getInstance("big_preview")); - if (big_preview_floater) - { - big_preview_floater->closeOnFloaterOwnerClosing(this); - } - closeFloater(); -} - -BOOL LLFloaterTwitter::postBuild() -{ - // Keep tab of the Photo Panel - mTwitterPhotoPanel = static_cast(getChild("panel_twitter_photo")); - // Connection status widgets - mStatusErrorText = getChild("connection_error_text"); - mStatusLoadingText = getChild("connection_loading_text"); - mStatusLoadingIndicator = getChild("connection_loading_indicator"); - return LLFloater::postBuild(); -} - -void LLFloaterTwitter::showPhotoPanel() -{ - LLTabContainer* parent = dynamic_cast(mTwitterPhotoPanel->getParent()); - if (!parent) - { - LL_WARNS() << "Cannot find panel container" << LL_ENDL; - return; - } - - parent->selectTabPanel(mTwitterPhotoPanel); -} - -void LLFloaterTwitter::draw() -{ - if (mStatusErrorText && mStatusLoadingText && mStatusLoadingIndicator) - { - mStatusErrorText->setVisible(false); - mStatusLoadingText->setVisible(false); - mStatusLoadingIndicator->setVisible(false); - LLTwitterConnect::EConnectionState connection_state = LLTwitterConnect::instance().getConnectionState(); - std::string status_text; - - switch (connection_state) - { - case LLTwitterConnect::TWITTER_NOT_CONNECTED: - // No status displayed when first opening the panel and no connection done - case LLTwitterConnect::TWITTER_CONNECTED: - // When successfully connected, no message is displayed - case LLTwitterConnect::TWITTER_POSTED: - // No success message to show since we actually close the floater after successful posting completion - break; - case LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS: - // Connection loading indicator - mStatusLoadingText->setVisible(true); - status_text = LLTrans::getString("SocialTwitterConnecting"); - mStatusLoadingText->setValue(status_text); - mStatusLoadingIndicator->setVisible(true); - break; - case LLTwitterConnect::TWITTER_POSTING: - // Posting indicator - mStatusLoadingText->setVisible(true); - status_text = LLTrans::getString("SocialTwitterPosting"); - mStatusLoadingText->setValue(status_text); - mStatusLoadingIndicator->setVisible(true); - break; - case LLTwitterConnect::TWITTER_CONNECTION_FAILED: - // Error connecting to the service - mStatusErrorText->setVisible(true); - status_text = LLTrans::getString("SocialTwitterErrorConnecting"); - mStatusErrorText->setValue(status_text); - break; - case LLTwitterConnect::TWITTER_POST_FAILED: - // Error posting to the service - mStatusErrorText->setVisible(true); - status_text = LLTrans::getString("SocialTwitterErrorPosting"); - mStatusErrorText->setValue(status_text); - break; - case LLTwitterConnect::TWITTER_DISCONNECTING: - // Disconnecting loading indicator - mStatusLoadingText->setVisible(true); - status_text = LLTrans::getString("SocialTwitterDisconnecting"); - mStatusLoadingText->setValue(status_text); - mStatusLoadingIndicator->setVisible(true); - break; - case LLTwitterConnect::TWITTER_DISCONNECT_FAILED: - // Error disconnecting from the service - mStatusErrorText->setVisible(true); - status_text = LLTrans::getString("SocialTwitterErrorDisconnecting"); - mStatusErrorText->setValue(status_text); - break; - } - } - LLFloater::draw(); -} - diff --git a/indra/newview/llfloatertwitter.h b/indra/newview/llfloatertwitter.h deleted file mode 100644 index d586799d18..0000000000 --- a/indra/newview/llfloatertwitter.h +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @file llfloatertwitter.h -* @brief Header file for llfloatertwitter -* @author cho@lindenlab.com -* -* $LicenseInfo:firstyear=2013&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2013, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ -#ifndef LL_LLFLOATERTWITTER_H -#define LL_LLFLOATERTWITTER_H - -#include "llfloater.h" -#include "lltextbox.h" -#include "llviewertexture.h" - -class LLIconCtrl; -class LLCheckBoxCtrl; -class LLSnapshotLivePreview; -class LLFloaterBigPreview; - -class LLTwitterPhotoPanel : public LLPanel -{ -public: - LLTwitterPhotoPanel(); - ~LLTwitterPhotoPanel(); - - BOOL postBuild(); - void draw(); - - LLSnapshotLivePreview* getPreviewView(); - void onVisibilityChange(BOOL new_visibility); - void onAddLocationToggled(); - void onAddPhotoToggled(); - void onClickBigPreview(); - void onClickNewSnapshot(); - void onSend(); - S32 notify(const LLSD& info); - bool onTwitterConnectStateChange(const LLSD& data); - - void sendPhoto(); - void clearAndClose(); - - void updateStatusTextLength(BOOL restore_old_status_text); - void updateControls(); - void updateResolution(BOOL do_update); - void checkAspectRatio(S32 index); - LLUICtrl* getRefreshBtn(); - -private: - bool isPreviewVisible(); - void attachPreview(); - - LLHandle mPreviewHandle; - - LLUICtrl * mResolutionComboBox; - LLUICtrl * mFilterComboBox; - LLUICtrl * mRefreshBtn; - LLUICtrl * mWorkingLabel; - LLUICtrl * mThumbnailPlaceholder; - LLUICtrl * mStatusCounterLabel; - LLUICtrl * mStatusTextBox; - LLUICtrl * mLocationCheckbox; - LLUICtrl * mPhotoCheckbox; - LLUICtrl * mPostButton; - LLUICtrl * mCancelButton; - LLButton * mBtnPreview; - - LLFloaterBigPreview * mBigPreviewFloater; - - std::string mOldStatusText; -}; - -class LLTwitterAccountPanel : public LLPanel -{ -public: - LLTwitterAccountPanel(); - BOOL postBuild(); - void draw(); - -private: - void onVisibilityChange(BOOL new_visibility); - bool onTwitterConnectStateChange(const LLSD& data); - bool onTwitterConnectInfoChange(); - void onConnect(); - void onUseAnotherAccount(); - void onDisconnect(); - - void showConnectButton(); - void hideConnectButton(); - void showDisconnectedLayout(); - void showConnectedLayout(); - - LLTextBox * mAccountCaptionLabel; - LLTextBox * mAccountNameLabel; - LLUICtrl * mPanelButtons; - LLUICtrl * mConnectButton; - LLUICtrl * mDisconnectButton; -}; - - -class LLFloaterTwitter : public LLFloater -{ -public: - LLFloaterTwitter(const LLSD& key); - BOOL postBuild(); - void draw(); - void onClose(bool app_quitting); - void onCancel(); - - void showPhotoPanel(); - -private: - LLTwitterPhotoPanel* mTwitterPhotoPanel; - LLTextBox* mStatusErrorText; - LLTextBox* mStatusLoadingText; - LLUICtrl* mStatusLoadingIndicator; -}; - -#endif // LL_LLFLOATERTWITTER_H - diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index c591dfacaf..23fd6d9c8e 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -30,8 +30,6 @@ #include "lliconctrl.h" #include "llfloaterreg.h" #include "llhttpconstants.h" -#include "llflickrconnect.h" -#include "lltwitterconnect.h" #include "lllayoutstack.h" #include "llpluginclassmedia.h" #include "llprogressbar.h" @@ -288,26 +286,6 @@ void LLFloaterWebContent::onOpen(const LLSD& key) //virtual void LLFloaterWebContent::onClose(bool app_quitting) { - // If we close the web browsing window showing the Flickr login, we need to signal to this object that the connection will not happen - // MAINT-3440 note change here to use findInstance and not getInstance - latter creates an instance if it's not there which is bad. - LLFloater* flickr_web = LLFloaterReg::findInstance("flickr_web"); - if (flickr_web == this) - { - if (!LLFlickrConnect::instance().isConnected()) - { - LLFlickrConnect::instance().setConnectionState(LLFlickrConnect::FLICKR_CONNECTION_FAILED); - } - } - // Same with Twitter - // MAINT-3440 note change here to use findInstance and not getInstance - latter creates an instance if it's not there which is bad. - LLFloater* twitter_web = LLFloaterReg::findInstance("twitter_web"); - if (twitter_web == this) - { - if (!LLTwitterConnect::instance().isConnected()) - { - LLTwitterConnect::instance().setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); - } - } LLViewerMedia::getInstance()->proxyWindowClosed(mUUID); destroy(); } diff --git a/indra/newview/llimagefiltersmanager.cpp b/indra/newview/llimagefiltersmanager.cpp index c23cdc8103..3b8adc1610 100644 --- a/indra/newview/llimagefiltersmanager.cpp +++ b/indra/newview/llimagefiltersmanager.cpp @@ -1,6 +1,6 @@ /** * @file llimagefiltersmanager.cpp - * @brief Load image filters list and retrieve their path. Mostly used for Flickr UI at the moment. + * @brief Load image filters list and retrieve their path. * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/llimagefiltersmanager.h b/indra/newview/llimagefiltersmanager.h index f1ed3cf1c3..d06212d85a 100644 --- a/indra/newview/llimagefiltersmanager.h +++ b/indra/newview/llimagefiltersmanager.h @@ -1,6 +1,6 @@ /** * @file llimagefiltersmanager.h - * @brief Load image filters list and retrieve their path. Mostly used for Flickr UI at the moment. + * @brief Load image filters list and retrieve their path. * * $LicenseInfo:firstyear=2000&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp index 23747a8efd..1a3e946127 100644 --- a/indra/newview/llpanelsnapshotoptions.cpp +++ b/indra/newview/llpanelsnapshotoptions.cpp @@ -32,8 +32,6 @@ #include "llfloatersnapshot.h" // FIXME: create a snapshot model #include "llfloaterreg.h" -#include "llfloaterflickr.h" -#include "llfloatertwitter.h" /** * Provides several ways to save a snapshot. @@ -58,8 +56,6 @@ private: void onSaveToEmail(); void onSaveToInventory(); void onSaveToComputer(); - void onSendToTwitter(); - void onSendToFlickr(); LLFloaterSnapshotBase* mSnapshotFloater; }; @@ -72,8 +68,7 @@ LLPanelSnapshotOptions::LLPanelSnapshotOptions() mCommitCallbackRegistrar.add("Snapshot.SaveToEmail", boost::bind(&LLPanelSnapshotOptions::onSaveToEmail, this)); mCommitCallbackRegistrar.add("Snapshot.SaveToInventory", boost::bind(&LLPanelSnapshotOptions::onSaveToInventory, this)); mCommitCallbackRegistrar.add("Snapshot.SaveToComputer", boost::bind(&LLPanelSnapshotOptions::onSaveToComputer, this)); - mCommitCallbackRegistrar.add("Snapshot.SendToTwitter", boost::bind(&LLPanelSnapshotOptions::onSendToTwitter, this)); - mCommitCallbackRegistrar.add("Snapshot.SendToFlickr", boost::bind(&LLPanelSnapshotOptions::onSendToFlickr, this)); + LLGlobalEconomy::getInstance()->addObserver(this); } @@ -135,26 +130,3 @@ void LLPanelSnapshotOptions::onSaveToComputer() openPanel("panel_snapshot_local"); } -void LLPanelSnapshotOptions::onSendToTwitter() -{ - LLFloaterReg::hideInstance("snapshot"); - - LLFloaterTwitter* twitter_floater = dynamic_cast(LLFloaterReg::getInstance("twitter")); - if (twitter_floater) - { - twitter_floater->showPhotoPanel(); - } - LLFloaterReg::showInstance("twitter"); -} - -void LLPanelSnapshotOptions::onSendToFlickr() -{ - LLFloaterReg::hideInstance("snapshot"); - - LLFloaterFlickr* flickr_floater = dynamic_cast(LLFloaterReg::getInstance("flickr")); - if (flickr_floater) - { - flickr_floater->showPhotoPanel(); - } - LLFloaterReg::showInstance("flickr"); -} diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index f5fea9dece..8fef3ff1c0 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -34,8 +34,6 @@ #include "lleconomy.h" #include "llfloaterperms.h" #include "llfloaterreg.h" -#include "llfloaterflickr.h" -#include "llfloatertwitter.h" #include "llimagefilter.h" #include "llimagefiltersmanager.h" #include "llimagebmp.h" diff --git a/indra/newview/lltwitterconnect.cpp b/indra/newview/lltwitterconnect.cpp deleted file mode 100644 index b2d2fa9d77..0000000000 --- a/indra/newview/lltwitterconnect.cpp +++ /dev/null @@ -1,576 +0,0 @@ -/** - * @file lltwitterconnect.h - * @author Merov, Cho - * @brief Connection to Twitter Service - * - * $LicenseInfo:firstyear=2013&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2013, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "lltwitterconnect.h" -#include "llflickrconnect.h" - -#include "llagent.h" -#include "llcallingcard.h" // for LLAvatarTracker -#include "llcommandhandler.h" -#include "llnotificationsutil.h" -#include "llurlaction.h" -#include "llimagepng.h" -#include "llimagejpeg.h" -#include "lltrans.h" -#include "llevents.h" -#include "llviewerregion.h" - -#include "llfloaterwebcontent.h" -#include "llfloaterreg.h" -#include "llcorehttputil.h" - -boost::scoped_ptr LLTwitterConnect::sStateWatcher(new LLEventStream("TwitterConnectState")); -boost::scoped_ptr LLTwitterConnect::sInfoWatcher(new LLEventStream("TwitterConnectInfo")); -boost::scoped_ptr LLTwitterConnect::sContentWatcher(new LLEventStream("TwitterConnectContent")); - -// Local functions -void log_twitter_connect_error(const std::string& request, U32 status, const std::string& reason, const std::string& code, const std::string& description) -{ - // Note: 302 (redirect) is *not* an error that warrants logging - if (status != 302) - { - LL_WARNS("TwitterConnect") << request << " request failed with a " << status << " " << reason << ". Reason: " << code << " (" << description << ")" << LL_ENDL; - } -} - -void toast_user_for_twitter_success() -{ - LLSD args; - args["MESSAGE"] = LLTrans::getString("twitter_post_success"); - LLNotificationsUtil::add("TwitterConnect", args); -} - -class LLTwitterConnectHandler : public LLCommandHandler -{ -public: - LLTwitterConnectHandler() : LLCommandHandler("fbc", UNTRUSTED_THROTTLE) {} - - bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web) - { - if (tokens.size() >= 1) - { - if (tokens[0].asString() == "connect") - { - if (tokens.size() >= 2 && tokens[1].asString() == "twitter") - { - // this command probably came from the twitter_web browser, so close it - LLFloaterReg::hideInstance("twitter_web"); - - // connect to twitter - if (query_map.has("oauth_token")) - { - LLTwitterConnect::instance().connectToTwitter(query_map["oauth_token"], query_map.get("oauth_verifier")); - } - return true; - } - else if (tokens.size() >= 2 && tokens[1].asString() == "flickr") - { - // this command probably came from the flickr_web browser, so close it - LLFloaterReg::hideInstance("flickr_web"); - - // connect to flickr - if (query_map.has("oauth_token")) - { - LLFlickrConnect::instance().connectToFlickr(query_map["oauth_token"], query_map.get("oauth_verifier")); - } - return true; - } - } - } - return false; - } -}; -LLTwitterConnectHandler gTwitterConnectHandler; - - -/////////////////////////////////////////////////////////////////////////////// -// -void LLTwitterConnect::twitterConnectCoro(std::string requestToken, std::string oauthVerifier) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - LLSD body; - if (!requestToken.empty()) - body["request_token"] = requestToken; - if (!oauthVerifier.empty()) - body["oauth_verifier"] = oauthVerifier; - - LLSD result = httpAdapter->putAndSuspend(httpRequest, getTwitterConnectURL("/connection"), body, httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - if ( status == LLCore::HttpStatus(HTTP_FOUND) ) - { - std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; - if (location.empty()) - { - LL_WARNS("FlickrConnect") << "Missing Location header " << LL_ENDL; - } - else - { - openTwitterWeb(location); - } - } - else - { - LL_WARNS("TwitterConnect") << "Connection failed " << status.toString() << LL_ENDL; - setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); - log_twitter_connect_error("Connect", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - } - else - { - LL_DEBUGS("TwitterConnect") << "Connect successful. " << LL_ENDL; - setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -bool LLTwitterConnect::testShareStatus(LLSD &result) -{ - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (status) - return true; - - if (status == LLCore::HttpStatus(HTTP_FOUND)) - { - std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; - if (location.empty()) - { - LL_WARNS("TwitterConnect") << "Missing Location header " << LL_ENDL; - } - else - { - openTwitterWeb(location); - } - } - if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) - { - LL_DEBUGS("TwitterConnect") << "Not connected. " << LL_ENDL; - connectToTwitter(); - } - else - { - LL_WARNS("TwitterConnect") << "HTTP Status error " << status.toString() << LL_ENDL; - setConnectionState(LLTwitterConnect::TWITTER_POST_FAILED); - log_twitter_connect_error("Share", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - return false; -} - -void LLTwitterConnect::twitterShareCoro(std::string route, LLSD share) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - LLSD result = httpAdapter->postAndSuspend(httpRequest, getTwitterConnectURL(route, true), share, httpOpts); - - if (testShareStatus(result)) - { - toast_user_for_twitter_success(); - LL_DEBUGS("TwitterConnect") << "Post successful. " << LL_ENDL; - setConnectionState(LLTwitterConnect::TWITTER_POSTED); - } -} - -void LLTwitterConnect::twitterShareImageCoro(LLPointer image, std::string status) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("FlickrConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpHeaders::ptr_t httpHeaders(new LLCore::HttpHeaders); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - std::string imageFormat; - if (dynamic_cast(image.get())) - { - imageFormat = "png"; - } - else if (dynamic_cast(image.get())) - { - imageFormat = "jpg"; - } - else - { - LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL; - return; - } - - // All this code is mostly copied from LLWebProfile::post() - const std::string boundary = "----------------------------0123abcdefab"; - - std::string contentType = "multipart/form-data; boundary=" + boundary; - httpHeaders->append("Content-Type", contentType.c_str()); - - LLCore::BufferArray::ptr_t raw = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); // - LLCore::BufferArrayStream body(raw.get()); - - // *NOTE: The order seems to matter. - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"status\"\r\n\r\n" - << status << "\r\n"; - - body << "--" << boundary << "\r\n" - << "Content-Disposition: form-data; name=\"image\"; filename=\"Untitled." << imageFormat << "\"\r\n" - << "Content-Type: image/" << imageFormat << "\r\n\r\n"; - - // Insert the image data. - // *FIX: Treating this as a string will probably screw it up ... - U8* image_data = image->getData(); - for (S32 i = 0; i < image->getDataSize(); ++i) - { - body << image_data[i]; - } - - body << "\r\n--" << boundary << "--\r\n"; - - LLSD result = httpAdapter->postAndSuspend(httpRequest, getTwitterConnectURL("/share/photo", true), raw, httpOpts, httpHeaders); - - if (testShareStatus(result)) - { - toast_user_for_twitter_success(); - LL_DEBUGS("TwitterConnect") << "Post successful. " << LL_ENDL; - setConnectionState(LLTwitterConnect::TWITTER_POSTED); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLTwitterConnect::twitterDisconnectCoro() -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setFollowRedirects(false); - - LLSD result = httpAdapter->deleteAndSuspend(httpRequest, getTwitterConnectURL("/connection"), httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status && (status != LLCore::HttpStatus(HTTP_NOT_FOUND))) - { - LL_WARNS("TwitterConnect") << "Disconnect failed!" << LL_ENDL; - setConnectionState(LLTwitterConnect::TWITTER_DISCONNECT_FAILED); - - log_twitter_connect_error("Disconnect", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - else - { - LL_DEBUGS("TwitterConnect") << "Disconnect successful. " << LL_ENDL; - clearInfo(); - setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLTwitterConnect::twitterConnectedCoro(bool autoConnect) -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setFollowRedirects(false); - setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - - LLSD result = httpAdapter->getAndSuspend(httpRequest, getTwitterConnectURL("/connection", true), httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - if (status == LLCore::HttpStatus(HTTP_NOT_FOUND)) - { - LL_DEBUGS("TwitterConnect") << "Not connected. " << LL_ENDL; - if (autoConnect) - { - connectToTwitter(); - } - else - { - setConnectionState(LLTwitterConnect::TWITTER_NOT_CONNECTED); - } - } - else - { - LL_WARNS("TwitterConnect") << "Failed to test connection:" << status.toTerseString() << LL_ENDL; - - setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_FAILED); - log_twitter_connect_error("Connected", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - } - else - { - LL_DEBUGS("TwitterConnect") << "Connect successful. " << LL_ENDL; - setConnectionState(LLTwitterConnect::TWITTER_CONNECTED); - } - -} - -/////////////////////////////////////////////////////////////////////////////// -// -void LLTwitterConnect::twitterInfoCoro() -{ - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("TwitterConnect", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - - httpOpts->setWantHeaders(true); - httpOpts->setFollowRedirects(false); - - LLSD result = httpAdapter->getAndSuspend(httpRequest, getTwitterConnectURL("/info", true), httpOpts); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (status == LLCore::HttpStatus(HTTP_FOUND)) - { - std::string location = httpResults[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS][HTTP_IN_HEADER_LOCATION]; - if (location.empty()) - { - LL_WARNS("TwitterConnect") << "Missing Location header " << LL_ENDL; - } - else - { - openTwitterWeb(location); - } - } - else if (!status) - { - LL_WARNS("TwitterConnect") << "Twitter Info failed: " << status.toString() << LL_ENDL; - log_twitter_connect_error("Info", status.getStatus(), status.toString(), - result.get("error_code"), result.get("error_description")); - } - else - { - LL_INFOS("TwitterConnect") << "Twitter: Info received" << LL_ENDL; - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - storeInfo(result); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// -LLTwitterConnect::LLTwitterConnect() -: mConnectionState(TWITTER_NOT_CONNECTED), - mConnected(false), - mInfo(), - mRefreshInfo(false), - mReadFromMaster(false) -{ -} - -void LLTwitterConnect::openTwitterWeb(std::string url) -{ - LLFloaterWebContent::Params p; - p.url(url); - p.show_chrome(true); - p.allow_back_forward_navigation(false); - p.clean_browser(true); - LLFloater *floater = LLFloaterReg::showInstance("twitter_web", p); - //the internal web browser has a bug that prevents it from gaining focus unless a mouse event occurs first (it seems). - //So when showing the internal web browser, set focus to it's containing floater "twitter_web". When a mouse event - //occurs on the "webbrowser" panel part of the floater, a mouse cursor will properly show and the "webbrowser" will gain focus. - //twitter_web floater contains the "webbrowser" panel. JIRA: ACME-744 - gFocusMgr.setKeyboardFocus( floater ); - - //LLUrlAction::openURLExternal(url); -} - -std::string LLTwitterConnect::getTwitterConnectURL(const std::string& route, bool include_read_from_master) -{ - std::string url(""); - LLViewerRegion *regionp = gAgent.getRegion(); - if (regionp) - { - //url = "http://pdp15.lindenlab.com/twitter/agent/" + gAgentID.asString(); // TEMPORARY FOR TESTING - CHO - url = regionp->getCapability("TwitterConnect"); - url += route; - - if (include_read_from_master && mReadFromMaster) - { - url += "?read_from_master=true"; - } - } - return url; -} - -void LLTwitterConnect::connectToTwitter(const std::string& request_token, const std::string& oauth_verifier) -{ - setConnectionState(LLTwitterConnect::TWITTER_CONNECTION_IN_PROGRESS); - - LLCoros::instance().launch("LLTwitterConnect::twitterConnectCoro", - boost::bind(&LLTwitterConnect::twitterConnectCoro, this, request_token, oauth_verifier)); -} - -void LLTwitterConnect::disconnectFromTwitter() -{ - setConnectionState(LLTwitterConnect::TWITTER_DISCONNECTING); - - LLCoros::instance().launch("LLTwitterConnect::twitterDisconnectCoro", - boost::bind(&LLTwitterConnect::twitterDisconnectCoro, this)); -} - -void LLTwitterConnect::checkConnectionToTwitter(bool auto_connect) -{ - LLCoros::instance().launch("LLTwitterConnect::twitterConnectedCoro", - boost::bind(&LLTwitterConnect::twitterConnectedCoro, this, auto_connect)); -} - -void LLTwitterConnect::loadTwitterInfo() -{ - if(mRefreshInfo) - { - LLCoros::instance().launch("LLTwitterConnect::twitterInfoCoro", - boost::bind(&LLTwitterConnect::twitterInfoCoro, this)); - } -} - -void LLTwitterConnect::uploadPhoto(const std::string& image_url, const std::string& status) -{ - LLSD body; - body["image"] = image_url; - body["status"] = status; - - setConnectionState(LLTwitterConnect::TWITTER_POSTING); - - LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/photo", body)); -} - -void LLTwitterConnect::uploadPhoto(LLPointer image, const std::string& status) -{ - setConnectionState(LLTwitterConnect::TWITTER_POSTING); - - LLCoros::instance().launch("LLTwitterConnect::twitterShareImageCoro", - boost::bind(&LLTwitterConnect::twitterShareImageCoro, this, image, status)); -} - -void LLTwitterConnect::updateStatus(const std::string& status) -{ - LLSD body; - body["status"] = status; - - setConnectionState(LLTwitterConnect::TWITTER_POSTING); - - LLCoros::instance().launch("LLTwitterConnect::twitterShareCoro", - boost::bind(&LLTwitterConnect::twitterShareCoro, this, "/share/status", body)); -} - -void LLTwitterConnect::storeInfo(const LLSD& info) -{ - mInfo = info; - mRefreshInfo = false; - - sInfoWatcher->post(info); -} - -const LLSD& LLTwitterConnect::getInfo() const -{ - return mInfo; -} - -void LLTwitterConnect::clearInfo() -{ - mInfo = LLSD(); -} - -void LLTwitterConnect::setDataDirty() -{ - mRefreshInfo = true; -} - -void LLTwitterConnect::setConnectionState(LLTwitterConnect::EConnectionState connection_state) -{ - if(connection_state == TWITTER_CONNECTED) - { - mReadFromMaster = true; - setConnected(true); - setDataDirty(); - } - else if(connection_state == TWITTER_NOT_CONNECTED) - { - setConnected(false); - } - else if(connection_state == TWITTER_POSTED) - { - mReadFromMaster = false; - } - - if (mConnectionState != connection_state) - { - // set the connection state before notifying watchers - mConnectionState = connection_state; - - LLSD state_info; - state_info["enum"] = connection_state; - sStateWatcher->post(state_info); - } -} - -void LLTwitterConnect::setConnected(bool connected) -{ - mConnected = connected; -} diff --git a/indra/newview/lltwitterconnect.h b/indra/newview/lltwitterconnect.h deleted file mode 100644 index e77048cc35..0000000000 --- a/indra/newview/lltwitterconnect.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file lltwitterconnect.h - * @author Merov, Cho - * @brief Connection to Twitter Service - * - * $LicenseInfo:firstyear=2013&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2013, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLTWITTERCONNECT_H -#define LL_LLTWITTERCONNECT_H - -#include "llsingleton.h" -#include "llimage.h" -#include "llcoros.h" -#include "lleventcoro.h" - -class LLEventPump; - -/** - * @class LLTwitterConnect - * - * Manages authentication to, and interaction with, a web service allowing the - * the viewer to post status updates and upload photos to Twitter. - */ -class LLTwitterConnect : public LLSingleton -{ - LLSINGLETON(LLTwitterConnect); - LOG_CLASS(LLTwitterConnect); -public: - enum EConnectionState - { - TWITTER_NOT_CONNECTED = 0, - TWITTER_CONNECTION_IN_PROGRESS = 1, - TWITTER_CONNECTED = 2, - TWITTER_CONNECTION_FAILED = 3, - TWITTER_POSTING = 4, - TWITTER_POSTED = 5, - TWITTER_POST_FAILED = 6, - TWITTER_DISCONNECTING = 7, - TWITTER_DISCONNECT_FAILED = 8 - }; - - void connectToTwitter(const std::string& request_token = "", const std::string& oauth_verifier = ""); // Initiate the complete Twitter connection. Please use checkConnectionToTwitter() in normal use. - void disconnectFromTwitter(); // Disconnect from the Twitter service. - void checkConnectionToTwitter(bool auto_connect = false); // Check if an access token is available on the Twitter service. If not, call connectToTwitter(). - - void loadTwitterInfo(); - void uploadPhoto(const std::string& image_url, const std::string& status); - void uploadPhoto(LLPointer image, const std::string& status); - void updateStatus(const std::string& status); - - void storeInfo(const LLSD& info); - const LLSD& getInfo() const; - void clearInfo(); - void setDataDirty(); - - void setConnectionState(EConnectionState connection_state); - void setConnected(bool connected); - bool isConnected() { return mConnected; } - bool isTransactionOngoing() { return ((mConnectionState == TWITTER_CONNECTION_IN_PROGRESS) || (mConnectionState == TWITTER_POSTING) || (mConnectionState == TWITTER_DISCONNECTING)); } - EConnectionState getConnectionState() { return mConnectionState; } - - void openTwitterWeb(std::string url); - -private: - - std::string getTwitterConnectURL(const std::string& route = "", bool include_read_from_master = false); - - EConnectionState mConnectionState; - BOOL mConnected; - LLSD mInfo; - bool mRefreshInfo; - bool mReadFromMaster; - - static boost::scoped_ptr sStateWatcher; - static boost::scoped_ptr sInfoWatcher; - static boost::scoped_ptr sContentWatcher; - - bool testShareStatus(LLSD &result); - void twitterConnectCoro(std::string requestToken, std::string oauthVerifier); - void twitterDisconnectCoro(); - void twitterConnectedCoro(bool autoConnect); - void twitterInfoCoro(); - void twitterShareCoro(std::string route, LLSD share); - void twitterShareImageCoro(LLPointer image, std::string status); -}; - -#endif // LL_LLTWITTERCONNECT_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index f475ab7d66..7e0f449d59 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -67,7 +67,6 @@ #include "llfloaterexperiences.h" #include "llfloaterexperiencepicker.h" #include "llfloaterevent.h" -#include "llfloaterflickr.h" #include "llfloaterfonttest.h" #include "llfloatergesture.h" #include "llfloatergodtools.h" @@ -132,7 +131,6 @@ #include "llfloatertos.h" #include "llfloatertoybox.h" #include "llfloatertranslationsettings.h" -#include "llfloatertwitter.h" #include "llfloateruipreview.h" #include "llfloatervoiceeffect.h" #include "llfloaterwebcontent.h" @@ -352,11 +350,6 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create); LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create); - - LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterUIPreviewUtil::registerFloater(); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 5b227c641b..75e707aaa3 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2895,8 +2895,6 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("EstateAccess"); capabilityNames.append("EstateChangeInfo"); capabilityNames.append("EventQueueGet"); - capabilityNames.append("FlickrConnect"); - capabilityNames.append("TwitterConnect"); capabilityNames.append("FetchLib2"); capabilityNames.append("FetchLibDescendents2"); diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 5aba0546f3..7482ec994c 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -133,7 +133,6 @@ with the same filename but different name - @@ -154,7 +153,6 @@ with the same filename but different name - diff --git a/indra/newview/skins/default/xui/en/floater_flickr.xml b/indra/newview/skins/default/xui/en/floater_flickr.xml deleted file mode 100644 index 3b9c4894c1..0000000000 --- a/indra/newview/skins/default/xui/en/floater_flickr.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - Error - - - - Loading... - - - - diff --git a/indra/newview/skins/default/xui/en/floater_twitter.xml b/indra/newview/skins/default/xui/en/floater_twitter.xml deleted file mode 100644 index 5e8dfb8a52..0000000000 --- a/indra/newview/skins/default/xui/en/floater_twitter.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - Error - - - - Loading... - - diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index ab42b76b3b..3bab3aea55 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -308,21 +308,6 @@ parameter="conversation" /> - - - - - - - - - [MESSAGE] - - - - [MESSAGE] - - - - - - Not connected to Flickr. - - - - - - - - [http://community.secondlife.com/t5/English-Knowledge-Base/Second-Life-Share-Flickr/ta-p/2435609 Learn about posting to Flickr] - - - diff --git a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml b/indra/newview/skins/default/xui/en/panel_flickr_photo.xml deleted file mode 100644 index 7fb2291423..0000000000 --- a/indra/newview/skins/default/xui/en/panel_flickr_photo.xml +++ /dev/null @@ -1,259 +0,0 @@ - - - - - - - - - - - - - - Refreshing... - - - - - - Title: - - - - - Description: - - - - - - Tags: - - -Separate tags with spaces -Use "" for multi-word tags - - - - - - - - - - - diff --git a/indra/newview/skins/default/xui/en/panel_snapshot_options.xml b/indra/newview/skins/default/xui/en/panel_snapshot_options.xml index 981b9ab881..2fe4cf8183 100644 --- a/indra/newview/skins/default/xui/en/panel_snapshot_options.xml +++ b/indra/newview/skins/default/xui/en/panel_snapshot_options.xml @@ -56,40 +56,6 @@ - - - - - - [http://community.secondlife.com/t5/English-Knowledge-Base/Second-Life-Share-Twitter/ta-p/2435453 Learn about posting to Twitter] - - - diff --git a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml b/indra/newview/skins/default/xui/en/panel_twitter_photo.xml deleted file mode 100644 index 8774d09a03..0000000000 --- a/indra/newview/skins/default/xui/en/panel_twitter_photo.xml +++ /dev/null @@ -1,196 +0,0 @@ - - - What's happening? - - - 140 - - - - - - - - - - - - - - - - - - Refreshing... - - - - - - - diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 292c2a6293..454616340a 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -201,21 +201,7 @@ Please try logging in again in a minute. You have been disconnected from the region you were in. You were sent to an invalid region. Testing viewer disconnect - - - Connecting to Flickr... - Posting... - Disconnecting from Flickr... - Problem connecting to Flickr - Problem posting to Flickr - Problem disconnecting from Flickr - Connecting to Twitter... - Posting... - Disconnecting from Twitter... - Problem connecting to Twitter - Problem posting to Twitter - Problem disconnecting from Twitter - + Black & White 1970's Colors @@ -3656,13 +3642,6 @@ If you continue to receive this message, contact the [SUPPORT_SITE]. Drag items from inventory here - - You posted to Flickr. - - - You posted to Twitter. - - (IM Session Doesn't Exist) @@ -4088,7 +4067,6 @@ Try enclosing path to the editor with double quotes. Conversations Compass Destinations - Flickr Gestures Grid status How to @@ -4108,7 +4086,6 @@ Try enclosing path to the editor with double quotes. Search Snapshot Speak - Twitter Camera controls Voice settings @@ -4120,7 +4097,6 @@ Try enclosing path to the editor with double quotes. Converse with everyone Compass Destinations of interest - Upload to Flickr Gestures for your avatar Show current Grid status How to do common tasks @@ -4140,7 +4116,6 @@ Try enclosing path to the editor with double quotes. Find places, events, people Take a picture Speak with people nearby using your microphone - Twitter Changing camera angle Volume controls for calls and people near you in world -- cgit v1.2.3 From f9fdae67789c87ad2a6a062570236b5140ccc112 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 13 Nov 2019 12:56:07 +0200 Subject: SL-9699 Field should be populated as long as there is data, regardless of 'remember password' --- indra/newview/llpanellogin.cpp | 25 ++++++++++--------------- indra/newview/llpanellogin.h | 4 ++-- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index d7c189271e..4f050a9748 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -554,12 +554,12 @@ void LLPanelLogin::populateFields(LLPointer credential, bool remem if (sInstance->mFirstLoginThisInstall) { // no list to populate - setFields(credential, remember_psswrd); + setFields(credential); } else { sInstance->getChild("remember_name")->setValue(remember_user); - sInstance->populateUserList(credential, remember_psswrd); + sInstance->populateUserList(credential); remember_check->setEnabled(remember_user); } } @@ -580,16 +580,13 @@ void LLPanelLogin::resetFields() } else { - LLUICtrl* remember_check = sInstance->getChild("remember_check"); - bool remember_psswrd = remember_check->getValue(); LLPointer cred = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid()); - sInstance->populateUserList(cred, remember_psswrd); + sInstance->populateUserList(cred); } } // static -void LLPanelLogin::setFields(LLPointer credential, - bool remember_psswrd) +void LLPanelLogin::setFields(LLPointer credential) { if (!sInstance) { @@ -631,7 +628,7 @@ void LLPanelLogin::setFields(LLPointer credential, LL_INFOS("Credentials") << "Setting authenticator field " << authenticator["type"].asString() << LL_ENDL; if(authenticator.isMap() && authenticator.has("secret") && - (authenticator["secret"].asString().size() > 0) && remember_psswrd) + (authenticator["secret"].asString().size() > 0)) { // This is a MD5 hex digest of a password. @@ -1096,8 +1093,7 @@ void LLPanelLogin::onUserListCommit(void*) { std::string user_key = username_combo->getSelectedValue(); LLPointer cred = gSecAPIHandler->loadFromCredentialMap("login_list", LLGridManager::getInstance()->getGrid(), user_key); - bool remember_psswrd = sInstance->getChild("remember_check")->getValue(); - setFields(cred, remember_psswrd); + setFields(cred); sInstance->mPasswordModified = false; } else @@ -1156,10 +1152,9 @@ void LLPanelLogin::updateServer() if(!sInstance->areCredentialFieldsDirty()) { // populate dropbox and setFields - bool remember_psswrd = sInstance->getChild("remember_check")->getValue(); // Note: following call is related to initializeLoginInfo() LLPointer credential = gSecAPIHandler->loadCredential(LLGridManager::getInstance()->getGrid()); - sInstance->populateUserList(credential, remember_psswrd); + sInstance->populateUserList(credential); } // update the login panel links @@ -1198,7 +1193,7 @@ void LLPanelLogin::updateLoginButtons() } } -void LLPanelLogin::populateUserList(LLPointer credential, bool remember_psswrd) +void LLPanelLogin::populateUserList(LLPointer credential) { LLComboBox* user_combo = getChild("username_combo"); user_combo->removeall(); @@ -1228,7 +1223,7 @@ void LLPanelLogin::populateUserList(LLPointer credential, bool rem } else { - setFields(credential, remember_psswrd); + setFields(credential); } } else @@ -1236,7 +1231,7 @@ void LLPanelLogin::populateUserList(LLPointer credential, bool rem if (credential.notNull()) { user_combo->add(LLPanelLogin::getUserName(credential), credential->userID(), ADD_BOTTOM, TRUE); - setFields(credential, remember_psswrd); + setFields(credential); } } } diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h index 3eb7b68949..c9b8e1b6fc 100644 --- a/indra/newview/llpanellogin.h +++ b/indra/newview/llpanellogin.h @@ -96,7 +96,7 @@ private: void onSelectServer(); void onLocationSLURL(); - static void setFields(LLPointer credential, bool remember_psswrd); + static void setFields(LLPointer credential); static void onClickConnect(void*); static void onClickNewAccount(void*); @@ -113,7 +113,7 @@ private: boost::scoped_ptr mListener; void updateLoginButtons(); - void populateUserList(LLPointer credential, bool remember_psswrd); + void populateUserList(LLPointer credential); void (*mCallback)(S32 option, void *userdata); void* mCallbackData; -- cgit v1.2.3 From 75d910062546eedd609a4cb751bc707cbdd3eac8 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 15 Nov 2019 19:47:03 +0200 Subject: SL-9699 First login panel checkbox was misinterpreted --- indra/newview/llpanellogin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 4f050a9748..cfd486f7f3 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -749,7 +749,7 @@ void LLPanelLogin::getFields(LLPointer& credential, } else { - remember_user = true; + remember_user = remember_psswrd; // on panel_login_first "remember_check" is named as 'remember me' } } -- cgit v1.2.3 From e32a2e2f8ad072408cb9136d3d5fc5f02a232bef Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Sun, 17 Nov 2019 18:21:49 +0200 Subject: SL-9699 Fixed processing of placeholder --- indra/newview/llpanellogin.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index cfd486f7f3..4fd39d1211 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -1230,8 +1230,12 @@ void LLPanelLogin::populateUserList(LLPointer credential) { if (credential.notNull()) { - user_combo->add(LLPanelLogin::getUserName(credential), credential->userID(), ADD_BOTTOM, TRUE); - setFields(credential); + const LLSD &ident = credential->getIdentifier(); + if (ident.isMap() && ident.has("type")) + { + user_combo->add(LLPanelLogin::getUserName(credential), credential->userID(), ADD_BOTTOM, TRUE); + setFields(credential); + } } } } -- cgit v1.2.3 From fed4d3391cf704fb080cf95e15cd992351ba0575 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 18 Nov 2019 21:46:19 +0200 Subject: SL-9699 Fixed processing of placeholder #2 --- indra/newview/llfloaterforgetuser.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterforgetuser.cpp b/indra/newview/llfloaterforgetuser.cpp index 55e25ace9a..363951041a 100644 --- a/indra/newview/llfloaterforgetuser.cpp +++ b/indra/newview/llfloaterforgetuser.cpp @@ -54,7 +54,7 @@ LLFloaterForgetUser::~LLFloaterForgetUser() BOOL LLFloaterForgetUser::postBuild() { - // Note, storage works per grid, watever is selected currently in login screen or logged in. + // Note, storage works per grid, whatever is selected currently in login screen or logged in. // Since login screen can change grid, store the value. mGrid = LLGridManager::getInstance()->getGrid(); @@ -87,14 +87,18 @@ BOOL LLFloaterForgetUser::postBuild() LLPointer cred = gSecAPIHandler->loadCredential(mGrid); if (cred.notNull()) { - LLScrollListItem::Params item_params; - item_params.value(cred->userID()); - item_params.columns.add() - .value(LLPanelLogin::getUserName(cred)) - .column("user") - .font(LLFontGL::getFontSansSerifSmall()); - scroll_list->addRow(item_params, ADD_BOTTOM); - scroll_list->selectFirstItem(); + const LLSD &ident = cred->getIdentifier(); + if (ident.isMap() && ident.has("type")) + { + LLScrollListItem::Params item_params; + item_params.value(cred->userID()); + item_params.columns.add() + .value(LLPanelLogin::getUserName(cred)) + .column("user") + .font(LLFontGL::getFontSansSerifSmall()); + scroll_list->addRow(item_params, ADD_BOTTOM); + scroll_list->selectFirstItem(); + } } } -- cgit v1.2.3 From 8a0338bda074ca0dd9cc1d50c80b34ae0e60e020 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Wed, 20 Nov 2019 21:41:27 +0200 Subject: Backed out changeset: 3ea1714b65b8 --- indra/newview/llimprocessing.cpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index 61655944a8..e3705e82b9 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -854,18 +854,39 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, } else // IM_TASK_INVENTORY_OFFERED { - info->mType = (LLAssetType::EType) binary_bucket[0]; - info->mObjectID = LLUUID::null; - info->mFromObject = TRUE; - } + if (offline == IM_OFFLINE && session_id.isNull() && aux_id.notNull() && binary_bucket_size > sizeof(S8)* 5) + { + // cap received offline message + std::string str_bucket = ll_safe_string((char*)binary_bucket, binary_bucket_size); + typedef boost::tokenizer > tokenizer; + boost::char_separator sep("|", "", boost::keep_empty_tokens); + tokenizer tokens(str_bucket, sep); + tokenizer::iterator iter = tokens.begin(); + + info->mType = (LLAssetType::EType)(atoi((*(iter++)).c_str())); + // Note There is more elements in 'tokens' ... - // In the case of an offline message, the transaction id will be in aux_id and th session_id will be null - // (conversely when online the transaction id is passed as session_id) - info->mTransactionID = session_id.isNull() ? aux_id : session_id; + info->mObjectID = LLUUID::null; + info->mFromObject = TRUE; + } + else + { + if (sizeof(S8) != binary_bucket_size) + { + LL_WARNS("Messaging") << "Malformed inventory offer from object" << LL_ENDL; + delete info; + break; + } + info->mType = (LLAssetType::EType) binary_bucket[0]; + info->mObjectID = LLUUID::null; + info->mFromObject = TRUE; + } + } info->mIM = dialog; info->mFromID = from_id; info->mFromGroup = from_group; + info->mTransactionID = session_id; info->mFolderID = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(info->mType)); info->mFromName = name; -- cgit v1.2.3 From d3f389a38c8c5a2e394ad5f4ee44128e0e2b2dd3 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 26 Nov 2019 17:21:43 +0200 Subject: SL-12326 Textures' apr pool crash fix --- indra/newview/lltexturecache.cpp | 31 ++++++++++++++++++++----------- indra/newview/lltexturecache.h | 7 ++++++- 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index f3bb574191..e2deb7ce1d 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -838,6 +838,7 @@ LLTextureCache::LLTextureCache(bool threaded) mFastCachePoolp(NULL), mFastCachePadBuffer(NULL) { + mHeaderAPRFilePoolp = new LLVolatileAPRPool(); // is_local = true, because this pool is for headers, headers are under own mutex } LLTextureCache::~LLTextureCache() @@ -846,6 +847,7 @@ LLTextureCache::~LLTextureCache() writeUpdatedEntries() ; delete mFastCachep; delete mFastCachePoolp; + delete mHeaderAPRFilePoolp; ll_aligned_free_16(mFastCachePadBuffer); } @@ -1014,10 +1016,11 @@ void LLTextureCache::purgeCache(ELLPath location, bool remove_dir) if(LLFile::isdir(mTexturesDirName)) { std::string file_name = gDirUtilp->getExpandedFilename(location, entries_filename); - LLAPRFile::remove(file_name, getLocalAPRFilePool()); + // mHeaderAPRFilePoolp because we are under header mutex, and can be in main thread + LLAPRFile::remove(file_name, mHeaderAPRFilePoolp); file_name = gDirUtilp->getExpandedFilename(location, cache_filename); - LLAPRFile::remove(file_name, getLocalAPRFilePool()); + LLAPRFile::remove(file_name, mHeaderAPRFilePoolp); purgeAllTextures(true); } @@ -1094,7 +1097,7 @@ LLAPRFile* LLTextureCache::openHeaderEntriesFile(bool readonly, S32 offset) { llassert_always(mHeaderAPRFile == NULL); apr_int32_t flags = readonly ? APR_READ|APR_BINARY : APR_READ|APR_WRITE|APR_BINARY; - mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, getLocalAPRFilePool()); + mHeaderAPRFile = new LLAPRFile(mHeaderEntriesFileName, flags, mHeaderAPRFilePoolp); if(offset > 0) { mHeaderAPRFile->seek(APR_SET, offset); @@ -1117,10 +1120,10 @@ void LLTextureCache::readEntriesHeader() { // mHeaderEntriesInfo initializes to default values so safe not to read it llassert_always(mHeaderAPRFile == NULL); - if (LLAPRFile::isExist(mHeaderEntriesFileName, getLocalAPRFilePool())) + if (LLAPRFile::isExist(mHeaderEntriesFileName, mHeaderAPRFilePoolp)) { LLAPRFile::readEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo), - getLocalAPRFilePool()); + mHeaderAPRFilePoolp); } else //create an empty entries header. { @@ -1152,7 +1155,7 @@ void LLTextureCache::writeEntriesHeader() if (!mReadOnly) { LLAPRFile::writeEx(mHeaderEntriesFileName, (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo), - getLocalAPRFilePool()); + mHeaderAPRFilePoolp); } } @@ -1832,7 +1835,8 @@ void LLTextureCache::purgeTextures(bool validate) if (uuididx == validate_idx) { LL_DEBUGS("TextureCache") << "Validating: " << filename << "Size: " << entries[idx].mBodySize << LL_ENDL; - S32 bodysize = LLAPRFile::size(filename, getLocalAPRFilePool()); + // mHeaderAPRFilePoolp because this is under header mutex in main thread + S32 bodysize = LLAPRFile::size(filename, mHeaderAPRFilePoolp); if (bodysize != entries[idx].mBodySize) { LL_WARNS("TextureCache") << "TEXTURE CACHE BODY HAS BAD SIZE: " << bodysize << " != " << entries[idx].mBodySize @@ -2231,7 +2235,7 @@ void LLTextureCache::openFastCache(bool first_time) { mFastCachePadBuffer = (U8*)ll_aligned_malloc_16(TEXTURE_FAST_CACHE_ENTRY_SIZE); } - mFastCachePoolp = new LLVolatileAPRPool(); + mFastCachePoolp = new LLVolatileAPRPool(); // is_local= true by default, so not thread safe by default if (LLAPRFile::isExist(mFastCacheFileName, mFastCachePoolp)) { mFastCachep = new LLAPRFile(mFastCacheFileName, APR_READ|APR_WRITE|APR_BINARY, mFastCachePoolp) ; @@ -2315,7 +2319,9 @@ void LLTextureCache::removeCachedTexture(const LLUUID& id) mTexturesSizeMap.erase(id); } mHeaderIDMap.erase(id); - LLAPRFile::remove(getTextureFileName(id), getLocalAPRFilePool()); + // We are inside header's mutex so mHeaderAPRFilePoolp is safe to use, + // but getLocalAPRFilePool() is not safe, it might be in use by worker + LLAPRFile::remove(getTextureFileName(id), mHeaderAPRFilePoolp); } //called after mHeaderMutex is locked. @@ -2327,7 +2333,10 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename) { if (entry.mBodySize == 0) // Always attempt to remove when mBodySize > 0. { - if (LLAPRFile::isExist(filename, getLocalAPRFilePool())) // Sanity check. Shouldn't exist when body size is 0. + // Sanity check. Shouldn't exist when body size is 0. + // We are inside header's mutex so mHeaderAPRFilePoolp is safe to use, + // but getLocalAPRFilePool() is not safe, it might be in use by worker + if (LLAPRFile::isExist(filename, mHeaderAPRFilePoolp)) { LL_WARNS("TextureCache") << "Entry has body size of zero but file " << filename << " exists. Deleting this file, too." << LL_ENDL; } @@ -2347,7 +2356,7 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename) if (file_maybe_exists) { - LLAPRFile::remove(filename, getLocalAPRFilePool()); + LLAPRFile::remove(filename, mHeaderAPRFilePoolp); } } diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h index da59290930..6046f2b9df 100644 --- a/indra/newview/lltexturecache.h +++ b/indra/newview/lltexturecache.h @@ -139,7 +139,7 @@ public: U32 getEntries() { return mHeaderEntriesInfo.mEntries; } U32 getMaxEntries() { return sCacheMaxEntries; }; BOOL isInCache(const LLUUID& id) ; - BOOL isInLocal(const LLUUID& id) ; + BOOL isInLocal(const LLUUID& id) ; //not thread safe at the moment protected: // Accessed by LLTextureCacheWorker @@ -190,6 +190,11 @@ private: LLMutex mFastCacheMutex; LLAPRFile* mHeaderAPRFile; LLVolatileAPRPool* mFastCachePoolp; + + // mLocalAPRFilePoolp is not thread safe and is meant only for workers + // howhever mHeaderEntriesFileName is accessed not from workers' threads + // so it needs own pool (not thread safe by itself, relies onto header's mutex) + LLVolatileAPRPool* mHeaderAPRFilePoolp; typedef std::map handle_map_t; handle_map_t mReaders; -- cgit v1.2.3