diff options
author | Eli Linden <eli@lindenlab.com> | 2010-02-02 11:32:33 -0800 |
---|---|---|
committer | Eli Linden <eli@lindenlab.com> | 2010-02-02 11:32:33 -0800 |
commit | a4d81d0f6995ad52f3c0fc094d93f8652600abbd (patch) | |
tree | 9fcc82ba3061423c971f56aa70b8447de2677237 /indra/newview/llfloaterscriptlimits.cpp | |
parent | 3fde73508e5b2fb5507b47d1f56d3fb47162b6fc (diff) | |
parent | b90d1d0b6f60684ba2e97959c6a9d2df0ff8ec79 (diff) |
Merge
Diffstat (limited to 'indra/newview/llfloaterscriptlimits.cpp')
-rw-r--r-- | indra/newview/llfloaterscriptlimits.cpp | 987 |
1 files changed, 565 insertions, 422 deletions
diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 8875e35821..4194416a01 100644 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -59,10 +59,30 @@ /// LLFloaterScriptLimits ///---------------------------------------------------------------------------- -// due to server side bugs the full summary display is not possible -// until they are fixed this define creates a simple version of the -// summary which only shows available & correct information -#define USE_SIMPLE_SUMMARY +// debug switches, won't work in release +#ifndef LL_RELEASE_FOR_DOWNLOAD + +// dump responder replies to llinfos for debugging +//#define DUMP_REPLIES_TO_LLINFOS + +#ifdef DUMP_REPLIES_TO_LLINFOS +#include "llsdserialize.h" +#include "llwindow.h" +#endif + +// use fake LLSD responses to check the viewer side is working correctly +// I'm syncing this with the server side efforts so hopfully we can keep +// the to-ing and fro-ing between the two teams to a minimum +//#define USE_FAKE_RESPONSES + +#ifdef USE_FAKE_RESPONSES +const S32 FAKE_NUMBER_OF_URLS = 329; +const S32 FAKE_AVAILABLE_URLS = 731; +const S32 FAKE_AMOUNT_OF_MEMORY = 66741; +const S32 FAKE_AVAILABLE_MEMORY = 895577; +#endif + +#endif const S32 SIZE_OF_ONE_KB = 1024; @@ -87,32 +107,41 @@ BOOL LLFloaterScriptLimits::postBuild() } mTab = getChild<LLTabContainer>("scriptlimits_panels"); + + if(!mTab) + { + llinfos << "Error! couldn't get scriptlimits_panels, aborting Script Information setup" << llendl; + return FALSE; + } // contruct the panels - LLPanelScriptLimitsRegionMemory* panel_memory; - panel_memory = new LLPanelScriptLimitsRegionMemory; - mInfoPanels.push_back(panel_memory); + std::string land_url = gAgent.getRegion()->getCapability("LandResources"); + if (!land_url.empty()) + { + LLPanelScriptLimitsRegionMemory* panel_memory; + panel_memory = new LLPanelScriptLimitsRegionMemory; + mInfoPanels.push_back(panel_memory); + LLUICtrlFactory::getInstance()->buildPanel(panel_memory, "panel_script_limits_region_memory.xml"); + mTab->addTabPanel(panel_memory); + } - LLUICtrlFactory::getInstance()->buildPanel(panel_memory, "panel_script_limits_region_memory.xml"); - mTab->addTabPanel(panel_memory); - - LLPanelScriptLimitsRegionURLs* panel_urls = new LLPanelScriptLimitsRegionURLs; - mInfoPanels.push_back(panel_urls); - LLUICtrlFactory::getInstance()->buildPanel(panel_urls, "panel_script_limits_region_urls.xml"); - mTab->addTabPanel(panel_urls); - - LLPanelScriptLimitsAttachment* panel_attachments = new LLPanelScriptLimitsAttachment; - mInfoPanels.push_back(panel_attachments); - LLUICtrlFactory::getInstance()->buildPanel(panel_attachments, "panel_script_limits_my_avatar.xml"); - mTab->addTabPanel(panel_attachments); - - if(selectParcelPanel) + std::string attachment_url = gAgent.getRegion()->getCapability("AttachmentResources"); + if (!attachment_url.empty()) + { + LLPanelScriptLimitsAttachment* panel_attachments = new LLPanelScriptLimitsAttachment; + mInfoPanels.push_back(panel_attachments); + LLUICtrlFactory::getInstance()->buildPanel(panel_attachments, "panel_script_limits_my_avatar.xml"); + mTab->addTabPanel(panel_attachments); + } + + if(mInfoPanels.size() > 0) { mTab->selectTab(0); } - else + + if(!selectParcelPanel && (mInfoPanels.size() > 1)) { - mTab->selectTab(2); + mTab->selectTab(1); } return TRUE; @@ -160,6 +189,20 @@ void LLPanelScriptLimitsInfo::updateChild(LLUICtrl* child_ctr) void fetchScriptLimitsRegionInfoResponder::result(const LLSD& content) { + //we don't need to test with a fake respose here (shouldn't anyway) + +#ifdef DUMP_REPLIES_TO_LLINFOS + + LLSDNotationStreamer notation_streamer(content); + std::ostringstream nice_llsd; + nice_llsd << notation_streamer; + + OSMessageBox(nice_llsd.str(), "main cap response:", 0); + + llinfos << "main cap response:" << content << llendl; + +#endif + // at this point we have an llsd which should contain ether one or two urls to the services we want. // first we look for the details service: if(content.has("ScriptResourceDetails")) @@ -173,24 +216,6 @@ void fetchScriptLimitsRegionInfoResponder::result(const LLSD& content) { llinfos << "Failed to get llfloaterscriptlimits instance" << llendl; } - else - { - -// temp - only show info if we get details - there's nothing to show if not until the sim gets fixed -#ifdef USE_SIMPLE_SUMMARY - - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - std::string msg = LLTrans::getString("ScriptLimitsRequestDontOwnParcel"); - panel_memory->childSetValue("loading_text", LLSD(msg)); - LLPanelScriptLimitsRegionURLs* panel_urls = (LLPanelScriptLimitsRegionURLs*)tab->getChild<LLPanel>("script_limits_region_urls_panel"); - panel_urls->childSetValue("loading_text", LLSD(msg)); - - // intentional early out as we dont want the resource summary if we are using the "simple summary" - // and the details are missing - return; -#endif - } } // then the summary service: @@ -205,8 +230,61 @@ void fetchScriptLimitsRegionInfoResponder::error(U32 status, const std::string& llinfos << "Error from responder " << reason << llendl; } -void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content) +void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref) { +#ifdef USE_FAKE_RESPONSES + + LLSD fake_content; + LLSD summary = LLSD::emptyMap(); + LLSD available = LLSD::emptyArray(); + LLSD available_urls = LLSD::emptyMap(); + LLSD available_memory = LLSD::emptyMap(); + LLSD used = LLSD::emptyArray(); + LLSD used_urls = LLSD::emptyMap(); + LLSD used_memory = LLSD::emptyMap(); + + used_urls["type"] = "urls"; + used_urls["amount"] = FAKE_NUMBER_OF_URLS; + available_urls["type"] = "urls"; + available_urls["amount"] = FAKE_AVAILABLE_URLS; + used_memory["type"] = "memory"; + used_memory["amount"] = FAKE_AMOUNT_OF_MEMORY; + available_memory["type"] = "memory"; + available_memory["amount"] = FAKE_AVAILABLE_MEMORY; + +//summary response:{'summary':{'available':[{'amount':i731,'type':'urls'},{'amount':i895577,'type':'memory'},{'amount':i731,'type':'urls'},{'amount':i895577,'type':'memory'}],'used':[{'amount':i329,'type':'urls'},{'amount':i66741,'type':'memory'}]}} + + used.append(used_urls); + used.append(used_memory); + available.append(available_urls); + available.append(available_memory); + + summary["available"] = available; + summary["used"] = used; + + fake_content["summary"] = summary; + + const LLSD& content = fake_content; + +#else + + const LLSD& content = content_ref; + +#endif + + +#ifdef DUMP_REPLIES_TO_LLINFOS + + LLSDNotationStreamer notation_streamer(content); + std::ostringstream nice_llsd; + nice_llsd << notation_streamer; + + OSMessageBox(nice_llsd.str(), "summary response:", 0); + + llinfos << "summary response:" << *content << llendl; + +#endif + LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); if(!instance) { @@ -217,8 +295,6 @@ void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content) LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); panel_memory->setRegionSummary(content); - LLPanelScriptLimitsRegionURLs* panel_urls = (LLPanelScriptLimitsRegionURLs*)tab->getChild<LLPanel>("script_limits_region_urls_panel"); - panel_urls->setRegionSummary(content); } } @@ -227,8 +303,82 @@ void fetchScriptLimitsRegionSummaryResponder::error(U32 status, const std::strin llinfos << "Error from responder " << reason << llendl; } -void fetchScriptLimitsRegionDetailsResponder::result(const LLSD& content) +void fetchScriptLimitsRegionDetailsResponder::result(const LLSD& content_ref) { +#ifdef USE_FAKE_RESPONSES +/* +Updated detail service, ** denotes field added: + +result (map) ++-parcels (array of maps) + +-id (uuid) + +-local_id (S32)** + +-name (string) + +-owner_id (uuid) (in ERS as owner, but owner_id in code) + +-objects (array of maps) + +-id (uuid) + +-name (string) + +-owner_id (uuid) (in ERS as owner, in code as owner_id) + +-owner_name (sting)** + +-location (map)** + +-x (float) + +-y (float) + +-z (float) + +-resources (map) (this is wrong in the ERS but right in code) + +-type (string) + +-amount (int) +*/ + LLSD fake_content; + LLSD resource = LLSD::emptyMap(); + LLSD location = LLSD::emptyMap(); + LLSD object = LLSD::emptyMap(); + LLSD objects = LLSD::emptyArray(); + LLSD parcel = LLSD::emptyMap(); + LLSD parcels = LLSD::emptyArray(); + + resource["urls"] = FAKE_NUMBER_OF_URLS; + resource["memory"] = FAKE_AMOUNT_OF_MEMORY; + + location["x"] = 128.0f; + location["y"] = 128.0f; + location["z"] = 0.0f; + + object["id"] = LLUUID("d574a375-0c6c-fe3d-5733-da669465afc7"); + object["name"] = "Gabs fake Object!"; + object["owner_id"] = LLUUID("8dbf2d41-69a0-4e5e-9787-0c9d297bc570"); + object["owner_name"] = "Gabs Linden"; + object["location"] = location; + object["resources"] = resource; + + objects.append(object); + + parcel["id"] = LLUUID("da05fb28-0d20-e593-2728-bddb42dd0160"); + parcel["local_id"] = 42; + parcel["name"] = "Gabriel Linden\'s Sub Plot"; + parcel["objects"] = objects; + parcels.append(parcel); + + fake_content["parcels"] = parcels; + const LLSD& content = fake_content; + +#else + + const LLSD& content = content_ref; + +#endif + +#ifdef DUMP_REPLIES_TO_LLINFOS + + LLSDNotationStreamer notation_streamer(content); + std::ostringstream nice_llsd; + nice_llsd << notation_streamer; + + OSMessageBox(nice_llsd.str(), "details response:", 0); + + llinfos << "details response:" << content << llendl; + +#endif + LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); if(!instance) @@ -238,11 +388,22 @@ void fetchScriptLimitsRegionDetailsResponder::result(const LLSD& content) else { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - panel_memory->setRegionDetails(content); - - LLPanelScriptLimitsRegionURLs* panel_urls = (LLPanelScriptLimitsRegionURLs*)tab->getChild<LLPanel>("script_limits_region_urls_panel"); - panel_urls->setRegionDetails(content); + if(tab) + { + LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); + if(panel_memory) + { + panel_memory->setRegionDetails(content); + } + else + { + llinfos << "Failed to get scriptlimits memory panel" << llendl; + } + } + else + { + llinfos << "Failed to get scriptlimits_panels" << llendl; + } } } @@ -251,8 +412,61 @@ void fetchScriptLimitsRegionDetailsResponder::error(U32 status, const std::strin llinfos << "Error from responder " << reason << llendl; } -void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content) +void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref) { + +#ifdef USE_FAKE_RESPONSES + + // just add the summary, as that's all I'm testing currently! + LLSD fake_content = LLSD::emptyMap(); + LLSD summary = LLSD::emptyMap(); + LLSD available = LLSD::emptyArray(); + LLSD available_urls = LLSD::emptyMap(); + LLSD available_memory = LLSD::emptyMap(); + LLSD used = LLSD::emptyArray(); + LLSD used_urls = LLSD::emptyMap(); + LLSD used_memory = LLSD::emptyMap(); + + used_urls["type"] = "urls"; + used_urls["amount"] = FAKE_NUMBER_OF_URLS; + available_urls["type"] = "urls"; + available_urls["amount"] = FAKE_AVAILABLE_URLS; + used_memory["type"] = "memory"; + used_memory["amount"] = FAKE_AMOUNT_OF_MEMORY; + available_memory["type"] = "memory"; + available_memory["amount"] = FAKE_AVAILABLE_MEMORY; + + used.append(used_urls); + used.append(used_memory); + available.append(available_urls); + available.append(available_memory); + + summary["available"] = available; + summary["used"] = used; + + fake_content["summary"] = summary; + fake_content["attachments"] = content_ref["attachments"]; + + const LLSD& content = fake_content; + +#else + + const LLSD& content = content_ref; + +#endif + +#ifdef DUMP_REPLIES_TO_LLINFOS + + LLSDNotationStreamer notation_streamer(content); + std::ostringstream nice_llsd; + nice_llsd << notation_streamer; + + OSMessageBox(nice_llsd.str(), "attachment response:", 0); + + llinfos << "attachment response:" << content << llendl; + +#endif + LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); if(!instance) @@ -262,8 +476,22 @@ void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content) else { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsAttachment* panel = (LLPanelScriptLimitsAttachment*)tab->getChild<LLPanel>("script_limits_my_avatar_panel"); - panel->setAttachmentDetails(content); + if(tab) + { + LLPanelScriptLimitsAttachment* panel = (LLPanelScriptLimitsAttachment*)tab->getChild<LLPanel>("script_limits_my_avatar_panel"); + if(panel) + { + panel->setAttachmentDetails(content); + } + else + { + llinfos << "Failed to get script_limits_my_avatar_panel" << llendl; + } + } + else + { + llinfos << "Failed to get scriptlimits_panels" << llendl; + } } } @@ -309,7 +537,7 @@ void LLPanelScriptLimitsRegionMemory::processParcelInfo(const LLParcelData& parc { std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting"); childSetValue("loading_text", LLSD(msg_waiting)); - } + } } void LLPanelScriptLimitsRegionMemory::setParcelID(const LLUUID& parcel_id) @@ -341,6 +569,11 @@ void LLPanelScriptLimitsRegionMemory::onNameCache( std::string name = first_name + " " + last_name; LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); + if(!list) + { + return; + } + std::vector<LLSD>::iterator id_itor; for (id_itor = mObjectListItems.begin(); id_itor != mObjectListItems.end(); ++id_itor) { @@ -351,33 +584,8 @@ void LLPanelScriptLimitsRegionMemory::onNameCache( if(item) { - item->getColumn(2)->setValue(LLSD(name)); - element["columns"][2]["value"] = name; - } - } - } - - // fill in the url's tab if needed, all urls must have memory so we can do it all here - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); - if(instance) - { - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_urls_panel"); - - LLScrollListCtrl *list = panel->getChild<LLScrollListCtrl>("scripts_list"); - std::vector<LLSD>::iterator id_itor; - for (id_itor = mObjectListItems.begin(); id_itor != mObjectListItems.end(); ++id_itor) - { - LLSD element = *id_itor; - if(element["owner_id"].asUUID() == id) - { - LLScrollListItem* item = list->getItem(element["id"].asUUID()); - - if(item) - { - item->getColumn(2)->setValue(LLSD(name)); - element["columns"][2]["value"] = name; - } + item->getColumn(3)->setValue(LLSD(name)); + element["columns"][3]["value"] = name; } } } @@ -386,6 +594,12 @@ void LLPanelScriptLimitsRegionMemory::onNameCache( void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) { LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); + + if(!list) + { + llinfos << "Error getting the scripts_list control" << llendl; + return; + } S32 number_parcels = content["parcels"].size(); @@ -394,130 +608,197 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) std::string msg_parcels = LLTrans::getString("ScriptLimitsParcelsOwned", args_parcels); childSetValue("parcels_listed", LLSD(msg_parcels)); - S32 total_objects = 0; - S32 total_size = 0; - std::vector<LLUUID> names_requested; + // This makes the assumption that all objects will have the same set + // of attributes, ie they will all have, or none will have locations + // This is a pretty safe assumption as it's reliant on server version. + bool has_locations = false; + bool has_local_ids = false; + for(S32 i = 0; i < number_parcels; i++) { std::string parcel_name = content["parcels"][i]["name"].asString(); LLUUID parcel_id = content["parcels"][i]["id"].asUUID(); S32 number_objects = content["parcels"][i]["objects"].size(); + + S32 local_id = 0; + if(content["parcels"][i].has("local_id")) + { + // if any locations are found flag that we can use them and turn on the highlight button + has_local_ids = true; + local_id = content["parcels"][i]["local_id"].asInteger(); + } + for(S32 j = 0; j < number_objects; j++) { S32 size = content["parcels"][i]["objects"][j]["resources"]["memory"].asInteger() / SIZE_OF_ONE_KB; - total_size += size; + + S32 urls = content["parcels"][i]["objects"][j]["resources"]["urls"].asInteger(); std::string name_buf = content["parcels"][i]["objects"][j]["name"].asString(); LLUUID task_id = content["parcels"][i]["objects"][j]["id"].asUUID(); LLUUID owner_id = content["parcels"][i]["objects"][j]["owner_id"].asUUID(); - + + F32 location_x = 0.0f; + F32 location_y = 0.0f; + F32 location_z = 0.0f; + + if(content["parcels"][i]["objects"][j].has("location")) + { + // if any locations are found flag that we can use them and turn on the highlight button + LLVector3 vec = ll_vector3_from_sd(content["parcels"][i]["objects"][j]["location"]); + has_locations = true; + location_x = vec.mV[0]; + location_y = vec.mV[1]; + location_z = vec.mV[2]; + } + std::string owner_buf; - - BOOL name_is_cached = gCacheName->getFullName(owner_id, owner_buf); - if(!name_is_cached) + + // in the future the server will give us owner names, so see if we're there yet: + if(content["parcels"][i]["objects"][j].has("owner_name")) + { + owner_buf = content["parcels"][i]["objects"][j]["owner_name"].asString(); + } + // ...and if not use the slightly more painful method of disovery: + else { - if(std::find(names_requested.begin(), names_requested.end(), owner_id) == names_requested.end()) + BOOL name_is_cached = gCacheName->getFullName(owner_id, owner_buf); + if(!name_is_cached) { - names_requested.push_back(owner_id); - gCacheName->get(owner_id, TRUE, - boost::bind(&LLPanelScriptLimitsRegionMemory::onNameCache, - this, _1, _2, _3)); + if(std::find(names_requested.begin(), names_requested.end(), owner_id) == names_requested.end()) + { + names_requested.push_back(owner_id); + gCacheName->get(owner_id, TRUE, + boost::bind(&LLPanelScriptLimitsRegionMemory::onNameCache, + this, _1, _2, _3)); + } } } LLSD element; element["id"] = task_id; - element["owner_id"] = owner_id; element["columns"][0]["column"] = "size"; element["columns"][0]["value"] = llformat("%d", size); element["columns"][0]["font"] = "SANSSERIF"; - element["columns"][1]["column"] = "name"; - element["columns"][1]["value"] = name_buf; + element["columns"][1]["column"] = "urls"; + element["columns"][1]["value"] = llformat("%d", urls); element["columns"][1]["font"] = "SANSSERIF"; - element["columns"][2]["column"] = "owner"; - element["columns"][2]["value"] = owner_buf; + element["columns"][2]["column"] = "name"; + element["columns"][2]["value"] = name_buf; element["columns"][2]["font"] = "SANSSERIF"; - element["columns"][3]["column"] = "location"; - element["columns"][3]["value"] = parcel_name; + element["columns"][3]["column"] = "owner"; + element["columns"][3]["value"] = owner_buf; element["columns"][3]["font"] = "SANSSERIF"; + element["columns"][4]["column"] = "parcel"; + element["columns"][4]["value"] = parcel_name; + element["columns"][4]["font"] = "SANSSERIF"; + element["columns"][5]["column"] = "location"; + if(has_locations) + { + element["columns"][5]["value"] = llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z); + } + else + { + element["columns"][5]["value"] = ""; + } + element["columns"][5]["font"] = "SANSSERIF"; list->addElement(element, ADD_SORTED); + + element["owner_id"] = owner_id; + element["local_id"] = local_id; mObjectListItems.push_back(element); - total_objects++; } } - mParcelMemoryUsed =total_size; - mGotParcelMemoryUsed = TRUE; - populateParcelMemoryText(); -} + if (has_locations) + { + LLButton* btn = getChild<LLButton>("highlight_btn"); + if(btn) + { + btn->setVisible(true); + } + } -void LLPanelScriptLimitsRegionMemory::populateParcelMemoryText() -{ - if(mGotParcelMemoryUsed && mGotParcelMemoryMax) + if (has_local_ids) { -#ifdef USE_SIMPLE_SUMMARY - LLStringUtil::format_map_t args_parcel_memory; - args_parcel_memory["[COUNT]"] = llformat ("%d", mParcelMemoryUsed); - std::string msg_parcel_memory = LLTrans::getString("ScriptLimitsMemoryUsedSimple", args_parcel_memory); - childSetValue("memory_used", LLSD(msg_parcel_memory)); -#else - S32 parcel_memory_available = mParcelMemoryMax - mParcelMemoryUsed; + LLButton* btn = getChild<LLButton>("return_btn"); + if(btn) + { + btn->setVisible(true); + } + } - LLStringUtil::format_map_t args_parcel_memory; - args_parcel_memory["[COUNT]"] = llformat ("%d", mParcelMemoryUsed); - args_parcel_memory["[MAX]"] = llformat ("%d", mParcelMemoryMax); - args_parcel_memory["[AVAILABLE]"] = llformat ("%d", parcel_memory_available); - std::string msg_parcel_memory = LLTrans::getString("ScriptLimitsMemoryUsed", args_parcel_memory); - childSetValue("memory_used", LLSD(msg_parcel_memory)); -#endif + // save the structure to make object return easier + mContent = content; - childSetValue("loading_text", LLSD(std::string(""))); - } + childSetValue("loading_text", LLSD(std::string(""))); } void LLPanelScriptLimitsRegionMemory::setRegionSummary(LLSD content) { - if(content["summary"]["available"][0]["type"].asString() == std::string("memory")) + if(content["summary"]["used"][0]["type"].asString() == std::string("memory")) { - mParcelMemoryMax = content["summary"]["available"][0]["amount"].asInteger(); - mGotParcelMemoryMax = TRUE; + mParcelMemoryUsed = content["summary"]["used"][0]["amount"].asInteger() / SIZE_OF_ONE_KB; + mParcelMemoryMax = content["summary"]["available"][0]["amount"].asInteger() / SIZE_OF_ONE_KB; + mGotParcelMemoryUsed = TRUE; } - else if(content["summary"]["available"][1]["type"].asString() == std::string("memory")) + else if(content["summary"]["used"][1]["type"].asString() == std::string("memory")) { - mParcelMemoryMax = content["summary"]["available"][1]["amount"].asInteger(); - mGotParcelMemoryMax = TRUE; + mParcelMemoryUsed = content["summary"]["used"][1]["amount"].asInteger() / SIZE_OF_ONE_KB; + mParcelMemoryMax = content["summary"]["available"][1]["amount"].asInteger() / SIZE_OF_ONE_KB; + mGotParcelMemoryUsed = TRUE; } else { llinfos << "summary doesn't contain memory info" << llendl; return; } -/* - currently this is broken on the server, so we get this value from the details section - and update via populateParcelMemoryText() when both sets of information have been returned - - when the sim is fixed this should be used instead: - if(content["summary"]["used"][0]["type"].asString() == std::string("memory")) + + if(content["summary"]["used"][0]["type"].asString() == std::string("urls")) { - mParcelMemoryUsed = content["summary"]["used"][0]["amount"].asInteger(); - mGotParcelMemoryUsed = TRUE; + mParcelURLsUsed = content["summary"]["used"][0]["amount"].asInteger(); + mParcelURLsMax = content["summary"]["available"][0]["amount"].asInteger(); + mGotParcelURLsUsed = TRUE; } - else if(content["summary"]["used"][1]["type"].asString() == std::string("memory")) + else if(content["summary"]["used"][1]["type"].asString() == std::string("urls")) { - mParcelMemoryUsed = content["summary"]["used"][1]["amount"].asInteger(); - mGotParcelMemoryUsed = TRUE; + mParcelURLsUsed = content["summary"]["used"][1]["amount"].asInteger(); + mParcelURLsMax = content["summary"]["available"][1]["amount"].asInteger(); + mGotParcelURLsUsed = TRUE; } else { - //ERROR!!! + llinfos << "summary doesn't contain urls info" << llendl; return; - }*/ + } - populateParcelMemoryText(); + if((mParcelMemoryUsed >= 0) && (mParcelMemoryMax >= 0)) + { + S32 parcel_memory_available = mParcelMemoryMax - mParcelMemoryUsed; + + LLStringUtil::format_map_t args_parcel_memory; + args_parcel_memory["[COUNT]"] = llformat ("%d", mParcelMemoryUsed); + args_parcel_memory["[MAX]"] = llformat ("%d", mParcelMemoryMax); + args_parcel_memory["[AVAILABLE]"] = llformat ("%d", parcel_memory_available); + std::string msg_parcel_memory = LLTrans::getString("ScriptLimitsMemoryUsed", args_parcel_memory); + childSetValue("memory_used", LLSD(msg_parcel_memory)); + } + + if((mParcelURLsUsed >= 0) && (mParcelURLsMax >= 0)) + { + S32 parcel_urls_available = mParcelURLsMax - mParcelURLsUsed; + + LLStringUtil::format_map_t args_parcel_urls; + args_parcel_urls["[COUNT]"] = llformat ("%d", mParcelURLsUsed); + args_parcel_urls["[MAX]"] = llformat ("%d", mParcelURLsMax); + args_parcel_urls["[AVAILABLE]"] = llformat ("%d", parcel_urls_available); + std::string msg_parcel_urls = LLTrans::getString("ScriptLimitsURLsUsed", args_parcel_urls); + childSetValue("urls_used", LLSD(msg_parcel_urls)); + } } BOOL LLPanelScriptLimitsRegionMemory::postBuild() @@ -530,6 +811,10 @@ BOOL LLPanelScriptLimitsRegionMemory::postBuild() childSetValue("loading_text", LLSD(msg_waiting)); LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); + if(!list) + { + return FALSE; + } //set all columns to resizable mode even if some columns will be empty for(S32 column = 0; column < list->getNumColumns(); column++) @@ -548,18 +833,11 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() LLFloaterLand* instance = LLFloaterReg::getTypedInstance<LLFloaterLand>("about_land"); if(!instance) { - //this isnt really an error... -// llinfos << "Failed to get about land instance" << llendl; -// std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); childSetValue("loading_text", LLSD(std::string(""))); //might have to do parent post build here //if not logic below could use early outs return FALSE; } - - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionURLs* panel_urls = (LLPanelScriptLimitsRegionURLs*)tab->getChild<LLPanel>("script_limits_region_urls_panel"); - LLParcel* parcel = instance->getCurrentSelectedParcel(); LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); @@ -575,7 +853,6 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() { std::string msg_wrong_region = LLTrans::getString("ScriptLimitsRequestWrongRegion"); childSetValue("loading_text", LLSD(msg_wrong_region)); - panel_urls->childSetValue("loading_text", LLSD(msg_wrong_region)); return FALSE; } @@ -605,14 +882,12 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); childSetValue("loading_text", LLSD(msg_waiting)); - panel_urls->childSetValue("loading_text", LLSD(msg_waiting)); } } else { - std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); + std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestNoParcelSelected"); childSetValue("loading_text", LLSD(msg_waiting)); - panel_urls->childSetValue("loading_text", LLSD(msg_waiting)); } return LLPanelScriptLimitsInfo::postBuild(); @@ -629,10 +904,13 @@ void LLPanelScriptLimitsRegionMemory::clearList() mGotParcelMemoryUsed = FALSE; mGotParcelMemoryMax = FALSE; + mGotParcelURLsUsed = FALSE; + mGotParcelURLsMax = FALSE; LLStringUtil::format_map_t args_parcel_memory; std::string msg_empty_string(""); childSetValue("memory_used", LLSD(msg_empty_string)); + childSetValue("urls_used", LLSD(msg_empty_string)); childSetValue("parcels_listed", LLSD(msg_empty_string)); mObjectListItems.clear(); @@ -647,13 +925,16 @@ void LLPanelScriptLimitsRegionMemory::onClickRefresh(void* userdata) if(instance) { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - panel_memory->clearList(); - - LLPanelScriptLimitsRegionURLs* panel_urls = (LLPanelScriptLimitsRegionURLs*)tab->getChild<LLPanel>("script_limits_region_urls_panel"); - panel_urls->clearList(); + if(tab) + { + LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); + if(panel_memory) + { + panel_memory->clearList(); - panel_memory->StartRequestChain(); + panel_memory->StartRequestChain(); + } + } return; } else @@ -665,78 +946,80 @@ void LLPanelScriptLimitsRegionMemory::onClickRefresh(void* userdata) void LLPanelScriptLimitsRegionMemory::showBeacon() { -/* LLScrollListCtrl* list = getChild<LLScrollListCtrl>("scripts_list"); + LLScrollListCtrl* list = getChild<LLScrollListCtrl>("scripts_list"); if (!list) return; LLScrollListItem* first_selected = list->getFirstSelected(); if (!first_selected) return; - std::string name = first_selected->getColumn(1)->getValue().asString(); - std::string pos_string = first_selected->getColumn(3)->getValue().asString(); + std::string name = first_selected->getColumn(2)->getValue().asString(); + std::string pos_string = first_selected->getColumn(5)->getValue().asString(); - llinfos << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" <<llendl; - llinfos << "name = " << name << " pos = " << pos_string << llendl; - F32 x, y, z; S32 matched = sscanf(pos_string.c_str(), "<%g,%g,%g>", &x, &y, &z); if (matched != 3) return; LLVector3 pos_agent(x, y, z); LLVector3d pos_global = gAgent.getPosGlobalFromAgent(pos_agent); - llinfos << "name = " << name << " pos = " << pos_string << llendl; + std::string tooltip(""); - LLTracker::trackLocation(pos_global, name, tooltip, LLTracker::LOCATION_ITEM);*/ + LLTracker::trackLocation(pos_global, name, tooltip, LLTracker::LOCATION_ITEM); } // static void LLPanelScriptLimitsRegionMemory::onClickHighlight(void* userdata) { -/* llinfos << "LLPanelRegionGeneralInfo::onClickHighlight" << llendl; + llinfos << "LLPanelRegionGeneralInfo::onClickHighlight" << llendl; LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); if(instance) { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - panel->showBeacon(); + if(tab) + { + LLPanelScriptLimitsRegionMemory* panel = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); + if(panel) + { + panel->showBeacon(); + } + } return; } else { llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << llendl; -// std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); -// panel->childSetValue("loading_text", LLSD(msg_waiting)); return; - }*/ + } } -void LLPanelScriptLimitsRegionMemory::returnObjects() +void LLPanelScriptLimitsRegionMemory::returnObjectsFromParcel(S32 local_id) { -/* llinfos << "started" << llendl; LLMessageSystem *msg = gMessageSystem; LLViewerRegion* region = gAgent.getRegion(); if (!region) return; - llinfos << "got region" << llendl; LLCtrlListInterface *list = childGetListInterface("scripts_list"); if (!list || list->getItemCount() == 0) return; - llinfos << "got list" << llendl; - std::vector<LLUUID>::iterator id_itor; + std::vector<LLSD>::iterator id_itor; bool start_message = true; - for (id_itor = mObjectListIDs.begin(); id_itor != mObjectListIDs.end(); ++id_itor) + for (id_itor = mObjectListItems.begin(); id_itor != mObjectListItems.end(); ++id_itor) { - LLUUID task_id = *id_itor; - llinfos << task_id << llendl; - if (!list->isSelected(task_id)) + LLSD element = *id_itor; + if (!list->isSelected(element["id"].asUUID())) { - llinfos << "not selected" << llendl; // Selected only continue; } - llinfos << "selected" << llendl; + + if(element["local_id"].asInteger() != local_id) + { + // Not the parcel we are looking for + continue; + } + if (start_message) { msg->newMessageFast(_PREHASH_ParcelReturnObjects); @@ -744,285 +1027,74 @@ void LLPanelScriptLimitsRegionMemory::returnObjects() msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ParcelData); - msg->addS32Fast(_PREHASH_LocalID, -1); // Whole region - msg->addS32Fast(_PREHASH_ReturnType, RT_LIST); + msg->addS32Fast(_PREHASH_LocalID, element["local_id"].asInteger()); + msg->addU32Fast(_PREHASH_ReturnType, RT_LIST); start_message = false; - llinfos << "start message" << llendl; } msg->nextBlockFast(_PREHASH_TaskIDs); - msg->addUUIDFast(_PREHASH_TaskID, task_id); - llinfos << "added id" << llendl; + msg->addUUIDFast(_PREHASH_TaskID, element["id"].asUUID()); if (msg->isSendFullFast(_PREHASH_TaskIDs)) { msg->sendReliable(region->getHost()); start_message = true; - llinfos << "sent 1" << llendl; } } if (!start_message) { msg->sendReliable(region->getHost()); - llinfos << "sent 2" << llendl; - }*/ + } } -// static -void LLPanelScriptLimitsRegionMemory::onClickReturn(void* userdata) +void LLPanelScriptLimitsRegionMemory::returnObjects() { -/* llinfos << "LLPanelRegionGeneralInfo::onClickReturn" << llendl; - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); - if(instance) + if(!mContent.has("parcels")) { - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - panel->returnObjects(); return; } - else - { - llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << llendl; -// std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); -// panel->childSetValue("loading_text", LLSD(msg_waiting)); - return; - }*/ -} - -///---------------------------------------------------------------------------- -// URLs Panel -///---------------------------------------------------------------------------- - -void LLPanelScriptLimitsRegionURLs::setRegionDetails(LLSD content) -{ - LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); - - S32 number_parcels = content["parcels"].size(); - - LLStringUtil::format_map_t args_parcels; - args_parcels["[PARCELS]"] = llformat ("%d", number_parcels); - std::string msg_parcels = LLTrans::getString("ScriptLimitsParcelsOwned", args_parcels); - childSetValue("parcels_listed", LLSD(msg_parcels)); - - S32 total_objects = 0; - S32 total_size = 0; + S32 number_parcels = mContent["parcels"].size(); + + // a message per parcel containing all objects to be returned from that parcel for(S32 i = 0; i < number_parcels; i++) { - std::string parcel_name = content["parcels"][i]["name"].asString(); - llinfos << parcel_name << llendl; - - S32 number_objects = content["parcels"][i]["objects"].size(); - for(S32 j = 0; j < number_objects; j++) + S32 local_id = 0; + if(mContent["parcels"][i].has("local_id")) { - if(content["parcels"][i]["objects"][j]["resources"].has("urls")) - { - S32 size = content["parcels"][i]["objects"][j]["resources"]["urls"].asInteger(); - total_size += size; - - std::string name_buf = content["parcels"][i]["objects"][j]["name"].asString(); - LLUUID task_id = content["parcels"][i]["objects"][j]["id"].asUUID(); - LLUUID owner_id = content["parcels"][i]["objects"][j]["owner_id"].asUUID(); - - std::string owner_buf; - gCacheName->getFullName(owner_id, owner_buf); //dont care if this fails as the memory tab will request and fill the field - - LLSD element; - - element["id"] = task_id; - element["columns"][0]["column"] = "urls"; - element["columns"][0]["value"] = llformat("%d", size); - element["columns"][0]["font"] = "SANSSERIF"; - element["columns"][1]["column"] = "name"; - element["columns"][1]["value"] = name_buf; - element["columns"][1]["font"] = "SANSSERIF"; - element["columns"][2]["column"] = "owner"; - element["columns"][2]["value"] = owner_buf; - element["columns"][2]["font"] = "SANSSERIF"; - element["columns"][3]["column"] = "location"; - element["columns"][3]["value"] = parcel_name; - element["columns"][3]["font"] = "SANSSERIF"; - - list->addElement(element); - mObjectListItems.push_back(element); - total_objects++; - } + local_id = mContent["parcels"][i]["local_id"].asInteger(); + returnObjectsFromParcel(local_id); } } - - mParcelURLsUsed =total_size; - mGotParcelURLsUsed = TRUE; - populateParcelURLsText(); -} - -void LLPanelScriptLimitsRegionURLs::populateParcelURLsText() -{ - if(mGotParcelURLsUsed && mGotParcelURLsMax) - { - -#ifdef USE_SIMPLE_SUMMARY - LLStringUtil::format_map_t args_parcel_urls; - args_parcel_urls["[COUNT]"] = llformat ("%d", mParcelURLsUsed); - std::string msg_parcel_urls = LLTrans::getString("ScriptLimitsURLsUsedSimple", args_parcel_urls); - childSetValue("urls_used", LLSD(msg_parcel_urls)); -#else - S32 parcel_urls_available = mParcelURLsMax - mParcelURLsUsed; - LLStringUtil::format_map_t args_parcel_urls; - args_parcel_urls["[COUNT]"] = llformat ("%d", mParcelURLsUsed); - args_parcel_urls["[MAX]"] = llformat ("%d", mParcelURLsMax); - args_parcel_urls["[AVAILABLE]"] = llformat ("%d", parcel_urls_available); - std::string msg_parcel_urls = LLTrans::getString("ScriptLimitsURLsUsed", args_parcel_urls); - childSetValue("urls_used", LLSD(msg_parcel_urls)); -#endif - - childSetValue("loading_text", LLSD(std::string(""))); - - } + onClickRefresh(NULL); } -void LLPanelScriptLimitsRegionURLs::setRegionSummary(LLSD content) -{ - if(content["summary"]["available"][0]["type"].asString() == std::string("urls")) - { - mParcelURLsMax = content["summary"]["available"][0]["amount"].asInteger(); - mGotParcelURLsMax = TRUE; - } - else if(content["summary"]["available"][1]["type"].asString() == std::string("urls")) - { - mParcelURLsMax = content["summary"]["available"][1]["amount"].asInteger(); - mGotParcelURLsMax = TRUE; - } - else - { - llinfos << "summary contains no url info" << llendl; - return; - } -/* - currently this is broken on the server, so we get this value from the details section - and update via populateParcelMemoryText() when both sets of information have been returned - - when the sim is fixed this should be used instead: - if(content["summary"]["used"][0]["type"].asString() == std::string("urls")) - { - mParcelURLsUsed = content["summary"]["used"][0]["amount"].asInteger(); - mGotParcelURLsUsed = TRUE; - } - else if(content["summary"]["used"][1]["type"].asString() == std::string("urls")) - { - mParcelURLsUsed = content["summary"]["used"][1]["amount"].asInteger(); - mGotParcelURLsUsed = TRUE; - } - else - { - //ERROR!!! - return; - }*/ - - populateParcelURLsText(); -} - -BOOL LLPanelScriptLimitsRegionURLs::postBuild() -{ - childSetAction("refresh_list_btn", onClickRefresh, this); - childSetAction("highlight_btn", onClickHighlight, this); - childSetAction("return_btn", onClickReturn, this); - - std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestWaiting"); - childSetValue("loading_text", LLSD(msg_waiting)); - return FALSE; -} - -void LLPanelScriptLimitsRegionURLs::clearList() -{ - LLCtrlListInterface *list = childGetListInterface("scripts_list"); - - if (list) - { - list->operateOnAll(LLCtrlListInterface::OP_DELETE); - } - - mGotParcelURLsUsed = FALSE; - mGotParcelURLsMax = FALSE; - - LLStringUtil::format_map_t args_parcel_urls; - std::string msg_empty_string(""); - childSetValue("urls_used", LLSD(msg_empty_string)); - childSetValue("parcels_listed", LLSD(msg_empty_string)); - - mObjectListItems.clear(); -} - -// static -void LLPanelScriptLimitsRegionURLs::onClickRefresh(void* userdata) -{ - llinfos << "Refresh clicked" << llendl; - - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); - if(instance) - { - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - // use the memory panel to re-request all the info - panel_memory->clearList(); - - LLPanelScriptLimitsRegionURLs* panel_urls = (LLPanelScriptLimitsRegionURLs*)tab->getChild<LLPanel>("script_limits_region_urls_panel"); - // but the urls panel to clear itself - panel_urls->clearList(); - - panel_memory->StartRequestChain(); - return; - } - else - { - llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after refresh button clicked" << llendl; - return; - } -} // static -void LLPanelScriptLimitsRegionURLs::onClickHighlight(void* userdata) +void LLPanelScriptLimitsRegionMemory::onClickReturn(void* userdata) { -/* llinfos << "Highlight clicked" << llendl; + llinfos << "LLPanelRegionGeneralInfo::onClickReturn" << llendl; LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); if(instance) { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - // use the beacon function from the memory panel - panel->showBeacon(); + if(tab) + { + LLPanelScriptLimitsRegionMemory* panel = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); + if(panel) + { + panel->returnObjects(); + } + } return; } else { llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << llendl; -// std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); -// panel->childSetValue("loading_text", LLSD(msg_waiting)); - return; - }*/ -} - -// static -void LLPanelScriptLimitsRegionURLs::onClickReturn(void* userdata) -{ -/* llinfos << "Return clicked" << llendl; - LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); - if(instance) - { - LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); - LLPanelScriptLimitsRegionMemory* panel = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); - // use the return function from the memory panel - panel->returnObjects(); return; } - else - { - llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << llendl; -// std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); -// panel->childSetValue("loading_text", LLSD(msg_waiting)); - return; - }*/ } ///---------------------------------------------------------------------------- @@ -1047,6 +1119,12 @@ BOOL LLPanelScriptLimitsAttachment::requestAttachmentDetails() void LLPanelScriptLimitsAttachment::setAttachmentDetails(LLSD content) { LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); + + if(!list) + { + return; + } + S32 number_attachments = content["attachments"].size(); for(int i = 0; i < number_attachments; i++) @@ -1096,6 +1174,8 @@ void LLPanelScriptLimitsAttachment::setAttachmentDetails(LLSD content) list->addElement(element); } } + + setAttachmentSummary(content); childSetValue("loading_text", LLSD(std::string(""))); } @@ -1122,6 +1202,69 @@ void LLPanelScriptLimitsAttachment::clearList() childSetValue("loading_text", LLSD(msg_waiting)); } +void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content) +{ + if(content["summary"]["used"][0]["type"].asString() == std::string("memory")) + { + mAttachmentMemoryUsed = content["summary"]["used"][0]["amount"].asInteger() / SIZE_OF_ONE_KB; + mAttachmentMemoryMax = content["summary"]["available"][0]["amount"].asInteger() / SIZE_OF_ONE_KB; + mGotAttachmentMemoryUsed = TRUE; + } + else if(content["summary"]["used"][1]["type"].asString() == std::string("memory")) + { + mAttachmentMemoryUsed = content["summary"]["used"][1]["amount"].asInteger() / SIZE_OF_ONE_KB; + mAttachmentMemoryMax = content["summary"]["available"][1]["amount"].asInteger() / SIZE_OF_ONE_KB; + mGotAttachmentMemoryUsed = TRUE; + } + else + { + llinfos << "attachment details don't contain memory summary info" << llendl; + return; + } + + if(content["summary"]["used"][0]["type"].asString() == std::string("urls")) + { + mAttachmentURLsUsed = content["summary"]["used"][0]["amount"].asInteger(); + mAttachmentURLsMax = content["summary"]["available"][0]["amount"].asInteger(); + mGotAttachmentURLsUsed = TRUE; + } + else if(content["summary"]["used"][1]["type"].asString() == std::string("urls")) + { + mAttachmentURLsUsed = content["summary"]["used"][1]["amount"].asInteger(); + mAttachmentURLsMax = content["summary"]["available"][1]["amount"].asInteger(); + mGotAttachmentURLsUsed = TRUE; + } + else + { + llinfos << "attachment details don't contain urls summary info" << llendl; + return; + } + + if((mAttachmentMemoryUsed >= 0) && (mAttachmentMemoryMax >= 0)) + { + S32 attachment_memory_available = mAttachmentMemoryMax - mAttachmentMemoryUsed; + + LLStringUtil::format_map_t args_attachment_memory; + args_attachment_memory["[COUNT]"] = llformat ("%d", mAttachmentMemoryUsed); + args_attachment_memory["[MAX]"] = llformat ("%d", mAttachmentMemoryMax); + args_attachment_memory["[AVAILABLE]"] = llformat ("%d", attachment_memory_available); + std::string msg_attachment_memory = LLTrans::getString("ScriptLimitsMemoryUsed", args_attachment_memory); + childSetValue("memory_used", LLSD(msg_attachment_memory)); + } + + if((mAttachmentURLsUsed >= 0) && (mAttachmentURLsMax >= 0)) + { + S32 attachment_urls_available = mAttachmentURLsMax - mAttachmentURLsUsed; + + LLStringUtil::format_map_t args_attachment_urls; + args_attachment_urls["[COUNT]"] = llformat ("%d", mAttachmentURLsUsed); + args_attachment_urls["[MAX]"] = llformat ("%d", mAttachmentURLsMax); + args_attachment_urls["[AVAILABLE]"] = llformat ("%d", attachment_urls_available); + std::string msg_attachment_urls = LLTrans::getString("ScriptLimitsURLsUsed", args_attachment_urls); + childSetValue("urls_used", LLSD(msg_attachment_urls)); + } +} + // static void LLPanelScriptLimitsAttachment::onClickRefresh(void* userdata) { |