diff options
Diffstat (limited to 'indra/newview/llfloaterreporter.cpp')
-rw-r--r-- | indra/newview/llfloaterreporter.cpp | 441 |
1 files changed, 167 insertions, 274 deletions
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 412494eeb3..4d154c4cd3 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -48,19 +48,19 @@ #include "llversionviewer.h" #include "message.h" #include "v3math.h" +#include "lltexteditor.h" // viewer project includes #include "llagent.h" #include "llbutton.h" #include "llcheckboxctrl.h" -#include "llinventoryview.h" +#include "llfloaterreg.h" #include "lllineeditor.h" #include "lltexturectrl.h" #include "llscrolllistctrl.h" #include "llimview.h" #include "lltextbox.h" #include "lldispatcher.h" -#include "llviewertexteditor.h" #include "llviewerobject.h" #include "llviewerregion.h" #include "llcombobox.h" @@ -73,7 +73,7 @@ #include "lltoolmgr.h" #include "llresourcedata.h" // for LLResourceData #include "llviewerwindow.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llworldmap.h" #include "llfilepicker.h" #include "llfloateravatarpicker.h" @@ -84,6 +84,7 @@ #include "llviewernetwork.h" #include "llassetuploadresponders.h" +#include "llagentui.h" const U32 INCLUDE_SCREENSHOT = 0x01 << 0; @@ -91,28 +92,14 @@ const U32 INCLUDE_SCREENSHOT = 0x01 << 0; // Globals //----------------------------------------------------------------------------- -// this map keeps track of current reporter instances -// there can only be one instance of each reporter type -LLMap< EReportType, LLFloaterReporter* > gReporterInstances; - -// keeps track of where email is going to - global to avoid a pile -// of static/non-static access outside my control -namespace { - static BOOL gEmailToEstateOwner = FALSE; - static BOOL gDialogVisible = FALSE; -} - //----------------------------------------------------------------------------- // Member functions //----------------------------------------------------------------------------- -LLFloaterReporter::LLFloaterReporter( - const std::string& name, - const LLRect& rect, - const std::string& title, - EReportType report_type) - : - LLFloater(name, rect, title), - mReportType(report_type), + +LLFloaterReporter::LLFloaterReporter(const LLSD& key) +: LLFloater(key), + mReportType(COMPLAINT_REPORT), + mEmailToEstateOwner(FALSE), mObjectID(), mScreenID(), mAbuserID(), @@ -122,37 +109,35 @@ LLFloaterReporter::LLFloaterReporter( mCopyrightWarningSeen( FALSE ), mResourceDatap(new LLResourceData()) { - if (report_type == BUG_REPORT) - { - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_report_bug.xml"); - } - else - { - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_report_abuse.xml"); - } - - childSetText("abuse_location_edit", gAgent.getSLURL() ); - - LLButton* pick_btn = getChild<LLButton>("pick_btn"); - if (pick_btn) - { - // XUI: Why aren't these in viewerart.ini? - pick_btn->setImages( std::string("UIImgFaceUUID"), - std::string("UIImgFaceSelectedUUID") ); - childSetAction("pick_btn", onClickObjPicker, this); - } + //LLUICtrlFactory::getInstance()->buildFloater(this, "floater_report_abuse.xml"); +} - if (report_type != BUG_REPORT) +// static +void LLFloaterReporter::processRegionInfo(LLMessageSystem* msg) +{ + U32 region_flags; + msg->getU32("RegionInfo", "RegionFlags", region_flags); + + if ( LLFloaterReg::instanceVisible("reporter") ) { - // abuser name is selected from a list - LLLineEditor* le = getChild<LLLineEditor>("abuser_name_edit"); - le->setEnabled( FALSE ); - } - - childSetAction("select_abuser", onClickSelectAbuser, this); + LLFloaterReporter *f = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter"); + BOOL email_to_estate_owner = ( region_flags & REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER ); + f->mEmailToEstateOwner = email_to_estate_owner; - childSetAction("send_btn", onClickSend, this); - childSetAction("cancel_btn", onClickCancel, this); + if ( email_to_estate_owner ) + { + LLNotifications::instance().add("HelpReportAbuseEmailEO"); + } + else + { + LLNotifications::instance().add("HelpReportAbuseEmailLL"); + } + }; +} +// virtual +BOOL LLFloaterReporter::postBuild() +{ + childSetText("abuse_location_edit", LLAgentUI::buildSLURL()); enableControls(TRUE); @@ -165,8 +150,6 @@ LLFloaterReporter::LLFloaterReporter( } setPosBox(pos); - gReporterInstances.addData(report_type, this); - // Take a screenshot, but don't draw this floater. setVisible(FALSE); takeScreenshot(); @@ -180,44 +163,43 @@ LLFloaterReporter::LLFloaterReporter( mDefaultSummary = childGetText("details_edit"); - gDialogVisible = TRUE; + // send a message and ask for information about this region - + // result comes back in processRegionInfo(..) + LLMessageSystem* msg = gMessageSystem; + msg->newMessage("RequestRegionInfo"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("SessionID", gAgent.getSessionID()); + gAgent.sendReliableMessage(); + + + // abuser name is selected from a list + LLLineEditor* le = getChild<LLLineEditor>("abuser_name_edit"); + le->setEnabled( FALSE ); - // only request details for abuse reports (not BUG reports) - if (report_type != BUG_REPORT) - { - // send a message and ask for information about this region - - // result comes back in processRegionInfo(..) - LLMessageSystem* msg = gMessageSystem; - msg->newMessage("RequestRegionInfo"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - gAgent.sendReliableMessage(); - }; -} + setPosBox((LLVector3d)mPosition.getValue()); + LLButton* pick_btn = getChild<LLButton>("pick_btn"); + pick_btn->setImages(std::string("tool_face.tga"), + std::string("tool_face_active.tga") ); + childSetAction("pick_btn", onClickObjPicker, this); -// static -void LLFloaterReporter::processRegionInfo(LLMessageSystem* msg) -{ - U32 region_flags; - msg->getU32("RegionInfo", "RegionFlags", region_flags); - gEmailToEstateOwner = ( region_flags & REGION_FLAGS_ABUSE_EMAIL_TO_ESTATE_OWNER ); + childSetAction("select_abuser", onClickSelectAbuser, this); - if ( gDialogVisible ) - { - if ( gEmailToEstateOwner ) - { - LLNotifications::instance().add("HelpReportAbuseEmailEO"); - } - else - LLNotifications::instance().add("HelpReportAbuseEmailLL"); - }; -} + childSetAction("send_btn", onClickSend, this); + childSetAction("cancel_btn", onClickCancel, this); + + // grab the user's name + std::string fullname; + LLAgentUI::buildFullname(fullname); + childSetText("reporter_field", fullname); + + center(); + return TRUE; +} // virtual LLFloaterReporter::~LLFloaterReporter() { - gReporterInstances.removeData(mReportType); // child views automatically deleted mObjectID = LLUUID::null; @@ -232,7 +214,6 @@ LLFloaterReporter::~LLFloaterReporter() mMCDList.clear(); delete mResourceDatap; - gDialogVisible = FALSE; } // virtual @@ -241,7 +222,7 @@ void LLFloaterReporter::draw() // this is set by a static callback sometime after the dialog is created. // Only disable screenshot for abuse reports to estate owners - bug reports always // allow screenshots to be taken. - if ( gEmailToEstateOwner && ( mReportType != BUG_REPORT ) ) + if ( mEmailToEstateOwner ) { childSetValue("screen_check", FALSE ); childSetEnabled("screen_check", FALSE ); @@ -257,11 +238,7 @@ void LLFloaterReporter::draw() void LLFloaterReporter::enableControls(BOOL enable) { childSetEnabled("category_combo", enable); - // bug reports never include the chat history - if (mReportType != BUG_REPORT) - { - childSetEnabled("chat_check", enable); - } + childSetEnabled("chat_check", enable); childSetEnabled("screen_check", enable); childDisable("screenshot"); childSetEnabled("pick_btn", enable); @@ -332,7 +309,7 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id) // we have to query the simulator for information // about this object LLMessageSystem* msg = gMessageSystem; - U32 request_flags = (mReportType == BUG_REPORT) ? BUG_REPORT_REQUEST : COMPLAINT_REPORT_REQUEST; + U32 request_flags = COMPLAINT_REPORT_REQUEST; msg->newMessageFast(_PREHASH_RequestObjectPropertiesFamily); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); @@ -363,15 +340,12 @@ void LLFloaterReporter::callbackAvatarID(const std::vector<std::string>& names, if (ids.empty() || names.empty()) return; - // this should never be called in a bug report but here for safety. - if ( self->mReportType != BUG_REPORT ) - { - self->childSetText("abuser_name_edit", names[0] ); - - self->mAbuserID = ids[0]; + self->childSetText("abuser_name_edit", names[0] ); + + self->mAbuserID = ids[0]; + + self->refresh(); - self->refresh(); - }; } // static @@ -386,9 +360,7 @@ void LLFloaterReporter::onClickSend(void *userdata) if(self->validateReport()) { - // only show copyright alert for abuse reports - if ( self->mReportType != BUG_REPORT ) - { + const int IP_CONTENT_REMOVAL = 66; const int IP_PERMISSONS_EXPLOIT = 37; LLComboBox* combo = self->getChild<LLComboBox>( "category_combo"); @@ -418,7 +390,7 @@ void LLFloaterReporter::onClickSend(void *userdata) LLNotifications::instance().add("HelpReportAbuseContainsCopyright"); return; } - } + LLUploadDialog::modalUploadDialog("Uploading...\n\nReport"); // *TODO don't upload image if checkbox isn't checked @@ -427,7 +399,7 @@ void LLFloaterReporter::onClickSend(void *userdata) if(!url.empty() || !sshot_url.empty()) { self->sendReportViaCaps(url, sshot_url, self->gatherReport()); - self->close(); + self->closeFloater(); } else { @@ -442,7 +414,7 @@ void LLFloaterReporter::onClickSend(void *userdata) { self->sendReportViaLegacy(self->gatherReport()); LLUploadDialog::modalUploadFinished(); - self->close(); + self->closeFloater(); } } } @@ -461,7 +433,7 @@ void LLFloaterReporter::onClickCancel(void *userdata) { closePickTool(self); } - self->close(); + self->closeFloater(); } @@ -497,30 +469,16 @@ void LLFloaterReporter::closePickTool(void *userdata) // static void LLFloaterReporter::showFromMenu(EReportType report_type) { - if (gReporterInstances.checkData(report_type)) + if (COMPLAINT_REPORT != report_type) { - // ...bring that window to front - LLFloaterReporter *f = gReporterInstances.getData(report_type); - f->open(); /* Flawfinder: ignore */ + llwarns << "Unknown LLViewerReporter type : " << report_type << llendl; + return; } - else + + LLFloaterReporter* f = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter", LLSD()); + if (f) { - LLFloaterReporter *f; - if (BUG_REPORT == report_type) - { - f = LLFloaterReporter::createNewBugReporter(); - } - else if (COMPLAINT_REPORT == report_type) - { - f = LLFloaterReporter::createNewAbuseReporter(); - } - else - { - llwarns << "Unknown LLViewerReporter type : " << report_type << llendl; - return; - } - - f->center(); + f->setReportType(report_type); if (report_type == BUG_REPORT) { @@ -530,11 +488,6 @@ void LLFloaterReporter::showFromMenu(EReportType report_type) { // popup for abuse reports is triggered elsewhere } - - // grab the user's name - std::string fullname; - gAgent.buildFullname(fullname); - f->childSetText("reporter_field", fullname); } } @@ -542,13 +495,11 @@ void LLFloaterReporter::showFromMenu(EReportType report_type) // static void LLFloaterReporter::showFromObject(const LLUUID& object_id) { - LLFloaterReporter* f = createNewAbuseReporter(); - f->center(); - f->setFocus(TRUE); + LLFloaterReporter* f = LLFloaterReg::showTypedInstance<LLFloaterReporter>("reporter"); // grab the user's name std::string fullname; - gAgent.buildFullname(fullname); + LLAgentUI::buildFullname(fullname); f->childSetText("reporter_field", fullname); // Request info for this object @@ -557,39 +508,8 @@ void LLFloaterReporter::showFromObject(const LLUUID& object_id) // Need to deselect on close f->mDeselectOnClose = TRUE; - f->open(); /* Flawfinder: ignore */ -} - - -// static -LLFloaterReporter* LLFloaterReporter::getReporter(EReportType report_type) -{ - LLFloaterReporter *self = NULL; - if (gReporterInstances.checkData(report_type)) - { - // ...bring that window to front - self = gReporterInstances.getData(report_type); - } - return self; -} - -LLFloaterReporter* LLFloaterReporter::createNewAbuseReporter() -{ - return new LLFloaterReporter("complaint_reporter", - LLRect(), - "Report Abuse", - COMPLAINT_REPORT); -} - -//static -LLFloaterReporter* LLFloaterReporter::createNewBugReporter() -{ - return new LLFloaterReporter("bug_reporter", - LLRect(), - "Report Bug", - BUG_REPORT); + f->openFloater(); } - void LLFloaterReporter::setPickedObjectProperties(const std::string& object_name, const std::string& owner_name, const LLUUID owner_id) @@ -619,21 +539,26 @@ bool LLFloaterReporter::validateReport() return false; } - if ( mReportType != BUG_REPORT ) + + if ( childGetText("abuser_name_edit").empty() ) + { + LLNotifications::instance().add("HelpReportAbuseAbuserNameEmpty"); + return false; + }; + + if ( childGetText("abuse_location_edit").empty() ) + { + LLNotifications::instance().add("HelpReportAbuseAbuserLocationEmpty"); + return false; + }; + + if ( childGetText("abuse_location_edit").empty() ) { - if ( childGetText("abuser_name_edit").empty() ) - { - LLNotifications::instance().add("HelpReportAbuseAbuserNameEmpty"); - return false; - }; - - if ( childGetText("abuse_location_edit").empty() ) - { - LLNotifications::instance().add("HelpReportAbuseAbuserLocationEmpty"); - return false; - }; + LLNotifications::instance().add("HelpReportAbuseAbuserLocationEmpty"); + return false; }; + if ( childGetText("summary_edit").empty() ) { if ( mReportType != BUG_REPORT ) @@ -685,50 +610,34 @@ LLSD LLFloaterReporter::gatherReport() #if LL_WINDOWS const char* platform = "Win"; - const char* short_platform = "O:W"; #elif LL_DARWIN const char* platform = "Mac"; - const char* short_platform = "O:M"; #elif LL_LINUX const char* platform = "Lnx"; - const char* short_platform = "O:L"; #elif LL_SOLARIS const char* platform = "Sol"; const char* short_platform = "O:S"; #else const char* platform = "???"; - const char* short_platform = "O:?"; #endif - if ( mReportType == BUG_REPORT) - { - summary << short_platform << " V" << LL_VERSION_MAJOR << "." - << LL_VERSION_MINOR << "." - << LL_VERSION_PATCH << "." - << LL_VIEWER_BUILD - << " (" << regionp->getName() << ")" - << "[" << category_name << "] " - << "\"" << childGetValue("summary_edit").asString() << "\""; - } - else - { - summary << "" - << " |" << regionp->getName() << "|" // region reporter is currently in. - << " (" << childGetText("abuse_location_edit") << ")" // region abuse occured in (freeform text - no LLRegionPicker tool) - << " [" << category_name << "] " // updated category - << " {" << childGetText("abuser_name_edit") << "} " // name of abuse entered in report (chosen using LLAvatarPicker) - << " \"" << childGetValue("summary_edit").asString() << "\""; // summary as entered - }; + + summary << "" + << " |" << regionp->getName() << "|" // region reporter is currently in. + << " (" << childGetText("abuse_location_edit") << ")" // region abuse occured in (freeform text - no LLRegionPicker tool) + << " [" << category_name << "] " // updated category + << " {" << childGetText("abuser_name_edit") << "} " // name of abuse entered in report (chosen using LLAvatarPicker) + << " \"" << childGetValue("summary_edit").asString() << "\""; // summary as entered + std::ostringstream details; - if (mReportType != BUG_REPORT) - { - details << "V" << LL_VERSION_MAJOR << "." // client version moved to body of email for abuse reports - << LL_VERSION_MINOR << "." - << LL_VERSION_PATCH << "." - << LL_VIEWER_BUILD << std::endl << std::endl; - } + + details << "V" << LL_VERSION_MAJOR << "." // client version moved to body of email for abuse reports + << LL_VERSION_MINOR << "." + << LL_VERSION_PATCH << "." + << LL_VIEWER_BUILD << std::endl << std::endl; + std::string object_name = childGetText("object_name"); std::string owner_name = childGetText("owner_name"); if (!object_name.empty() && !owner_name.empty()) @@ -737,11 +646,9 @@ LLSD LLFloaterReporter::gatherReport() details << "Owner: " << owner_name << "\n"; } - if ( mReportType != BUG_REPORT ) - { - details << "Abuser name: " << childGetText("abuser_name_edit") << " \n"; - details << "Abuser location: " << childGetText("abuse_location_edit") << " \n"; - }; + + details << "Abuser name: " << childGetText("abuser_name_edit") << " \n"; + details << "Abuser location: " << childGetText("abuse_location_edit") << " \n"; details << childGetValue("details_edit").asString(); @@ -761,17 +668,11 @@ LLSD LLFloaterReporter::gatherReport() LLUUID screenshot_id = LLUUID::null; if (childGetValue("screen_check")) { - if ( mReportType != BUG_REPORT ) - { - if ( gEmailToEstateOwner == FALSE ) - { - screenshot_id = childGetValue("screenshot"); - } - } - else + + if ( mEmailToEstateOwner == FALSE ) { screenshot_id = childGetValue("screenshot"); - }; + } }; LLSD report = LLSD::emptyMap(); @@ -883,7 +784,7 @@ void LLFloaterReporter::takeScreenshot() llwarns << "Unable to take screenshot" << llendl; return; } - LLPointer<LLImageJ2C> upload_data = LLViewerImageList::convertToUploadFile(raw); + LLPointer<LLImageJ2C> upload_data = LLViewerTextureList::convertToUploadFile(raw); // create a resource data mResourceDatap->mInventoryType = LLInventoryType::IT_NONE; @@ -891,12 +792,8 @@ void LLFloaterReporter::takeScreenshot() mResourceDatap->mExpectedUploadCost = 0; // we expect that abuse screenshots are free mResourceDatap->mAssetInfo.mTransactionID.generate(); mResourceDatap->mAssetInfo.mUuid = mResourceDatap->mAssetInfo.mTransactionID.makeAssetID(gAgent.getSecureSessionID()); - if (BUG_REPORT == mReportType) - { - mResourceDatap->mAssetInfo.mType = LLAssetType::AT_TEXTURE; - mResourceDatap->mPreferredLocation = LLAssetType::EType(-1); - } - else if (COMPLAINT_REPORT == mReportType) + + if (COMPLAINT_REPORT == mReportType) { mResourceDatap->mAssetInfo.mType = LLAssetType::AT_TEXTURE; mResourceDatap->mPreferredLocation = LLAssetType::EType(-2); @@ -917,17 +814,17 @@ void LLFloaterReporter::takeScreenshot() mResourceDatap->mAssetInfo.mType); // store in the image list so it doesn't try to fetch from the server - LLPointer<LLViewerImage> image_in_list = new LLViewerImage(mResourceDatap->mAssetInfo.mUuid, TRUE); + LLPointer<LLViewerFetchedTexture> image_in_list = + LLViewerTextureManager::getFetchedTexture(mResourceDatap->mAssetInfo.mUuid, TRUE, FALSE, LLViewerTexture::FETCHED_TEXTURE); image_in_list->createGLTexture(0, raw); - gImageList.addImage(image_in_list); - + // the texture picker then uses that texture LLTexturePicker* texture = getChild<LLTextureCtrl>("screenshot"); if (texture) { texture->setImageAssetID(mResourceDatap->mAssetInfo.mUuid); texture->setDefaultImageAssetID(mResourceDatap->mAssetInfo.mUuid); - texture->setCaption(std::string("Screenshot")); + texture->setCaption(getString("Screenshot")); } } @@ -967,11 +864,7 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, } EReportType report_type = UNKNOWN_REPORT; - if (data->mPreferredLocation == -1) - { - report_type = BUG_REPORT; - } - else if (data->mPreferredLocation == -2) + if (data->mPreferredLocation == -2) { report_type = COMPLAINT_REPORT; } @@ -980,13 +873,13 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, llwarns << "Unknown report type : " << data->mPreferredLocation << llendl; } - LLFloaterReporter *self = getReporter(report_type); + LLFloaterReporter *self = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter"); if (self) { self->mScreenID = uuid; llinfos << "Got screen shot " << uuid << llendl; self->sendReportViaLegacy(self->gatherReport()); - self->close(); + self->closeFloater(); } } @@ -1001,35 +894,35 @@ void LLFloaterReporter::setPosBox(const LLVector3d &pos) childSetText("pos_field", pos_string); } -void LLFloaterReporter::setDescription(const std::string& description, LLMeanCollisionData *mcd) -{ - LLFloaterReporter *self = gReporterInstances[COMPLAINT_REPORT]; - if (self) - { - self->childSetText("details_edit", description); - - for_each(self->mMCDList.begin(), self->mMCDList.end(), DeletePointer()); - self->mMCDList.clear(); - if (mcd) - { - self->mMCDList.push_back(new LLMeanCollisionData(mcd)); - } - } -} - -void LLFloaterReporter::addDescription(const std::string& description, LLMeanCollisionData *mcd) -{ - LLFloaterReporter *self = gReporterInstances[COMPLAINT_REPORT]; - if (self) - { - LLTextEditor* text = self->getChild<LLTextEditor>("details_edit"); - if (text) - { - text->insertText(description); - } - if (mcd) - { - self->mMCDList.push_back(new LLMeanCollisionData(mcd)); - } - } -} +// void LLFloaterReporter::setDescription(const std::string& description, LLMeanCollisionData *mcd) +// { +// LLFloaterReporter *self = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter"); +// if (self) +// { +// self->childSetText("details_edit", description); + +// for_each(self->mMCDList.begin(), self->mMCDList.end(), DeletePointer()); +// self->mMCDList.clear(); +// if (mcd) +// { +// self->mMCDList.push_back(new LLMeanCollisionData(mcd)); +// } +// } +// } + +// void LLFloaterReporter::addDescription(const std::string& description, LLMeanCollisionData *mcd) +// { +// LLFloaterReporter *self = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter"); +// if (self) +// { +// LLTextEditor* text = self->getChild<LLTextEditor>("details_edit"); +// if (text) +// { +// text->insertText(description); +// } +// if (mcd) +// { +// self->mMCDList.push_back(new LLMeanCollisionData(mcd)); +// } +// } +// } |