llfloaterreporter.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. /**
  2. * @file llfloaterreporter.cpp
  3. * @brief Bug and abuse reports.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include <sstream>
  34. #include "llfloaterreporter.h"
  35. #include "llassetstorage.h"
  36. #include "llbutton.h"
  37. #include "llcachename.h"
  38. #include "llcombobox.h"
  39. #include "llexperiencecache.h"
  40. #include "llfilesystem.h"
  41. #include "llimagej2c.h"
  42. #include "llinventory.h"
  43. #include "lllineeditor.h"
  44. #include "llsys.h"
  45. #include "lltexteditor.h"
  46. #include "lltransfermanager.h"
  47. #include "lluictrlfactory.h"
  48. #include "lluploaddialog.h"
  49. #include "llversionviewer.h"
  50. #include "llmessage.h"
  51. #include "llagent.h"
  52. #include "llfloateravatarpicker.h"
  53. #include "llgridmanager.h"
  54. //MK
  55. #include "mkrlinterface.h"
  56. //mk
  57. #include "llselectmgr.h"
  58. #include "lltexturectrl.h"
  59. #include "lltoolmgr.h"
  60. #include "lltoolobjpicker.h"
  61. #include "llviewerassetupload.h"
  62. #include "llviewercontrol.h"
  63. #include "llviewerobjectlist.h"
  64. #include "llviewerregion.h"
  65. #include "llviewertexturelist.h"
  66. #include "llviewerwindow.h"
  67. // Specialized upload ressource info
  68. class LLARScreenShotUploader final : public LLResourceUploadInfo
  69. {
  70. public:
  71. LLARScreenShotUploader(const LLSD& report, const LLUUID& asset_id,
  72. LLAssetType::EType type)
  73. : LLResourceUploadInfo(asset_id, type, "Abuse Report"),
  74. mReport(report)
  75. {
  76. }
  77. LLSD prepareUpload() override
  78. {
  79. return LLSD().with("success", LLSD::Boolean(true));
  80. }
  81. LLSD generatePostBody() override { return mReport; }
  82. S32 getExpectedUploadCost() override { return 0; }
  83. LLUUID finishUpload(const LLSD&) override { return LLUUID::null; }
  84. bool showInventoryPanel() const { return false; }
  85. std::string getDisplayName() const override { return "Abuse Report"; }
  86. private:
  87. LLSD mReport;
  88. };
  89. LLFloaterReporter::LLFloaterReporter(const LLSD&)
  90. : mPicking(false),
  91. mCopyrightWarningSeen(false),
  92. mResourceDatap(new LLResourceData())
  93. {
  94. LLUICtrlFactory::getInstance()->buildFloater(this,
  95. "floater_report_abuse.xml");
  96. }
  97. //virtual
  98. LLFloaterReporter::~LLFloaterReporter()
  99. {
  100. // Child views automatically deleted
  101. mObjectID.setNull();
  102. if (mPicking)
  103. {
  104. closePickTool(this);
  105. }
  106. mPosition.set(0.0f, 0.0f, 0.0f);
  107. delete mResourceDatap;
  108. }
  109. //virtual
  110. bool LLFloaterReporter::postBuild()
  111. {
  112. childSetText("abuse_location_edit", gAgent.getSLURL());
  113. LLButton* pick_btn = getChild<LLButton>("pick_btn");
  114. pick_btn->setImages("UIImgFaceUUID", "UIImgFaceSelectedUUID");
  115. pick_btn->setClickedCallback(onClickObjPicker, this);
  116. // Abuser name is selected from a list
  117. LLLineEditor* le = getChild<LLLineEditor>("abuser_name_edit");
  118. le->setEnabled(false);
  119. childSetAction("select_abuser", onClickSelectAbuser, this);
  120. childSetAction("send_btn", onClickSend, this);
  121. childSetAction("cancel_btn", onClickCancel, this);
  122. // Convert the position to a string
  123. LLVector3d pos = gAgent.getPositionGlobal();
  124. LLViewerRegion* regionp = gAgent.getRegion();
  125. if (regionp)
  126. {
  127. pos -= regionp->getOriginGlobal();
  128. }
  129. setPosBox(pos);
  130. // Take a screenshot, but do not draw this floater.
  131. setVisible(false);
  132. takeScreenshot();
  133. setVisible(true);
  134. // Default text to be blank
  135. childSetText("object_name", LLStringUtil::null);
  136. childSetText("owner_name", LLStringUtil::null);
  137. mOwnerName = LLStringUtil::null;
  138. childSetFocus("summary_edit");
  139. mDefaultSummary = childGetText("details_edit");
  140. mCategoryCombo = getChild<LLComboBox>("category_combo");
  141. std::string cap_url = gAgent.getRegionCapability("AbuseCategories");
  142. if (!cap_url.empty())
  143. {
  144. std::string lang = gSavedSettings.getString("Language");
  145. if (!lang.empty())
  146. {
  147. cap_url += "?lc=" + lang;
  148. }
  149. gCoros.launch("requestAbuseCategoriesCoro",
  150. boost::bind(&LLFloaterReporter::requestAbuseCategoriesCoro,
  151. cap_url));
  152. }
  153. center();
  154. return true;
  155. }
  156. //static
  157. void LLFloaterReporter::requestAbuseCategoriesCoro(const std::string& url)
  158. {
  159. LLCoreHttpUtil::HttpCoroutineAdapter adapter("requestAbuseCategoriesCoro");
  160. LLSD result = adapter.getAndSuspend(url);
  161. LLFloaterReporter* self = findInstance();
  162. if (!self)
  163. {
  164. return; // Floater has since been closed !
  165. }
  166. LLCore::HttpStatus status =
  167. LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(result);
  168. if (!status || !result.has("categories"))
  169. {
  170. llwarns << "Error requesting abuse categories from capability. Error: "
  171. << status.toString() << llendl;
  172. return;
  173. }
  174. const LLSD& contents = result["categories"];
  175. if (!contents.size())
  176. {
  177. llwarns << "No contents received for abuse categories" << llendl;
  178. return;
  179. }
  180. llinfos << "Populating abuse report categories combo from server data"
  181. << llendl;
  182. LLComboBox* combo = self->mCategoryCombo;
  183. // Remember selection
  184. S32 selection = combo->getCurrentIndex();
  185. // Get the first item ("Select a category" entry) label and value
  186. combo->selectFirstItem();
  187. std::string label = combo->getSelectedItemLabel();
  188. LLSD value = combo->getSelectedValue();
  189. // Clear the whole combo
  190. combo->removeall();
  191. // Re-add the first entry
  192. combo->add(label, value);
  193. // Add the recceived categories
  194. for (LLSD::array_const_iterator it = contents.beginArray(),
  195. end = contents.endArray();
  196. it != end; ++it)
  197. {
  198. const LLSD& message_data = *it;
  199. label = message_data["description_localized"].asString();
  200. combo->add(label, message_data["category"]);
  201. }
  202. // Restore selection
  203. combo->selectNthItem(selection);
  204. }
  205. void LLFloaterReporter::getObjectInfo(const LLUUID& object_id)
  206. {
  207. // *TODO:
  208. // 1.- need to send to correct simulator if object is not in same simulator
  209. // as agent
  210. // 2.- display info in widget window that gives feedback that we have
  211. // recorded the object info
  212. // 3.- can pick avatar ==> might want to indicate when a picked object is
  213. // an avatar, attachment, or other category
  214. mObjectID = object_id;
  215. if (mObjectID.notNull())
  216. {
  217. // Get object info for the user's benefit
  218. LLViewerObject* objectp = gObjectList.findObject(mObjectID);
  219. if (objectp)
  220. {
  221. // Use the root object (for attachments, it will also pick the
  222. // avatar wearing it, which is what we want). This is important,
  223. // since passing a child object info request to the simulator would
  224. // fail to get a reply sent back to the reporter (server bug ?...
  225. // COMPLAINT_REPORT_REQUEST flag lost ?).
  226. objectp = (LLViewerObject*)objectp->getRoot();
  227. mObjectID = objectp->getID();
  228. // Correct the region and position information
  229. LLViewerRegion* regionp = objectp->getRegion();
  230. if (regionp)
  231. {
  232. childSetText("sim_field", regionp->getName());
  233. LLVector3d global_pos;
  234. global_pos.set(objectp->getPositionRegion());
  235. setPosBox(global_pos);
  236. }
  237. if (objectp->isAvatar())
  238. {
  239. setFromAvatarID(mObjectID);
  240. }
  241. else if (regionp)
  242. {
  243. // We have to query the simulator for information about this
  244. // object
  245. LLSelectMgr::registerObjectPropertiesFamilyRequest(mObjectID);
  246. LLMessageSystem* msg = gMessageSystemp;
  247. msg->newMessageFast(_PREHASH_RequestObjectPropertiesFamily);
  248. msg->nextBlockFast(_PREHASH_AgentData);
  249. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  250. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  251. msg->nextBlockFast(_PREHASH_ObjectData);
  252. msg->addU32Fast(_PREHASH_RequestFlags,
  253. COMPLAINT_REPORT_REQUEST);
  254. msg->addUUIDFast(_PREHASH_ObjectID, mObjectID);
  255. msg->sendReliable(regionp->getHost());
  256. }
  257. else
  258. {
  259. llwarns << "NULL region pointer for object: " << mObjectID
  260. << ". Cannot request info..." << llendl;
  261. }
  262. }
  263. }
  264. }
  265. void LLFloaterReporter::getExperienceInfo(const LLUUID& experience_id)
  266. {
  267. mExperienceID = experience_id;
  268. if (mExperienceID.notNull())
  269. {
  270. std::stringstream desc;
  271. const LLSD& experience =
  272. LLExperienceCache::getInstance()->get(mExperienceID);
  273. if (experience.isDefined())
  274. {
  275. setFromAvatarID(experience[LLExperienceCache::AGENT_ID]);
  276. desc << "Experience id: " << mExperienceID;
  277. }
  278. else
  279. {
  280. desc << "Unable to retrieve details for id: "<< mExperienceID;
  281. }
  282. childSetText("details_edit", desc.str());
  283. }
  284. }
  285. //static
  286. void LLFloaterReporter::onClickSelectAbuser(void* userdata)
  287. {
  288. LLFloaterReporter* self = (LLFloaterReporter*)userdata;
  289. if (!self || !gFloaterViewp)
  290. {
  291. return;
  292. }
  293. LLFloater* parent = gFloaterViewp->getParentFloater(self);
  294. if (!parent)
  295. {
  296. return;
  297. }
  298. parent->addDependentFloater(LLFloaterAvatarPicker::show(callbackAvatarID,
  299. userdata,
  300. false, true));
  301. }
  302. //static
  303. void LLFloaterReporter::callbackAvatarID(const std::vector<std::string>& names,
  304. const std::vector<LLUUID>& ids,
  305. void* userdata)
  306. {
  307. LLFloaterReporter* self = (LLFloaterReporter*)userdata;
  308. if (self && !ids.empty() && !names.empty())
  309. {
  310. self->childSetText("abuser_name_edit", names[0]);
  311. self->mAbuserID = ids[0];
  312. self->refresh();
  313. }
  314. }
  315. //static
  316. void LLFloaterReporter::onClickSend(void* userdata)
  317. {
  318. LLFloaterReporter* self = (LLFloaterReporter*)userdata;
  319. if (!self) return;
  320. if (self->mPicking)
  321. {
  322. closePickTool(self);
  323. }
  324. if (self->validateReport())
  325. {
  326. constexpr int IP_CONTENT_REMOVAL = 66;
  327. constexpr int IP_PERMISSONS_EXPLOIT = 37;
  328. LLComboBox* combo = self->mCategoryCombo;
  329. S32 category_value = combo->getSelectedValue().asInteger();
  330. if (!self->mCopyrightWarningSeen)
  331. {
  332. std::string details_lc = self->childGetText("details_edit");
  333. LLStringUtil::toLower(details_lc);
  334. std::string summary_lc = self->childGetText("summary_edit");
  335. LLStringUtil::toLower(summary_lc);
  336. if (details_lc.find("copyright") != std::string::npos ||
  337. summary_lc.find("copyright") != std::string::npos ||
  338. category_value == IP_CONTENT_REMOVAL ||
  339. category_value == IP_PERMISSONS_EXPLOIT)
  340. {
  341. gNotifications.add("HelpReportAbuseContainsCopyright");
  342. self->mCopyrightWarningSeen = true;
  343. return;
  344. }
  345. }
  346. else if (category_value == IP_CONTENT_REMOVAL)
  347. {
  348. // IP_CONTENT_REMOVAL *always* shows the dialog -
  349. // ergo you can never send that abuse report type.
  350. gNotifications.add("HelpReportAbuseContainsCopyright");
  351. return;
  352. }
  353. LLUploadDialog::modalUploadDialog("Uploading...\n\nReport");
  354. // *TODO don't upload image if checkbox isn't checked
  355. const std::string& url = gAgent.getRegionCapability("SendUserReport");
  356. const std::string& sshot_url =
  357. gAgent.getRegionCapability("SendUserReportWithScreenshot");
  358. if (!url.empty() || !sshot_url.empty())
  359. {
  360. self->sendReportViaCaps(url, sshot_url, self->gatherReport());
  361. self->close();
  362. }
  363. else if (self->childGetValue("screen_check"))
  364. {
  365. self->childDisable("send_btn");
  366. self->childDisable("cancel_btn");
  367. // The callback from uploading the image calls
  368. // sendReportViaLegacy()
  369. self->uploadImage();
  370. }
  371. else
  372. {
  373. self->sendReportViaLegacy(self->gatherReport());
  374. LLUploadDialog::modalUploadFinished();
  375. self->close();
  376. }
  377. }
  378. }
  379. //static
  380. void LLFloaterReporter::onClickCancel(void* userdata)
  381. {
  382. LLFloaterReporter* self = (LLFloaterReporter*)userdata;
  383. // Reset flag in case the next report also contains this text
  384. self->mCopyrightWarningSeen = false;
  385. if (self->mPicking)
  386. {
  387. closePickTool(self);
  388. }
  389. self->close();
  390. }
  391. //static
  392. void LLFloaterReporter::onClickObjPicker(void* userdata)
  393. {
  394. LLFloaterReporter* self = (LLFloaterReporter*)userdata;
  395. if (!self) return;
  396. gToolObjPicker.setExitCallback(LLFloaterReporter::closePickTool, self);
  397. gToolMgr.setTransientTool(&gToolObjPicker);
  398. self->mPicking = true;
  399. self->childSetText("object_name", LLStringUtil::null);
  400. self->childSetText("owner_name", LLStringUtil::null);
  401. self->mOwnerName = LLStringUtil::null;
  402. self->getChild<LLButton>("pick_btn")->setToggleState(true);
  403. }
  404. //static
  405. void LLFloaterReporter::closePickTool(void* userdata)
  406. {
  407. LLFloaterReporter* self = (LLFloaterReporter*)userdata;
  408. if (!self) return;
  409. const LLUUID& object_id = gToolObjPicker.getObjectID();
  410. self->getObjectInfo(object_id);
  411. gToolMgr.clearTransientTool();
  412. self->mPicking = false;
  413. self->getChild<LLButton>("pick_btn")->setToggleState(false);
  414. }
  415. //static
  416. bool LLFloaterReporter::showFromMenu()
  417. {
  418. //MK
  419. if (gRLenabled &&
  420. (gRLInterface.mContainsShowloc ||
  421. gRLInterface.mContainsShownames ||
  422. gRLInterface.mContainsShownametags))
  423. {
  424. gNotifications.add("RLVCannotAbuseReport");
  425. return false;
  426. }
  427. //mk
  428. LLFloaterReporter* self = findInstance();
  429. if (self)
  430. {
  431. // Bring that window to front
  432. self->open();
  433. }
  434. else
  435. {
  436. createNewReporter();
  437. LLFloaterReporter* self = findInstance();
  438. std::string fullname;
  439. gAgent.buildFullname(fullname);
  440. self->childSetText("reporter_field", fullname);
  441. }
  442. return true;
  443. }
  444. //static
  445. void LLFloaterReporter::showFromAvatar(const LLUUID& avatar_id,
  446. const std::string& desc,
  447. S32 abuse_category)
  448. {
  449. if (avatar_id.isNull() || !showFromMenu())
  450. {
  451. return;
  452. }
  453. LLFloaterReporter* self = findInstance();
  454. self->setFromAvatarID(avatar_id);
  455. if (!desc.empty())
  456. {
  457. self->childSetText("details_edit", desc);
  458. }
  459. if (abuse_category > -1)
  460. {
  461. self->mCategoryCombo->setSelectedByValue(LLSD::Integer(abuse_category),
  462. true);
  463. }
  464. }
  465. //static
  466. void LLFloaterReporter::showFromObject(const LLUUID& object_id,
  467. const LLUUID& experience_id)
  468. {
  469. if (!showFromMenu())
  470. {
  471. return;
  472. }
  473. LLFloaterReporter* self = findInstance();
  474. if (gObjectList.findAvatar(object_id))
  475. {
  476. self->setFromAvatarID(object_id);
  477. }
  478. else
  479. {
  480. // Request info for this object
  481. self->getObjectInfo(object_id);
  482. }
  483. self->getExperienceInfo(experience_id);
  484. }
  485. //static
  486. void LLFloaterReporter::showFromExperience(const LLUUID& experience_id)
  487. {
  488. if (showFromMenu())
  489. {
  490. LLFloaterReporter* self = findInstance(); // Guaranteed to exist
  491. self->getExperienceInfo(experience_id);
  492. }
  493. }
  494. //static
  495. void LLFloaterReporter::onAvatarNameCache(const LLUUID& avatar_id,
  496. const LLAvatarName& av_name)
  497. {
  498. LLFloaterReporter* self = findInstance();
  499. if (!self) return; // Stale callback, floater closed...
  500. self->mOwnerName = av_name.getNames();
  501. self->childSetText("owner_name", self->mOwnerName);
  502. self->childSetText("abuser_name_edit", self->mOwnerName);
  503. if (self->mObjectID == avatar_id)
  504. {
  505. self->childSetText("object_name", self->mOwnerName);
  506. }
  507. }
  508. void LLFloaterReporter::setFromAvatarID(const LLUUID& avatar_id)
  509. {
  510. mAbuserID = mObjectID = avatar_id;
  511. LLAvatarNameCache::get(avatar_id,
  512. boost::bind(&LLFloaterReporter::onAvatarNameCache,
  513. _1, _2));
  514. }
  515. LLFloaterReporter* LLFloaterReporter::createNewReporter()
  516. {
  517. LLFloaterReporter* self = findInstance();
  518. if (self)
  519. {
  520. // Only one reporter allowed at any time !
  521. self->close();
  522. }
  523. return getInstance(); // Creates a new reporter
  524. }
  525. void LLFloaterReporter::setPickedObjectProperties(const std::string& object_name,
  526. const std::string& owner_name,
  527. const LLUUID& owner_id)
  528. {
  529. childSetText("object_name", object_name);
  530. childSetText("owner_name", owner_name);
  531. childSetText("abuser_name_edit", owner_name);
  532. mAbuserID = owner_id;
  533. mOwnerName = owner_name;
  534. if (mOwnerName.empty())
  535. {
  536. LLAvatarNameCache::get(owner_id,
  537. boost::bind(&LLFloaterReporter::onAvatarNameCache,
  538. _1, _2));
  539. }
  540. }
  541. bool LLFloaterReporter::validateReport()
  542. {
  543. // Ensure user selected a category from the list
  544. LLSD category_sd = mCategoryCombo->getValue();
  545. U8 category = (U8)category_sd.asInteger();
  546. if (category == 0)
  547. {
  548. gNotifications.add("HelpReportAbuseSelectCategory");
  549. return false;
  550. }
  551. if (childGetText("abuser_name_edit").empty())
  552. {
  553. gNotifications.add("HelpReportAbuseAbuserNameEmpty");
  554. return false;
  555. }
  556. if (childGetText("abuse_location_edit").empty())
  557. {
  558. gNotifications.add("HelpReportAbuseAbuserLocationEmpty");
  559. return false;
  560. }
  561. if (childGetText("summary_edit").empty())
  562. {
  563. gNotifications.add("HelpReportAbuseSummaryEmpty");
  564. return false;
  565. }
  566. if (childGetText("details_edit") == mDefaultSummary)
  567. {
  568. gNotifications.add("HelpReportAbuseDetailsEmpty");
  569. return false;
  570. }
  571. return true;
  572. }
  573. LLSD LLFloaterReporter::gatherReport()
  574. {
  575. LLViewerRegion* regionp = gAgent.getRegion();
  576. if (!regionp)
  577. {
  578. return LLSD(); // *TODO handle this failure case more gracefully
  579. }
  580. // Reset flag in case the next report also contains this text
  581. mCopyrightWarningSeen = false;
  582. std::ostringstream summary;
  583. if (!gIsInProductionGrid)
  584. {
  585. summary << "Preview ";
  586. }
  587. std::string category_name;
  588. if (mCategoryCombo)
  589. {
  590. // We want the label, not the value
  591. category_name = mCategoryCombo->getSelectedItemLabel();
  592. }
  593. #if LL_WINDOWS
  594. const char* platform = "Win";
  595. #elif LL_DARWIN
  596. const char* platform = "Mac";
  597. #elif LL_LINUX
  598. const char* platform = "Lnx";
  599. #else
  600. const char* platform = "???";
  601. #endif
  602. // Region in which the reporter is currently present.
  603. summary << " |" << regionp->getName() << "|"
  604. // Region where abuse occured (freeform text)
  605. << " (" << childGetText("abuse_location_edit") << ")"
  606. // Updated category
  607. << " [" << category_name << "] "
  608. // Name of abuser entered in report (chosen using LLAvatarPicker)
  609. << " {" << childGetText("abuser_name_edit") << "} "
  610. // Summary as freeform text
  611. << " \"" << childGetValue("summary_edit").asString()
  612. << "\"";
  613. std::ostringstream details;
  614. // Client version moved to body of email for abuse reports
  615. details << "V" << LL_VERSION_MAJOR << "." << LL_VERSION_MINOR << "."
  616. << LL_VERSION_BRANCH << "." << LL_VERSION_RELEASE << std::endl;
  617. std::string object_name = childGetText("object_name");
  618. if (!object_name.empty() && !mOwnerName.empty())
  619. {
  620. details << "Object: " << object_name << "\n";
  621. details << "Owner: " << mOwnerName << "\n";
  622. }
  623. details << "Abuser name: " << childGetText("abuser_name_edit") << " \n";
  624. details << "Abuser location: " << childGetText("abuse_location_edit")
  625. << " \n";
  626. details << childGetValue("details_edit").asString();
  627. std::string version_string;
  628. version_string = llformat("%d.%d.%d %s %s %s %s", LL_VERSION_MAJOR,
  629. LL_VERSION_MINOR, LL_VERSION_BRANCH, platform,
  630. LLCPUInfo::getInstance()->getFamily().c_str(),
  631. gGLManager.mGLRenderer.c_str(),
  632. gGLManager.mDriverVersionVendorString.c_str());
  633. LLUUID screenshot_id;
  634. if (childGetValue("screen_check"))
  635. {
  636. screenshot_id = childGetValue("screenshot");
  637. }
  638. LLSD report = LLSD::emptyMap();
  639. report["report-type"] = (U8)COMPLAINT_REPORT;
  640. report["category"] = mCategoryCombo->getValue();
  641. report["position"] = mPosition.getValue();
  642. report["check-flags"] = (U8)0; // this is not used
  643. report["screenshot-id"] = screenshot_id;
  644. report["object-id"] = mObjectID;
  645. report["abuser-id"] = mAbuserID;
  646. report["abuse-region-name"] = "";
  647. report["abuse-region-id"] = LLUUID::null;
  648. report["summary"] = summary.str();
  649. report["version-string"] = version_string;
  650. report["details"] = details.str();
  651. return report;
  652. }
  653. void LLFloaterReporter::sendReportViaLegacy(const LLSD& report)
  654. {
  655. LLViewerRegion* regionp = gAgent.getRegion();
  656. if (!regionp) return;
  657. LLMessageSystem* msg = gMessageSystemp;
  658. msg->newMessageFast(_PREHASH_UserReport);
  659. msg->nextBlockFast(_PREHASH_AgentData);
  660. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  661. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  662. msg->nextBlockFast(_PREHASH_ReportData);
  663. msg->addU8Fast(_PREHASH_ReportType, report["report-type"].asInteger());
  664. msg->addU8(_PREHASH_Category, report["category"].asInteger());
  665. msg->addVector3Fast(_PREHASH_Position, LLVector3(report["position"]));
  666. msg->addU8Fast(_PREHASH_CheckFlags, report["check-flags"].asInteger());
  667. msg->addUUIDFast(_PREHASH_ScreenshotID, report["screenshot-id"].asUUID());
  668. msg->addUUIDFast(_PREHASH_ObjectID, report["object-id"].asUUID());
  669. msg->addUUID("AbuserID", report["abuser-id"].asUUID());
  670. msg->addString("AbuseRegionName", report["abuse-region-name"].asString());
  671. msg->addUUID("AbuseRegionID", report["abuse-region-id"].asUUID());
  672. msg->addStringFast(_PREHASH_Summary, report["summary"].asString());
  673. msg->addString("VersionString", report["version-string"]);
  674. msg->addStringFast(_PREHASH_Details, report["details"]);
  675. msg->sendReliable(regionp->getHost());
  676. }
  677. void LLFloaterReporter::finishedARPost(const LLSD&)
  678. {
  679. LLUploadDialog::modalUploadFinished();
  680. }
  681. void LLFloaterReporter::sendReportViaCaps(const std::string& url,
  682. const std::string& sshot_url,
  683. const LLSD& report)
  684. {
  685. if (childGetValue("screen_check").asBoolean() && !sshot_url.empty())
  686. {
  687. // Try to upload screenshot
  688. LLResourceUploadInfo::ptr_t
  689. info(new LLARScreenShotUploader(report,
  690. mResourceDatap->mAssetInfo.mUuid,
  691. mResourceDatap->mAssetInfo.mType));
  692. LLViewerAssetUpload::enqueueInventoryUpload(sshot_url, info);
  693. }
  694. else
  695. {
  696. // Screenshot not wanted or we do not have screenshot cap
  697. LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t
  698. proc = boost::bind(&LLFloaterReporter::finishedARPost, _1);
  699. LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpPost(url, report,
  700. proc, proc);
  701. }
  702. }
  703. void LLFloaterReporter::takeScreenshot()
  704. {
  705. constexpr S32 IMAGE_WIDTH = 1024;
  706. constexpr S32 IMAGE_HEIGHT = 768;
  707. mImageRaw = new LLImageRaw;
  708. if (!gViewerWindowp->rawSnapshot(mImageRaw, IMAGE_WIDTH, IMAGE_HEIGHT,
  709. true, false, true, false))
  710. {
  711. llwarns << "Unable to take screenshot" << llendl;
  712. return;
  713. }
  714. LLPointer<LLImageJ2C> j2cp =
  715. LLViewerTextureList::convertToUploadFile(mImageRaw);
  716. if (!j2cp)
  717. {
  718. llwarns << "Unable to encode the screenshot" << llendl;
  719. return;
  720. }
  721. // Create a resource data
  722. mResourceDatap->mInventoryType = LLInventoryType::IT_NONE;
  723. mResourceDatap->mNextOwnerPerm = 0; // Not used
  724. // We expect that abuse screenshots are free:
  725. mResourceDatap->mExpectedUploadCost = 0;
  726. mResourceDatap->mAssetInfo.mTransactionID.generate();
  727. mResourceDatap->mAssetInfo.mUuid =
  728. mResourceDatap->mAssetInfo.mTransactionID.makeAssetID(gAgent.getSecureSessionID());
  729. mResourceDatap->mAssetInfo.mType = LLAssetType::AT_TEXTURE;
  730. mResourceDatap->mPreferredLocation = LLFolderType::EType(-2);
  731. mResourceDatap->mAssetInfo.mCreatorID = gAgentID;
  732. mResourceDatap->mAssetInfo.setName("screenshot_name");
  733. mResourceDatap->mAssetInfo.setDescription("screenshot_descr");
  734. // Store in cache
  735. LLFileSystem j2c_file(mResourceDatap->mAssetInfo.mUuid,
  736. LLFileSystem::OVERWRITE);
  737. j2c_file.write(j2cp->getData(), j2cp->getDataSize());
  738. // Store in the image list
  739. LLPointer<LLViewerFetchedTexture> image_in_list =
  740. LLViewerTextureManager::getFetchedTexture(mResourceDatap->mAssetInfo.mUuid);
  741. image_in_list->createGLTexture(0, mImageRaw, 0, true);
  742. // *HACK: mark this local image as a missing asset so that the viewer does
  743. // not try to fetch it from the server. *TODO: find out why the texture
  744. // fetcher never stops to try and fetch it when it already failed to get it
  745. // once...
  746. image_in_list->setIsMissingAsset();
  747. // The texture picker then uses that texture
  748. LLTextureCtrl* texctrlp = getChild<LLTextureCtrl>("screenshot");
  749. if (texctrlp)
  750. {
  751. texctrlp->setImageAssetID(mResourceDatap->mAssetInfo.mUuid);
  752. texctrlp->setDefaultImageAssetID(mResourceDatap->mAssetInfo.mUuid);
  753. texctrlp->setCaption("Screenshot");
  754. }
  755. }
  756. void LLFloaterReporter::uploadImage()
  757. {
  758. if (!gAssetStoragep)
  759. {
  760. llwarns << "No valid asset storage. Aborted." << llendl;
  761. return;
  762. }
  763. llinfos << "*** Uploading: " << llendl;
  764. llinfos << "Type: "
  765. << LLAssetType::lookup(mResourceDatap->mAssetInfo.mType)
  766. << llendl;
  767. llinfos << "UUID: " << mResourceDatap->mAssetInfo.mUuid << llendl;
  768. llinfos << "Name: " << mResourceDatap->mAssetInfo.getName() << llendl;
  769. llinfos << "Desc: " << mResourceDatap->mAssetInfo.getDescription()
  770. << llendl;
  771. gAssetStoragep->storeAssetData(mResourceDatap->mAssetInfo.mTransactionID,
  772. mResourceDatap->mAssetInfo.mType,
  773. uploadDoneCallback, (void*)mResourceDatap,
  774. true);
  775. }
  776. // StoreAssetData callback (fixed)
  777. //static
  778. void LLFloaterReporter::uploadDoneCallback(const LLUUID& uuid, void* user_data,
  779. S32 result, LLExtStat ext_status)
  780. {
  781. LLUploadDialog::modalUploadFinished();
  782. LLResourceData* data = (LLResourceData*)user_data;
  783. if (result < 0)
  784. {
  785. LLSD args;
  786. args["REASON"] = std::string(LLAssetStorage::getErrorString(result));
  787. gNotifications.add("ErrorUploadingReportScreenshot", args);
  788. llwarns << "There was a problem uploading a report screenshot due to the following reason: "
  789. << args["REASON"].asString() << llendl;
  790. return;
  791. }
  792. if (data->mPreferredLocation != LLResourceData::INVALID_LOCATION)
  793. {
  794. llwarns << "Unknown report type: " << data->mPreferredLocation
  795. << llendl;
  796. }
  797. LLFloaterReporter* self = findInstance();
  798. if (self)
  799. {
  800. self->mScreenID = uuid;
  801. llinfos << "Got screen shot " << uuid << llendl;
  802. self->sendReportViaLegacy(self->gatherReport());
  803. self->close();
  804. }
  805. }
  806. void LLFloaterReporter::setPosBox(const LLVector3d& pos)
  807. {
  808. mPosition.set(pos);
  809. std::string pos_string = llformat("{%.1f, %.1f, %.1f}", mPosition.mV[VX],
  810. mPosition.mV[VY], mPosition.mV[VZ]);
  811. childSetText("pos_field", pos_string);
  812. }