summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterreporter.cpp
diff options
context:
space:
mode:
authorcoyot@coyot-sager-PC <coyot@coyot-sager-PC>2017-02-28 22:56:30 +0000
committercoyot@coyot-sager-PC <coyot@coyot-sager-PC>2017-02-28 22:56:30 +0000
commit3a3da6e4a76859f32dc36491fde2992e92ae57b5 (patch)
treef61a7417ad6ffcb8488c910cfa64f14afe979071 /indra/newview/llfloaterreporter.cpp
parent069c938eb6ebfd77f6a415207331c66f72270e5f (diff)
parentf0b256b1cb6c96aed81ee456e505247fd2169c5f (diff)
merge
Diffstat (limited to 'indra/newview/llfloaterreporter.cpp')
-rw-r--r--indra/newview/llfloaterreporter.cpp151
1 files changed, 97 insertions, 54 deletions
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index ed6f4ede9f..275554540e 100644
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -37,6 +37,7 @@
#include "llcachename.h"
#include "llcheckboxctrl.h"
#include "llfontgl.h"
+#include "llimagebmp.h"
#include "llimagej2c.h"
#include "llinventory.h"
#include "llnotificationsutil.h"
@@ -76,6 +77,7 @@
#include "llselectmgr.h"
#include "llversioninfo.h"
#include "lluictrlfactory.h"
+#include "llviewercontrol.h"
#include "llviewernetwork.h"
#include "llagentui.h"
@@ -86,6 +88,7 @@
#include "llcorehttputil.h"
#include "llviewerassetupload.h"
+const std::string SCREEN_PREV_FILENAME = "screen_report_last.bmp";
//=========================================================================
//-----------------------------------------------------------------------------
@@ -181,18 +184,12 @@ BOOL LLFloaterReporter::postBuild()
}
setPosBox(pos);
- // Take a screenshot, but don't draw this floater.
- setVisible(FALSE);
- takeScreenshot();
- setVisible(TRUE);
-
// Default text to be blank
getChild<LLUICtrl>("object_name")->setValue(LLStringUtil::null);
getChild<LLUICtrl>("owner_name")->setValue(LLStringUtil::null);
mOwnerName = LLStringUtil::null;
getChild<LLUICtrl>("summary_edit")->setFocus(TRUE);
- getChild<LLCheckBoxCtrl>("screen_check")->set(TRUE);
mDefaultSummary = getChild<LLUICtrl>("details_edit")->getValue().asString();
@@ -246,8 +243,6 @@ LLFloaterReporter::~LLFloaterReporter()
// virtual
void LLFloaterReporter::draw()
{
- getChildView("screen_check")->setEnabled(TRUE );
-
LLFloater::draw();
}
@@ -255,7 +250,6 @@ void LLFloaterReporter::enableControls(BOOL enable)
{
getChildView("category_combo")->setEnabled(enable);
getChildView("chat_check")->setEnabled(enable);
- getChildView("screen_check")->setEnabled(enable);
getChildView("screenshot")->setEnabled(FALSE);
getChildView("pick_btn")->setEnabled(enable);
getChildView("summary_edit")->setEnabled(enable);
@@ -448,23 +442,15 @@ void LLFloaterReporter::onClickSend(void *userdata)
if(!url.empty() || !sshot_url.empty())
{
self->sendReportViaCaps(url, sshot_url, self->gatherReport());
+ LLNotificationsUtil::add("HelpReportAbuseConfirm");
self->closeFloater();
}
else
{
- if(self->getChild<LLUICtrl>("screen_check")->getValue())
- {
- self->getChildView("send_btn")->setEnabled(FALSE);
- self->getChildView("cancel_btn")->setEnabled(FALSE);
- // the callback from uploading the image calls sendReportViaLegacy()
- self->uploadImage();
- }
- else
- {
- self->sendReportViaLegacy(self->gatherReport());
- LLUploadDialog::modalUploadFinished();
- self->closeFloater();
- }
+ self->getChildView("send_btn")->setEnabled(FALSE);
+ self->getChildView("cancel_btn")->setEnabled(FALSE);
+ // the callback from uploading the image calls sendReportViaLegacy()
+ self->uploadImage();
}
}
}
@@ -524,50 +510,59 @@ void LLFloaterReporter::showFromMenu(EReportType report_type)
LL_WARNS() << "Unknown LLViewerReporter type : " << report_type << LL_ENDL;
return;
}
-
- LLFloaterReporter* f = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter", LLSD());
- if (f)
+ LLFloaterReporter* reporter_floater = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter");
+ if(reporter_floater && reporter_floater->isInVisibleChain())
{
- f->setReportType(report_type);
+ gSavedPerAccountSettings.setBOOL("PreviousScreenshotForReport", FALSE);
+ }
+ reporter_floater = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter", LLSD());
+ if (reporter_floater)
+ {
+ reporter_floater->setReportType(report_type);
}
}
// static
void LLFloaterReporter::show(const LLUUID& object_id, const std::string& avatar_name, const LLUUID& experience_id)
{
- LLFloaterReporter* f = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter");
-
+ LLFloaterReporter* reporter_floater = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter");
+ if(reporter_floater && reporter_floater->isInVisibleChain())
+ {
+ gSavedPerAccountSettings.setBOOL("PreviousScreenshotForReport", FALSE);
+ }
+ reporter_floater = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter");
if (avatar_name.empty())
{
// Request info for this object
- f->getObjectInfo(object_id);
+ reporter_floater->getObjectInfo(object_id);
}
else
{
- f->setFromAvatarID(object_id);
+ reporter_floater->setFromAvatarID(object_id);
}
if(experience_id.notNull())
{
- f->getExperienceInfo(experience_id);
+ reporter_floater->getExperienceInfo(experience_id);
}
// Need to deselect on close
- f->mDeselectOnClose = TRUE;
-
- f->openFloater();
+ reporter_floater->mDeselectOnClose = TRUE;
}
void LLFloaterReporter::showFromExperience( const LLUUID& experience_id )
{
- LLFloaterReporter* f = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter");
- f->getExperienceInfo(experience_id);
+ LLFloaterReporter* reporter_floater = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter");
+ if(reporter_floater && reporter_floater->isInVisibleChain())
+ {
+ gSavedPerAccountSettings.setBOOL("PreviousScreenshotForReport", FALSE);
+ }
+ reporter_floater = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter");
+ reporter_floater->getExperienceInfo(experience_id);
// Need to deselect on close
- f->mDeselectOnClose = TRUE;
-
- f->openFloater();
+ reporter_floater->mDeselectOnClose = TRUE;
}
@@ -713,10 +708,7 @@ LLSD LLFloaterReporter::gatherReport()
// only send a screenshot ID if we're asked to and the email is
// going to LL - Estate Owners cannot see the screenshot asset
LLUUID screenshot_id = LLUUID::null;
- if (getChild<LLUICtrl>("screen_check")->getValue())
- {
- screenshot_id = getChild<LLUICtrl>("screenshot")->getValue();
- };
+ screenshot_id = getChild<LLUICtrl>("screenshot")->getValue();
LLSD report = LLSD::emptyMap();
report["report-type"] = (U8) mReportType;
@@ -770,7 +762,7 @@ void LLFloaterReporter::finishedARPost(const LLSD &)
void LLFloaterReporter::sendReportViaCaps(std::string url, std::string sshot_url, const LLSD& report)
{
- if(getChild<LLUICtrl>("screen_check")->getValue().asBoolean() && !sshot_url.empty())
+ if(!sshot_url.empty())
{
// try to upload screenshot
LLResourceUploadInfo::ptr_t uploadInfo(new LLARScreenShotUploader(report, mResourceDatap->mAssetInfo.mUuid, mResourceDatap->mAssetInfo.mType));
@@ -784,18 +776,24 @@ void LLFloaterReporter::sendReportViaCaps(std::string url, std::string sshot_url
}
}
-void LLFloaterReporter::takeScreenshot()
+void LLFloaterReporter::takeScreenshot(bool use_prev_screenshot)
{
- const S32 IMAGE_WIDTH = 1024;
- const S32 IMAGE_HEIGHT = 768;
-
- LLPointer<LLImageRaw> raw = new LLImageRaw;
- if( !gViewerWindow->rawSnapshot(raw, IMAGE_WIDTH, IMAGE_HEIGHT, TRUE, FALSE, TRUE, FALSE))
+ gSavedPerAccountSettings.setBOOL("PreviousScreenshotForReport", TRUE);
+ if(!use_prev_screenshot)
{
- LL_WARNS() << "Unable to take screenshot" << LL_ENDL;
- return;
+ std::string screenshot_filename(gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + SCREEN_PREV_FILENAME);
+ LLPointer<LLImageBMP> bmp_image = new LLImageBMP;
+ if(bmp_image->encode(mImageRaw, 0.0f))
+ {
+ bmp_image->save(screenshot_filename);
+ }
+ }
+ else
+ {
+ mImageRaw = mPrevImageRaw;
}
- LLPointer<LLImageJ2C> upload_data = LLViewerTextureList::convertToUploadFile(raw);
+
+ LLPointer<LLImageJ2C> upload_data = LLViewerTextureList::convertToUploadFile(mImageRaw);
// create a resource data
mResourceDatap->mInventoryType = LLInventoryType::IT_NONE;
@@ -827,7 +825,7 @@ void LLFloaterReporter::takeScreenshot()
// store in the image list so it doesn't try to fetch from the server
LLPointer<LLViewerFetchedTexture> image_in_list =
LLViewerTextureManager::getFetchedTexture(mResourceDatap->mAssetInfo.mUuid);
- image_in_list->createGLTexture(0, raw, 0, TRUE, LLGLTexture::OTHER);
+ image_in_list->createGLTexture(0, mImageRaw, 0, TRUE, LLGLTexture::OTHER);
// the texture picker then uses that texture
LLTextureCtrl* texture = getChild<LLTextureCtrl>("screenshot");
@@ -837,7 +835,46 @@ void LLFloaterReporter::takeScreenshot()
texture->setDefaultImageAssetID(mResourceDatap->mAssetInfo.mUuid);
texture->setCaption(getString("Screenshot"));
}
+}
+
+void LLFloaterReporter::onOpen(const LLSD& key)
+{
+ mImageRaw = new LLImageRaw;
+ const S32 IMAGE_WIDTH = 1024;
+ const S32 IMAGE_HEIGHT = 768;
+
+ // Take a screenshot, but don't draw this floater.
+ setVisible(FALSE);
+ if( !gViewerWindow->rawSnapshot(mImageRaw, IMAGE_WIDTH, IMAGE_HEIGHT, TRUE, FALSE, TRUE, FALSE))
+ {
+ LL_WARNS() << "Unable to take screenshot" << LL_ENDL;
+ setVisible(TRUE);
+ return;
+ }
+ setVisible(TRUE);
+ if(gSavedPerAccountSettings.getBOOL("PreviousScreenshotForReport"))
+ {
+ std::string screenshot_filename(gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + SCREEN_PREV_FILENAME);
+ mPrevImageRaw = new LLImageRaw;
+ LLPointer<LLImageBMP> start_image_bmp = new LLImageBMP;
+ if(start_image_bmp->load(screenshot_filename))
+ {
+ if (start_image_bmp->decode(mPrevImageRaw, 0.0f))
+ {
+ LLNotificationsUtil::add("LoadPreviousReportScreenshot", LLSD(), LLSD(), boost::bind(&LLFloaterReporter::onLoadScreenshotDialog,this, _1, _2));
+ return;
+ }
+ }
+ }
+
+ takeScreenshot();
+}
+
+void LLFloaterReporter::onLoadScreenshotDialog(const LLSD& notification, const LLSD& response)
+{
+ S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+ takeScreenshot(option == 0);
}
void LLFloaterReporter::uploadImage()
@@ -885,6 +922,7 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data,
self->mScreenID = uuid;
LL_INFOS() << "Got screen shot " << uuid << LL_ENDL;
self->sendReportViaLegacy(self->gatherReport());
+ LLNotificationsUtil::add("HelpReportAbuseConfirm");
self->closeFloater();
}
}
@@ -900,6 +938,11 @@ void LLFloaterReporter::setPosBox(const LLVector3d &pos)
getChild<LLUICtrl>("pos_field")->setValue(pos_string);
}
+void LLFloaterReporter::onClose(bool app_quitting)
+{
+ gSavedPerAccountSettings.setBOOL("PreviousScreenshotForReport", app_quitting);
+}
+
// void LLFloaterReporter::setDescription(const std::string& description, LLMeanCollisionData *mcd)
// {