diff options
Diffstat (limited to 'linden/indra/newview/llfloaterreporter.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterreporter.cpp | 438 |
1 files changed, 268 insertions, 170 deletions
diff --git a/linden/indra/newview/llfloaterreporter.cpp b/linden/indra/newview/llfloaterreporter.cpp index 116b338..0337dd0 100644 --- a/linden/indra/newview/llfloaterreporter.cpp +++ b/linden/indra/newview/llfloaterreporter.cpp | |||
@@ -63,6 +63,7 @@ | |||
63 | #include "lltooldraganddrop.h" | 63 | #include "lltooldraganddrop.h" |
64 | #include "llfloatermap.h" | 64 | #include "llfloatermap.h" |
65 | #include "lluiconstants.h" | 65 | #include "lluiconstants.h" |
66 | #include "lluploaddialog.h" | ||
66 | #include "llcallingcard.h" | 67 | #include "llcallingcard.h" |
67 | #include "llviewerobjectlist.h" | 68 | #include "llviewerobjectlist.h" |
68 | #include "llagent.h" | 69 | #include "llagent.h" |
@@ -80,6 +81,7 @@ | |||
80 | #include "llvieweruictrlfactory.h" | 81 | #include "llvieweruictrlfactory.h" |
81 | #include "viewer.h" | 82 | #include "viewer.h" |
82 | 83 | ||
84 | #include "llassetuploadresponders.h" | ||
83 | 85 | ||
84 | const U32 INCLUDE_SCREENSHOT = 0x01 << 0; | 86 | const U32 INCLUDE_SCREENSHOT = 0x01 << 0; |
85 | 87 | ||
@@ -115,7 +117,8 @@ LLFloaterReporter::LLFloaterReporter( | |||
115 | mDeselectOnClose( FALSE ), | 117 | mDeselectOnClose( FALSE ), |
116 | mPicking( FALSE), | 118 | mPicking( FALSE), |
117 | mPosition(), | 119 | mPosition(), |
118 | mCopyrightWarningSeen( FALSE ) | 120 | mCopyrightWarningSeen( FALSE ), |
121 | mResourceDatap(new LLResourceData()) | ||
119 | { | 122 | { |
120 | if (report_type == BUG_REPORT) | 123 | if (report_type == BUG_REPORT) |
121 | { | 124 | { |
@@ -166,9 +169,9 @@ LLFloaterReporter::LLFloaterReporter( | |||
166 | 169 | ||
167 | gReporterInstances.addData(report_type, this); | 170 | gReporterInstances.addData(report_type, this); |
168 | 171 | ||
169 | // Upload a screenshot, but don't draw this floater. | 172 | // Take a screenshot, but don't draw this floater. |
170 | setVisible(FALSE); | 173 | setVisible(FALSE); |
171 | uploadScreenshot(); | 174 | takeScreenshot(); |
172 | setVisible(TRUE); | 175 | setVisible(TRUE); |
173 | 176 | ||
174 | // Default text to be blank | 177 | // Default text to be blank |
@@ -230,11 +233,7 @@ LLFloaterReporter::~LLFloaterReporter() | |||
230 | std::for_each(mMCDList.begin(), mMCDList.end(), DeletePointer() ); | 233 | std::for_each(mMCDList.begin(), mMCDList.end(), DeletePointer() ); |
231 | mMCDList.clear(); | 234 | mMCDList.clear(); |
232 | 235 | ||
233 | if (gSelectMgr) | 236 | delete mResourceDatap; |
234 | { | ||
235 | gSelectMgr->deselectTransient(); | ||
236 | } | ||
237 | |||
238 | gDialogVisible = FALSE; | 237 | gDialogVisible = FALSE; |
239 | } | 238 | } |
240 | 239 | ||
@@ -368,7 +367,7 @@ void LLFloaterReporter::callbackAvatarID(const std::vector<std::string>& names, | |||
368 | if ( self->mReportType != BUG_REPORT ) | 367 | if ( self->mReportType != BUG_REPORT ) |
369 | { | 368 | { |
370 | self->childSetText("abuser_name_edit", names[0] ); | 369 | self->childSetText("abuser_name_edit", names[0] ); |
371 | 370 | ||
372 | self->mAbuserID = ids[0]; | 371 | self->mAbuserID = ids[0]; |
373 | 372 | ||
374 | self->refresh(); | 373 | self->refresh(); |
@@ -379,31 +378,59 @@ void LLFloaterReporter::callbackAvatarID(const std::vector<std::string>& names, | |||
379 | void LLFloaterReporter::onClickSend(void *userdata) | 378 | void LLFloaterReporter::onClickSend(void *userdata) |
380 | { | 379 | { |
381 | LLFloaterReporter *self = (LLFloaterReporter *)userdata; | 380 | LLFloaterReporter *self = (LLFloaterReporter *)userdata; |
381 | |||
382 | if (self->mPicking) | ||
383 | { | ||
384 | closePickTool(self); | ||
385 | } | ||
382 | 386 | ||
383 | // only do this for abuse reports | 387 | if(self->validateReport()) |
384 | if ( self->mReportType != BUG_REPORT ) | ||
385 | { | 388 | { |
386 | if ( ! self->mCopyrightWarningSeen ) | 389 | // only show copyright alert for abuse reports |
390 | if ( self->mReportType != BUG_REPORT ) | ||
387 | { | 391 | { |
388 | LLString details_lc = self->childGetText("details_edit"); | 392 | if ( ! self->mCopyrightWarningSeen ) |
389 | LLString::toLower( details_lc ); | ||
390 | LLString summary_lc = self->childGetText("summary_edit"); | ||
391 | LLString::toLower( summary_lc ); | ||
392 | if ( details_lc.find( "copyright" ) != std::string::npos || | ||
393 | summary_lc.find( "copyright" ) != std::string::npos ) | ||
394 | { | 393 | { |
395 | gViewerWindow->alertXml("HelpReportAbuseContainsCopyright"); | 394 | LLString details_lc = self->childGetText("details_edit"); |
396 | self->mCopyrightWarningSeen = TRUE; | 395 | LLString::toLower( details_lc ); |
397 | return; | 396 | LLString summary_lc = self->childGetText("summary_edit"); |
397 | LLString::toLower( summary_lc ); | ||
398 | if ( details_lc.find( "copyright" ) != std::string::npos || | ||
399 | summary_lc.find( "copyright" ) != std::string::npos ) | ||
400 | { | ||
401 | gViewerWindow->alertXml("HelpReportAbuseContainsCopyright"); | ||
402 | self->mCopyrightWarningSeen = TRUE; | ||
403 | return; | ||
404 | }; | ||
398 | }; | 405 | }; |
399 | }; | 406 | }; |
400 | }; | ||
401 | 407 | ||
402 | if (self->mPicking) | 408 | LLUploadDialog::modalUploadDialog("Uploading...\n\nReport"); |
403 | { | 409 | // *TODO don't upload image if checkbox isn't checked |
404 | closePickTool(self); | 410 | std::string url = gAgent.getRegion()->getCapability("SendUserReport"); |
411 | std::string sshot_url = gAgent.getRegion()->getCapability("SendUserReportWithScreenshot"); | ||
412 | if(!url.empty() || !sshot_url.empty()) | ||
413 | { | ||
414 | self->sendReportViaCaps(url, sshot_url, self->gatherReport()); | ||
415 | self->close(); | ||
416 | } | ||
417 | else | ||
418 | { | ||
419 | if(self->childGetValue("screen_check")) | ||
420 | { | ||
421 | self->childDisable("send_btn"); | ||
422 | self->childDisable("cancel_btn"); | ||
423 | // the callback from uploading the image calls sendReportViaLegacy() | ||
424 | self->uploadImage(); | ||
425 | } | ||
426 | else | ||
427 | { | ||
428 | self->sendReportViaLegacy(self->gatherReport()); | ||
429 | LLUploadDialog::modalUploadFinished(); | ||
430 | self->close(); | ||
431 | } | ||
432 | } | ||
405 | } | 433 | } |
406 | self->sendReport(); | ||
407 | } | 434 | } |
408 | 435 | ||
409 | 436 | ||
@@ -459,7 +486,7 @@ void LLFloaterReporter::showFromMenu(EReportType report_type) | |||
459 | { | 486 | { |
460 | // ...bring that window to front | 487 | // ...bring that window to front |
461 | LLFloaterReporter *f = gReporterInstances.getData(report_type); | 488 | LLFloaterReporter *f = gReporterInstances.getData(report_type); |
462 | f->open(); | 489 | f->open(); /* Flawfinder: ignore */ |
463 | } | 490 | } |
464 | else | 491 | else |
465 | { | 492 | { |
@@ -515,7 +542,7 @@ void LLFloaterReporter::showFromObject(const LLUUID& object_id) | |||
515 | // Need to deselect on close | 542 | // Need to deselect on close |
516 | f->mDeselectOnClose = TRUE; | 543 | f->mDeselectOnClose = TRUE; |
517 | 544 | ||
518 | f->open(); | 545 | f->open(); /* Flawfinder: ignore */ |
519 | } | 546 | } |
520 | 547 | ||
521 | 548 | ||
@@ -556,10 +583,9 @@ void LLFloaterReporter::setPickedObjectProperties(const char *object_name, const | |||
556 | childSetText("owner_name", owner_name); | 583 | childSetText("owner_name", owner_name); |
557 | } | 584 | } |
558 | 585 | ||
559 | void LLFloaterReporter::sendReport() | 586 | |
587 | bool LLFloaterReporter::validateReport() | ||
560 | { | 588 | { |
561 | LLViewerRegion *regionp = gAgent.getRegion(); | ||
562 | if (!regionp) return; | ||
563 | // Ensure user selected a category from the list | 589 | // Ensure user selected a category from the list |
564 | LLSD category_sd = childGetValue("category_combo"); | 590 | LLSD category_sd = childGetValue("category_combo"); |
565 | U8 category = (U8)category_sd.asInteger(); | 591 | U8 category = (U8)category_sd.asInteger(); |
@@ -573,7 +599,7 @@ void LLFloaterReporter::sendReport() | |||
573 | { | 599 | { |
574 | gViewerWindow->alertXml("HelpReportBugSelectCategory"); | 600 | gViewerWindow->alertXml("HelpReportBugSelectCategory"); |
575 | } | 601 | } |
576 | return; | 602 | return false; |
577 | } | 603 | } |
578 | 604 | ||
579 | if ( mReportType != BUG_REPORT ) | 605 | if ( mReportType != BUG_REPORT ) |
@@ -581,13 +607,13 @@ void LLFloaterReporter::sendReport() | |||
581 | if ( childGetText("abuser_name_edit").empty() ) | 607 | if ( childGetText("abuser_name_edit").empty() ) |
582 | { | 608 | { |
583 | gViewerWindow->alertXml("HelpReportAbuseAbuserNameEmpty"); | 609 | gViewerWindow->alertXml("HelpReportAbuseAbuserNameEmpty"); |
584 | return; | 610 | return false; |
585 | }; | 611 | }; |
586 | 612 | ||
587 | if ( childGetText("abuse_location_edit").empty() ) | 613 | if ( childGetText("abuse_location_edit").empty() ) |
588 | { | 614 | { |
589 | gViewerWindow->alertXml("HelpReportAbuseAbuserLocationEmpty"); | 615 | gViewerWindow->alertXml("HelpReportAbuseAbuserLocationEmpty"); |
590 | return; | 616 | return false; |
591 | }; | 617 | }; |
592 | }; | 618 | }; |
593 | 619 | ||
@@ -601,7 +627,7 @@ void LLFloaterReporter::sendReport() | |||
601 | { | 627 | { |
602 | gViewerWindow->alertXml("HelpReportBugSummaryEmpty"); | 628 | gViewerWindow->alertXml("HelpReportBugSummaryEmpty"); |
603 | } | 629 | } |
604 | return; | 630 | return false; |
605 | }; | 631 | }; |
606 | 632 | ||
607 | if ( childGetText("details_edit") == mDefaultSummary ) | 633 | if ( childGetText("details_edit") == mDefaultSummary ) |
@@ -614,53 +640,19 @@ void LLFloaterReporter::sendReport() | |||
614 | { | 640 | { |
615 | gViewerWindow->alertXml("HelpReportBugDetailsEmpty"); | 641 | gViewerWindow->alertXml("HelpReportBugDetailsEmpty"); |
616 | } | 642 | } |
617 | return; | 643 | return false; |
618 | }; | 644 | }; |
645 | return true; | ||
646 | } | ||
647 | |||
648 | LLSD LLFloaterReporter::gatherReport() | ||
649 | { | ||
650 | LLViewerRegion *regionp = gAgent.getRegion(); | ||
651 | if (!regionp) return LLSD(); // *TODO handle this failure case more gracefully | ||
619 | 652 | ||
620 | // reset flag in case the next report also contains this text | 653 | // reset flag in case the next report also contains this text |
621 | mCopyrightWarningSeen = FALSE; | 654 | mCopyrightWarningSeen = FALSE; |
622 | 655 | ||
623 | U32 check_flags = 0; | ||
624 | if (childGetValue("screen_check")) | ||
625 | { | ||
626 | check_flags |= INCLUDE_SCREENSHOT; | ||
627 | } | ||
628 | |||
629 | LLMessageSystem *msg = gMessageSystem; | ||
630 | msg->newMessageFast(_PREHASH_UserReport); | ||
631 | msg->nextBlockFast(_PREHASH_AgentData); | ||
632 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
633 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
634 | msg->nextBlockFast(_PREHASH_ReportData); | ||
635 | msg->addU8Fast(_PREHASH_ReportType, (U8) mReportType); | ||
636 | msg->addU8(_PREHASH_Category, category); | ||
637 | msg->addVector3Fast(_PREHASH_Position, mPosition); | ||
638 | msg->addU8Fast(_PREHASH_CheckFlags, (U8) check_flags); | ||
639 | |||
640 | // only send a screenshot ID if we're asked too and the email is | ||
641 | // going to LL - Estate Owners cannot see the screenshot asset | ||
642 | LLSD screenshot_id = LLUUID::null; | ||
643 | if (childGetValue("screen_check")) | ||
644 | { | ||
645 | if ( mReportType != BUG_REPORT ) | ||
646 | { | ||
647 | if ( gEmailToEstateOwner == FALSE ) | ||
648 | { | ||
649 | screenshot_id = childGetValue("screenshot"); | ||
650 | } | ||
651 | } | ||
652 | else | ||
653 | { | ||
654 | screenshot_id = childGetValue("screenshot"); | ||
655 | }; | ||
656 | }; | ||
657 | msg->addUUIDFast(_PREHASH_ScreenshotID, screenshot_id); | ||
658 | msg->addUUIDFast(_PREHASH_ObjectID, mObjectID); | ||
659 | |||
660 | msg->addUUID("AbuserID", mAbuserID ); | ||
661 | msg->addString("AbuseRegionName", ""); | ||
662 | msg->addUUID("AbuseRegionID", LLUUID::null); | ||
663 | |||
664 | std::ostringstream summary; | 656 | std::ostringstream summary; |
665 | if (!gInProductionGrid) | 657 | if (!gInProductionGrid) |
666 | { | 658 | { |
@@ -708,7 +700,6 @@ void LLFloaterReporter::sendReport() | |||
708 | << " {" << childGetText("abuser_name_edit") << "} " // name of abuse entered in report (chosen using LLAvatarPicker) | 700 | << " {" << childGetText("abuser_name_edit") << "} " // name of abuse entered in report (chosen using LLAvatarPicker) |
709 | << " \"" << childGetValue("summary_edit").asString() << "\""; // summary as entered | 701 | << " \"" << childGetValue("summary_edit").asString() << "\""; // summary as entered |
710 | }; | 702 | }; |
711 | msg->addStringFast(_PREHASH_Summary, summary.str().c_str()); | ||
712 | 703 | ||
713 | std::ostringstream details; | 704 | std::ostringstream details; |
714 | if (mReportType != BUG_REPORT) | 705 | if (mReportType != BUG_REPORT) |
@@ -733,10 +724,10 @@ void LLFloaterReporter::sendReport() | |||
733 | }; | 724 | }; |
734 | 725 | ||
735 | details << childGetValue("details_edit").asString(); | 726 | details << childGetValue("details_edit").asString(); |
736 | msg->addStringFast(_PREHASH_Details, details.str() ); | ||
737 | 727 | ||
738 | char version_string[MAX_STRING]; | 728 | char version_string[MAX_STRING]; /* Flawfinder: ignore */ |
739 | sprintf(version_string, | 729 | snprintf(version_string, /* Flawfinder: ignore */ |
730 | MAX_STRING, | ||
740 | "%d.%d.%d %s %s %s %s", | 731 | "%d.%d.%d %s %s %s %s", |
741 | LL_VERSION_MAJOR, | 732 | LL_VERSION_MAJOR, |
742 | LL_VERSION_MINOR, | 733 | LL_VERSION_MINOR, |
@@ -745,120 +736,204 @@ void LLFloaterReporter::sendReport() | |||
745 | gSysCPU.getFamily().c_str(), | 736 | gSysCPU.getFamily().c_str(), |
746 | gGLManager.mGLRenderer.c_str(), | 737 | gGLManager.mGLRenderer.c_str(), |
747 | gGLManager.mDriverVersionVendorString.c_str()); | 738 | gGLManager.mDriverVersionVendorString.c_str()); |
748 | msg->addString("VersionString", version_string); | ||
749 | 739 | ||
750 | msg->sendReliable(regionp->getHost()); | 740 | // only send a screenshot ID if we're asked to and the email is |
741 | // going to LL - Estate Owners cannot see the screenshot asset | ||
742 | LLUUID screenshot_id = LLUUID::null; | ||
743 | if (childGetValue("screen_check")) | ||
744 | { | ||
745 | if ( mReportType != BUG_REPORT ) | ||
746 | { | ||
747 | if ( gEmailToEstateOwner == FALSE ) | ||
748 | { | ||
749 | screenshot_id = childGetValue("screenshot"); | ||
750 | } | ||
751 | } | ||
752 | else | ||
753 | { | ||
754 | screenshot_id = childGetValue("screenshot"); | ||
755 | }; | ||
756 | }; | ||
757 | |||
758 | LLSD report = LLSD::emptyMap(); | ||
759 | report["report-type"] = (U8) mReportType; | ||
760 | report["category"] = childGetValue("category_combo"); | ||
761 | report["position"] = mPosition.getValue(); | ||
762 | report["check-flags"] = (U8)0; // this is not used | ||
763 | report["screenshot-id"] = screenshot_id; | ||
764 | report["object-id"] = mObjectID; | ||
765 | report["abuser-id"] = mAbuserID; | ||
766 | report["abuse-region-name"] = ""; | ||
767 | report["abuse-region-id"] = LLUUID::null; | ||
768 | report["summary"] = summary.str(); | ||
769 | report["version-string"] = version_string; | ||
770 | report["details"] = details.str(); | ||
771 | return report; | ||
772 | } | ||
751 | 773 | ||
752 | close(); | 774 | void LLFloaterReporter::sendReportViaLegacy(const LLSD & report) |
775 | { | ||
776 | LLViewerRegion *regionp = gAgent.getRegion(); | ||
777 | if (!regionp) return; | ||
778 | LLMessageSystem *msg = gMessageSystem; | ||
779 | msg->newMessageFast(_PREHASH_UserReport); | ||
780 | msg->nextBlockFast(_PREHASH_AgentData); | ||
781 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
782 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
783 | |||
784 | msg->nextBlockFast(_PREHASH_ReportData); | ||
785 | msg->addU8Fast(_PREHASH_ReportType, report["report-type"].asInteger()); | ||
786 | msg->addU8(_PREHASH_Category, report["category"].asInteger()); | ||
787 | msg->addVector3Fast(_PREHASH_Position, LLVector3(report["position"])); | ||
788 | msg->addU8Fast(_PREHASH_CheckFlags, report["check-flags"].asInteger()); | ||
789 | msg->addUUIDFast(_PREHASH_ScreenshotID, report["screenshot-id"].asUUID()); | ||
790 | msg->addUUIDFast(_PREHASH_ObjectID, report["object-id"].asUUID()); | ||
791 | msg->addUUID("AbuserID", report["abuser-id"].asUUID()); | ||
792 | msg->addString("AbuseRegionName", report["abuse-region-name"].asString()); | ||
793 | msg->addUUID("AbuseRegionID", report["abuse-region-id"].asUUID()); | ||
794 | |||
795 | msg->addStringFast(_PREHASH_Summary, report["summary"].asString().c_str()); | ||
796 | msg->addString("VersionString", report["version-string"]); | ||
797 | msg->addStringFast(_PREHASH_Details, report["details"] ); | ||
798 | |||
799 | msg->sendReliable(regionp->getHost()); | ||
753 | } | 800 | } |
754 | 801 | ||
802 | class LLUserReportScreenshotResponder : public LLAssetUploadResponder | ||
803 | { | ||
804 | public: | ||
805 | LLUserReportScreenshotResponder(const LLSD & post_data, | ||
806 | const LLUUID & vfile_id, | ||
807 | LLAssetType::EType asset_type): | ||
808 | LLAssetUploadResponder(post_data, vfile_id, asset_type) | ||
809 | { | ||
810 | } | ||
811 | void uploadFailed(const LLSD& content) | ||
812 | { | ||
813 | // *TODO pop up a dialog so the user knows their report screenshot didn't make it | ||
814 | LLUploadDialog::modalUploadFinished(); | ||
815 | } | ||
816 | void uploadComplete(const LLSD& content) | ||
817 | { | ||
818 | // we don't care about what the server returns from this post, just clean up the UI | ||
819 | LLUploadDialog::modalUploadFinished(); | ||
820 | } | ||
821 | }; | ||
822 | |||
823 | class LLUserReportResponder : public LLHTTPClient::Responder | ||
824 | { | ||
825 | public: | ||
826 | LLUserReportResponder(): LLHTTPClient::Responder() {} | ||
827 | |||
828 | void error(U32 status, const std::string& reason) | ||
829 | { | ||
830 | // *TODO do some user messaging here | ||
831 | LLUploadDialog::modalUploadFinished(); | ||
832 | } | ||
833 | void result(const LLSD& content) | ||
834 | { | ||
835 | // we don't care about what the server returns | ||
836 | LLUploadDialog::modalUploadFinished(); | ||
837 | } | ||
838 | }; | ||
839 | |||
840 | void LLFloaterReporter::sendReportViaCaps(std::string url, std::string sshot_url, const LLSD& report) | ||
841 | { | ||
842 | if(childGetValue("screen_check").asBoolean() && !sshot_url.empty()) | ||
843 | { | ||
844 | // try to upload screenshot | ||
845 | LLHTTPClient::post(sshot_url, report, new LLUserReportScreenshotResponder(report, | ||
846 | mResourceDatap->mAssetInfo.mUuid, | ||
847 | mResourceDatap->mAssetInfo.mType)); | ||
848 | } | ||
849 | else | ||
850 | { | ||
851 | // screenshot not wanted or we don't have screenshot cap | ||
852 | LLHTTPClient::post(url, report, new LLUserReportResponder()); | ||
853 | } | ||
854 | } | ||
755 | 855 | ||
756 | void LLFloaterReporter::uploadScreenshot() | 856 | void LLFloaterReporter::takeScreenshot() |
757 | { | 857 | { |
758 | const S32 IMAGE_WIDTH = 1024; | 858 | const S32 IMAGE_WIDTH = 1024; |
759 | const S32 IMAGE_HEIGHT = 768; | 859 | const S32 IMAGE_HEIGHT = 768; |
760 | LLString filename("report_screenshot.bmp"); | ||
761 | 860 | ||
762 | if( !gViewerWindow->saveSnapshot( filename, IMAGE_WIDTH, IMAGE_HEIGHT, TRUE, FALSE ) ) | 861 | LLPointer<LLImageRaw> raw = new LLImageRaw; |
862 | if( !gViewerWindow->rawSnapshot(raw, IMAGE_WIDTH, IMAGE_HEIGHT, TRUE, TRUE, FALSE)) | ||
763 | { | 863 | { |
864 | llwarns << "Unable to take screenshot" << llendl; | ||
764 | return; | 865 | return; |
765 | } | 866 | } |
867 | LLPointer<LLImageJ2C> upload_data = LLViewerImageList::convertToUploadFile(raw); | ||
766 | 868 | ||
767 | // Generate the temporary filename | 869 | // create a resource data |
768 | std::string temp_filename = gDirUtilp->getTempFilename(); | 870 | mResourceDatap->mInventoryType = LLInventoryType::IT_NONE; |
769 | 871 | mResourceDatap->mAssetInfo.mTransactionID.generate(); | |
770 | // try to create the upload file | 872 | mResourceDatap->mAssetInfo.mUuid = mResourceDatap->mAssetInfo.mTransactionID.makeAssetID(gAgent.getSecureSessionID()); |
771 | if (!LLViewerImageList::createUploadFile(filename, | 873 | if (BUG_REPORT == mReportType) |
772 | temp_filename, | ||
773 | IMG_CODEC_BMP )) | ||
774 | { | 874 | { |
775 | llwarns << "Unable to upload report screenshot " << filename << ":\n\n" << LLImageBase::getLastError() << "\n" << llendl; | 875 | mResourceDatap->mAssetInfo.mType = LLAssetType::AT_TEXTURE; |
776 | if(LLFile::remove(temp_filename.c_str()) == -1) | 876 | mResourceDatap->mPreferredLocation = LLAssetType::EType(-1); |
777 | { | 877 | } |
778 | lldebugs << "unable to remove temp file" << llendl; | 878 | else if (COMPLAINT_REPORT == mReportType) |
779 | } | 879 | { |
780 | LLFilePicker::instance().reset(); | 880 | mResourceDatap->mAssetInfo.mType = LLAssetType::AT_TEXTURE; |
881 | mResourceDatap->mPreferredLocation = LLAssetType::EType(-2); | ||
781 | } | 882 | } |
782 | else | 883 | else |
783 | { | 884 | { |
784 | // create a resource data | 885 | llwarns << "Unknown LLFloaterReporter type" << llendl; |
785 | LLResourceData* data = NULL; | 886 | } |
786 | data = new LLResourceData; | 887 | mResourceDatap->mAssetInfo.mCreatorID = gAgentID; |
787 | data->mInventoryType = LLInventoryType::IT_NONE; | 888 | mResourceDatap->mAssetInfo.setName("screenshot_name"); |
788 | data->mAssetInfo.mTransactionID.generate(); | 889 | mResourceDatap->mAssetInfo.setDescription("screenshot_descr"); |
789 | data->mAssetInfo.mUuid = data->mAssetInfo.mTransactionID.makeAssetID(gAgent.getSecureSessionID()); | 890 | |
790 | if (BUG_REPORT == mReportType) | 891 | // store in VFS |
791 | { | 892 | LLVFile::writeFile(upload_data->getData(), |
792 | //data->mAssetInfo.mType = LLAssetType::AT_BUG_REPORT_SCREENSHOT; | 893 | upload_data->getDataSize(), |
793 | data->mAssetInfo.mType = LLAssetType::AT_TEXTURE; | 894 | gVFS, |
794 | data->mPreferredLocation = LLAssetType::EType(-1); | 895 | mResourceDatap->mAssetInfo.mUuid, |
795 | } | 896 | mResourceDatap->mAssetInfo.mType); |
796 | else if (COMPLAINT_REPORT == mReportType) | 897 | |
797 | { | 898 | // store in the image list so it doesn't try to fetch from the server |
798 | //data->mAssetInfo.mType = LLAssetType::AT_COMPLAINT_REPORT_SCREENSHOT; | 899 | LLViewerImage* image_in_list = new LLViewerImage(mResourceDatap->mAssetInfo.mUuid, TRUE); |
799 | data->mAssetInfo.mType = LLAssetType::AT_TEXTURE; | 900 | image_in_list->createGLTexture(0, raw); |
800 | data->mPreferredLocation = LLAssetType::EType(-2); | 901 | gImageList.addImage(image_in_list); |
801 | } | 902 | |
802 | else | 903 | // the texture picker then uses that texture |
803 | { | 904 | LLTexturePicker* texture = LLUICtrlFactory::getTexturePickerByName(this, "screenshot"); |
804 | llwarns << "Unknown LLFloaterReporter type" << llendl; | 905 | if (texture) |
805 | } | 906 | { |
806 | data->mAssetInfo.mCreatorID = gAgentID; | 907 | texture->setImageAssetID(mResourceDatap->mAssetInfo.mUuid); |
807 | data->mAssetInfo.setName("screenshot_name"); | 908 | texture->setDefaultImageAssetID(mResourceDatap->mAssetInfo.mUuid); |
808 | data->mAssetInfo.setDescription("screenshot_descr"); | 909 | texture->setCaption("Screenshot"); |
809 | |||
810 | llinfos << "*** Uploading: " << llendl; | ||
811 | llinfos << "Type: " << LLAssetType::lookup(data->mAssetInfo.mType) << llendl; | ||
812 | llinfos << "File: " << filename << llendl; | ||
813 | llinfos << "Dest: " << temp_filename << llendl; | ||
814 | llinfos << "Name: " << data->mAssetInfo.getName() << llendl; | ||
815 | llinfos << "Desc: " << data->mAssetInfo.getDescription() << llendl; | ||
816 | |||
817 | gAssetStorage->storeAssetData(temp_filename.c_str(), | ||
818 | data->mAssetInfo.mTransactionID, | ||
819 | data->mAssetInfo.mType, | ||
820 | LLFloaterReporter::uploadDoneCallback, | ||
821 | (void*)data, TRUE); | ||
822 | } | 910 | } |
911 | |||
912 | } | ||
913 | |||
914 | void LLFloaterReporter::uploadImage() | ||
915 | { | ||
916 | llinfos << "*** Uploading: " << llendl; | ||
917 | llinfos << "Type: " << LLAssetType::lookup(mResourceDatap->mAssetInfo.mType) << llendl; | ||
918 | llinfos << "UUID: " << mResourceDatap->mAssetInfo.mUuid << llendl; | ||
919 | llinfos << "Name: " << mResourceDatap->mAssetInfo.getName() << llendl; | ||
920 | llinfos << "Desc: " << mResourceDatap->mAssetInfo.getDescription() << llendl; | ||
921 | |||
922 | gAssetStorage->storeAssetData(mResourceDatap->mAssetInfo.mTransactionID, | ||
923 | mResourceDatap->mAssetInfo.mType, | ||
924 | LLFloaterReporter::uploadDoneCallback, | ||
925 | (void*)mResourceDatap, TRUE); | ||
823 | } | 926 | } |
824 | 927 | ||
825 | 928 | ||
826 | // static | 929 | // static |
827 | void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, S32 result) // StoreAssetData callback (fixed) | 930 | void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, S32 result) // StoreAssetData callback (fixed) |
828 | { | 931 | { |
829 | LLResourceData* data = (LLResourceData*)user_data; | 932 | LLUploadDialog::modalUploadFinished(); |
830 | 933 | ||
831 | if(result >= 0) | 934 | LLResourceData* data = (LLResourceData*)user_data; |
832 | { | ||
833 | EReportType report_type = UNKNOWN_REPORT; | ||
834 | if (data->mPreferredLocation == -1) | ||
835 | { | ||
836 | report_type = BUG_REPORT; | ||
837 | } | ||
838 | else if (data->mPreferredLocation == -2) | ||
839 | { | ||
840 | report_type = COMPLAINT_REPORT; | ||
841 | } | ||
842 | else | ||
843 | { | ||
844 | llwarns << "Unknown report type : " << data->mPreferredLocation << llendl; | ||
845 | } | ||
846 | 935 | ||
847 | LLFloaterReporter *self = getReporter(report_type); | 936 | if(result < 0) |
848 | if (self) | ||
849 | { | ||
850 | LLTexturePicker* texture = LLUICtrlFactory::getTexturePickerByName(self, "screenshot"); | ||
851 | if (texture) | ||
852 | { | ||
853 | texture->setImageAssetID(uuid); | ||
854 | texture->setDefaultImageAssetID(uuid); | ||
855 | texture->setCaption("Screenshot"); | ||
856 | } | ||
857 | self->mScreenID = uuid; | ||
858 | llinfos << "Got screen shot " << uuid << llendl; | ||
859 | } | ||
860 | } | ||
861 | else // if(result >= 0) | ||
862 | { | 937 | { |
863 | LLStringBase<char>::format_map_t args; | 938 | LLStringBase<char>::format_map_t args; |
864 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); | 939 | args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); |
@@ -867,8 +942,31 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, | |||
867 | std::string err_msg("There was a problem uploading a report screenshot"); | 942 | std::string err_msg("There was a problem uploading a report screenshot"); |
868 | err_msg += " due to the following reason: " + args["[REASON]"]; | 943 | err_msg += " due to the following reason: " + args["[REASON]"]; |
869 | llwarns << err_msg << llendl; | 944 | llwarns << err_msg << llendl; |
945 | return; | ||
946 | } | ||
947 | |||
948 | EReportType report_type = UNKNOWN_REPORT; | ||
949 | if (data->mPreferredLocation == -1) | ||
950 | { | ||
951 | report_type = BUG_REPORT; | ||
870 | } | 952 | } |
871 | delete data; | 953 | else if (data->mPreferredLocation == -2) |
954 | { | ||
955 | report_type = COMPLAINT_REPORT; | ||
956 | } | ||
957 | else | ||
958 | { | ||
959 | llwarns << "Unknown report type : " << data->mPreferredLocation << llendl; | ||
960 | } | ||
961 | |||
962 | LLFloaterReporter *self = getReporter(report_type); | ||
963 | if (self) | ||
964 | { | ||
965 | self->mScreenID = uuid; | ||
966 | llinfos << "Got screen shot " << uuid << llendl; | ||
967 | self->sendReportViaLegacy(self->gatherReport()); | ||
968 | } | ||
969 | self->close(); | ||
872 | } | 970 | } |
873 | 971 | ||
874 | 972 | ||