diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2018-03-30 13:11:30 +0000 | 
|---|---|---|
| committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2018-03-30 13:11:30 +0000 | 
| commit | 43ae8aee6a8719e3bdd87ff2711343dd77edaefc (patch) | |
| tree | a4142e034e0aa34d20a18b24e8799302018a81eb /indra/newview | |
| parent | b1a84d955144664eb83cebbb4eb6b9f5229b0219 (diff) | |
SL-440 Obtain Abuse Report categories from capability
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llfloaterreporter.cpp | 79 | ||||
| -rw-r--r-- | indra/newview/llfloaterreporter.h | 1 | ||||
| -rw-r--r-- | indra/newview/llviewerregion.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/floater_report_abuse.xml | 1 | 
4 files changed, 82 insertions, 0 deletions
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index a320bcc6fc..26e2470494 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -214,10 +214,30 @@ BOOL LLFloaterReporter::postBuild()  	std::string reporter = LLSLURL("agent", gAgent.getID(), "inspect").getSLURLString();  	getChild<LLUICtrl>("reporter_field")->setValue(reporter); +	// request categories +	if (gAgent.getRegion() +		&& gAgent.getRegion()->capabilitiesReceived()) +	{ +		std::string cap_url = gAgent.getRegionCapability("AbuseCategories"); + +		if (!cap_url.empty()) +		{ +			std::string lang = gSavedSettings.getString("Language"); +			if (lang != "default" && !lang.empty()) +			{ +				cap_url += "?lc="; +				cap_url += lang; +			} +			LLCoros::instance().launch("LLIMProcessing::requestOfflineMessagesCoro", +				boost::bind(LLFloaterReporter::requestAbuseCategoriesCoro, cap_url, this->getHandle())); +		} +	} +  	center();  	return TRUE;  } +  // virtual  LLFloaterReporter::~LLFloaterReporter()  { @@ -402,6 +422,65 @@ void LLFloaterReporter::onAvatarNameCache(const LLUUID& avatar_id, const LLAvata  	}  } +void LLFloaterReporter::requestAbuseCategoriesCoro(std::string url, LLHandle<LLFloater> handle) +{ +    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); +    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t +        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("requestAbuseCategoriesCoro", httpPolicy)); +    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + +    LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + +    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; +    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + +    if (!status || !result.has("categories")) // success = httpResults["success"].asBoolean(); +    { +        LL_WARNS() << "Error requesting Abuse Categories from capability: " << url << LL_ENDL; +        return; +    } + +    if (handle.isDead()) +    { +        // nothing to do +        return; +    } + +    LLFloater* floater = handle.get(); +    LLComboBox* combo = floater->getChild<LLComboBox>("category_combo"); +    if (!combo) +    { +        LL_WARNS() << "categories category_combo not found!" << LL_ENDL; +        return; +    } + +    //get selection (in case capability took a while) +    S32 selection = combo->getCurrentIndex(); + +    // Combobox should have a "Select category" element; +    // This is a bit of workaround since there is no proper and simple way to save array of +    // localizable strings in xml along with data (value). For now combobox is initialized along +    // with placeholders, and first element is "Select category" which we want to keep, so remove +    // everything but first element. +    // Todo: once sim with capability fully releases, just remove this string and all unnecessary +    // items from combobox since they will be obsolete (or depending on situation remake this to +    // something better, for example move "Select category" to separate string) +    while (combo->remove(1)); + +    LLSD contents = result["categories"]; + +    LLSD::array_iterator i = contents.beginArray(); +    LLSD::array_iterator iEnd = contents.endArray(); +    for (; i != iEnd; ++i) +    { +        const LLSD &message_data(*i); +        std::string label = message_data["description_localized"]; +        combo->add(label, message_data["category"]); +    } + +    //restore selection +    combo->selectNthItem(selection); +}  // static  void LLFloaterReporter::onClickSend(void *userdata) diff --git a/indra/newview/llfloaterreporter.h b/indra/newview/llfloaterreporter.h index d9ecb9f4ea..c678df7155 100644 --- a/indra/newview/llfloaterreporter.h +++ b/indra/newview/llfloaterreporter.h @@ -129,6 +129,7 @@ private:  	void setFromAvatarID(const LLUUID& avatar_id);  	void onAvatarNameCache(const LLUUID& avatar_id, const LLAvatarName& av_name); +	static void requestAbuseCategoriesCoro(std::string url, LLHandle<LLFloater> handle);      static void finishedARPost(const LLSD &);  private: diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index b128e2cd93..bb0dbc6457 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2816,6 +2816,7 @@ void LLViewerRegion::unpackRegionHandshake()  void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)  { +	capabilityNames.append("AbuseCategories");  	capabilityNames.append("AgentPreferences");  	capabilityNames.append("AgentState");  	capabilityNames.append("AttachmentResources"); diff --git a/indra/newview/skins/default/xui/en/floater_report_abuse.xml b/indra/newview/skins/default/xui/en/floater_report_abuse.xml index 225266af86..8fa5b49573 100644 --- a/indra/newview/skins/default/xui/en/floater_report_abuse.xml +++ b/indra/newview/skins/default/xui/en/floater_report_abuse.xml @@ -188,6 +188,7 @@       tool_tip="Category -- select the category that best describes this report"       top_pad="5"       width="313"> +      <!-- Values can be populated from capability -->          <combo_box.item           label="Select category"           name="Select_category"  | 
