llfloaterland.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include <sstream>
00035 
00036 #include "llfloaterland.h"
00037 
00038 #include "llcachename.h"
00039 #include "llfocusmgr.h"
00040 #include "llparcel.h"
00041 #include "message.h"
00042 
00043 #include "llagent.h"
00044 #include "llfloateravatarpicker.h"
00045 #include "llbutton.h"
00046 #include "llcheckboxctrl.h"
00047 #include "llradiogroup.h"
00048 #include "llcombobox.h"
00049 #include "llfloaterauction.h"
00050 #include "llfloateravatarinfo.h"
00051 #include "llfloatergroups.h"
00052 #include "llfloatergroupinfo.h"
00053 #include "lllineeditor.h"
00054 #include "llnamelistctrl.h"
00055 #include "llnotify.h"
00056 #include "llradiogroup.h"
00057 #include "llscrolllistctrl.h"
00058 #include "llselectmgr.h"
00059 #include "llspinctrl.h"
00060 #include "lltabcontainer.h"
00061 #include "lltextbox.h"
00062 #include "lltexturectrl.h"
00063 #include "lluiconstants.h"
00064 #include "llvieweruictrlfactory.h"
00065 #include "llviewermessage.h"
00066 #include "llviewerparcelmgr.h"
00067 #include "llviewerregion.h"
00068 #include "llviewerstats.h"
00069 #include "llviewertexteditor.h"
00070 #include "llviewerwindow.h"
00071 #include "llmediaengine.h"
00072 #include "llviewercontrol.h"
00073 #include "roles_constants.h"
00074 
00075 static const char OWNER_ONLINE[]        = "0";
00076 static const char OWNER_OFFLINE[]       = "1";
00077 static const char OWNER_GROUP[]         = "2";
00078 
00079 // constants used in callbacks below - syntactic sugar.
00080 static const BOOL BUY_GROUP_LAND = TRUE;
00081 static const BOOL BUY_PERSONAL_LAND = FALSE;
00082 
00083 // Values for the parcel voice settings radio group
00084 enum
00085 {
00086         kRadioVoiceChatEstate = 0,
00087         kRadioVoiceChatPrivate = 1,
00088         kRadioVoiceChatDisable = 2
00089 };
00090 
00091 // Statics
00092 LLFloaterLand* LLFloaterLand::sInstance = NULL;
00093 LLParcelSelectionObserver* LLFloaterLand::sObserver = NULL;
00094 S32 LLFloaterLand::sLastTab = 0;
00095 
00096 LLViewHandle LLPanelLandGeneral::sBuyPassDialogHandle;
00097 
00098 // Local classes
00099 class LLParcelSelectionObserver : public LLParcelObserver
00100 {
00101 public:
00102         virtual void changed() { LLFloaterLand::refreshAll(); }
00103 };
00104 
00105 //---------------------------------------------------------------------------
00106 // LLFloaterLand
00107 //---------------------------------------------------------------------------
00108 
00109 void send_parcel_select_objects(S32 parcel_local_id, S32 return_type,
00110                                                                 uuid_list_t* return_ids = NULL)
00111 {
00112         LLMessageSystem *msg = gMessageSystem;
00113 
00114         LLViewerRegion* region = gParcelMgr->getSelectionRegion();
00115         if (!region) return;
00116 
00117         // Since new highlight will be coming in, drop any highlights
00118         // that exist right now.
00119         gSelectMgr->unhighlightAll();
00120 
00121         msg->newMessageFast(_PREHASH_ParcelSelectObjects);
00122         msg->nextBlockFast(_PREHASH_AgentData);
00123         msg->addUUIDFast(_PREHASH_AgentID,      gAgent.getID());
00124         msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
00125         msg->nextBlockFast(_PREHASH_ParcelData);
00126         msg->addS32Fast(_PREHASH_LocalID, parcel_local_id);
00127         msg->addS32Fast(_PREHASH_ReturnType, return_type);
00128 
00129         // Throw all return ids into the packet.
00130         // TODO: Check for too many ids.
00131         if (return_ids)
00132         {
00133                 uuid_list_t::iterator end = return_ids->end();
00134                 for (uuid_list_t::iterator it = return_ids->begin();
00135                          it != end;
00136                          ++it)
00137                 {
00138                         msg->nextBlockFast(_PREHASH_ReturnIDs);
00139                         msg->addUUIDFast(_PREHASH_ReturnID, (*it));
00140                 }
00141         }
00142         else
00143         {
00144                 // Put in a null key so that the message is complete.
00145                 msg->nextBlockFast(_PREHASH_ReturnIDs);
00146                 msg->addUUIDFast(_PREHASH_ReturnID, LLUUID::null);
00147         }
00148 
00149         msg->sendReliable(region->getHost());
00150 }
00151 
00152 
00153 // static
00154 void LLFloaterLand::show()
00155 {
00156         if (!sInstance)
00157         {
00158                 sInstance = new LLFloaterLand();
00159 
00160                 // Select tab from last view
00161                 sInstance->mTabLand->selectTab(sLastTab);
00162 
00163                 sObserver = new LLParcelSelectionObserver();
00164                 gParcelMgr->addObserver( sObserver );
00165         }
00166 
00167         sInstance->open();      /*Flawfinder: ignore*/
00168 
00169         // Done automatically when the selected parcel's properties arrive
00170         // (and hence we have the local id).
00171         // gParcelMgr->sendParcelAccessListRequest(AL_ACCESS | AL_BAN | AL_RENTER);
00172 
00173         sInstance->mParcel = gParcelMgr->getFloatingParcelSelection();
00174         
00175         // Refresh even if not over a region so we don't get an
00176         // uninitialized dialog. The dialog is 0-region aware.
00177         sInstance->refresh();
00178 }
00179 
00180 //static
00181 LLPanelLandObjects* LLFloaterLand::getCurrentPanelLandObjects()
00182 {
00183         if (!sInstance)
00184         {
00185                 return NULL;
00186         }
00187 
00188         return sInstance->mPanelObjects;
00189 }
00190 
00191 //static
00192 LLPanelLandCovenant* LLFloaterLand::getCurrentPanelLandCovenant()
00193 {
00194         if (!sInstance)
00195         {
00196                 return NULL;
00197         }
00198 
00199         return sInstance->mPanelCovenant;
00200 }
00201 
00202 // static
00203 void LLFloaterLand::refreshAll()
00204 {
00205         if (sInstance)
00206         {
00207                 sInstance->refresh();
00208         }
00209 }
00210 
00211 // virtual
00212 void LLFloaterLand::onClose(bool app_quitting)
00213 {
00214         gParcelMgr->removeObserver( sObserver );
00215         delete sObserver;
00216         sObserver = NULL;
00217 
00218         // Might have been showing owned objects
00219         gSelectMgr->unhighlightAll();
00220 
00221         // Save which panel we had open
00222         sLastTab = mTabLand->getCurrentPanelIndex();
00223 
00224         destroy();
00225 }
00226 
00227 
00228 LLFloaterLand::LLFloaterLand()
00229 :       LLFloater("floaterland", "FloaterLandRect5", "About Land")
00230 {
00231 
00232 
00233         std::map<LLString, LLCallbackMap> factory_map;
00234         factory_map["land_general_panel"] = LLCallbackMap(createPanelLandGeneral, this);
00235 
00236         
00237         factory_map["land_covenant_panel"] = LLCallbackMap(createPanelLandCovenant, this);
00238         factory_map["land_objects_panel"] = LLCallbackMap(createPanelLandObjects, this);
00239         factory_map["land_options_panel"] = LLCallbackMap(createPanelLandOptions, this);
00240         factory_map["land_media_panel"] =       LLCallbackMap(createPanelLandMedia, this);
00241         factory_map["land_access_panel"] =      LLCallbackMap(createPanelLandAccess, this);
00242         factory_map["land_ban_panel"] =         LLCallbackMap(createPanelLandBan, this);
00243 
00244         gUICtrlFactory->buildFloater(this, "floater_about_land.xml", &factory_map);
00245 
00246 
00247         LLTabContainerCommon* tab = LLUICtrlFactory::getTabContainerByName(this, "landtab");
00248 
00249         mTabLand = (LLTabContainer*) tab;
00250 
00251 
00252         if (tab)
00253         {
00254                 tab->selectTab(sLastTab);
00255         }
00256 }
00257 
00258 
00259 // virtual
00260 LLFloaterLand::~LLFloaterLand()
00261 {
00262         sInstance = NULL;
00263 }
00264 
00265 
00266 // public
00267 void LLFloaterLand::refresh()
00268 {
00269         mPanelGeneral->refresh();
00270         mPanelObjects->refresh();
00271         mPanelOptions->refresh();
00272         mPanelMedia->refresh();
00273         mPanelAccess->refresh();
00274         mPanelBan->refresh();
00275 }
00276 
00277 
00278 
00279 void* LLFloaterLand::createPanelLandGeneral(void* data)
00280 {
00281         LLFloaterLand* self = (LLFloaterLand*)data;
00282         self->mPanelGeneral = new LLPanelLandGeneral(self->mParcel);
00283         return self->mPanelGeneral;
00284 }
00285 
00286 // static
00287 
00288 
00289 void* LLFloaterLand::createPanelLandCovenant(void* data)
00290 {
00291         LLFloaterLand* self = (LLFloaterLand*)data;
00292         self->mPanelCovenant = new LLPanelLandCovenant(self->mParcel);
00293         return self->mPanelCovenant;
00294 }
00295 
00296 
00297 // static
00298 void* LLFloaterLand::createPanelLandObjects(void* data)
00299 {
00300         LLFloaterLand* self = (LLFloaterLand*)data;
00301         self->mPanelObjects = new LLPanelLandObjects(self->mParcel);
00302         return self->mPanelObjects;
00303 }
00304 
00305 // static
00306 void* LLFloaterLand::createPanelLandOptions(void* data)
00307 {
00308         LLFloaterLand* self = (LLFloaterLand*)data;
00309         self->mPanelOptions = new LLPanelLandOptions(self->mParcel);
00310         return self->mPanelOptions;
00311 }
00312 
00313 // static
00314 void* LLFloaterLand::createPanelLandMedia(void* data)
00315 {
00316         LLFloaterLand* self = (LLFloaterLand*)data;
00317         self->mPanelMedia = new LLPanelLandMedia(self->mParcel);
00318         return self->mPanelMedia;
00319 }
00320 
00321 // static
00322 void* LLFloaterLand::createPanelLandAccess(void* data)
00323 {
00324         LLFloaterLand* self = (LLFloaterLand*)data;
00325         self->mPanelAccess = new LLPanelLandAccess(self->mParcel);
00326         return self->mPanelAccess;
00327 }
00328 
00329 // static
00330 void* LLFloaterLand::createPanelLandBan(void* data)
00331 {
00332         LLFloaterLand* self = (LLFloaterLand*)data;
00333         self->mPanelBan = new LLPanelLandBan(self->mParcel);
00334         return self->mPanelBan;
00335 }
00336 
00337 
00338 //---------------------------------------------------------------------------
00339 // LLPanelLandGeneral
00340 //---------------------------------------------------------------------------
00341 
00342 
00343 LLPanelLandGeneral::LLPanelLandGeneral(LLParcelSelectionHandle& parcel)
00344 :       LLPanel("land_general_panel"),
00345         mUncheckedSell(FALSE),
00346         mParcel(parcel)
00347 {
00348 }
00349 
00350 BOOL LLPanelLandGeneral::postBuild()
00351 {
00352 
00353         mEditName = LLUICtrlFactory::getLineEditorByName(this, "Name");
00354         mEditName->setCommitCallback(onCommitAny);      
00355         childSetPrevalidate("Name", LLLineEditor::prevalidatePrintableNotPipe);
00356         childSetUserData("Name", this);
00357 
00358         mEditDesc = LLUICtrlFactory::getTextEditorByName(this, "Description");
00359         mEditDesc->setCommitOnFocusLost(TRUE);
00360         mEditDesc->setCommitCallback(onCommitAny);      
00361         childSetPrevalidate("Description", LLLineEditor::prevalidatePrintableNotPipe);
00362         childSetUserData("Description", this);
00363 
00364         
00365         mTextSalePending = LLUICtrlFactory::getTextBoxByName(this, "SalePending");
00366         mTextOwnerLabel = LLUICtrlFactory::getTextBoxByName(this, "Owner:");
00367         mTextOwner = LLUICtrlFactory::getTextBoxByName(this, "OwnerText");
00368 
00369         
00370         mBtnProfile = LLUICtrlFactory::getButtonByName(this, "Profile...");
00371         mBtnProfile->setClickedCallback(onClickProfile, this);
00372 
00373         
00374         mTextGroupLabel = LLUICtrlFactory::getTextBoxByName(this, "Group:");
00375         mTextGroup = LLUICtrlFactory::getTextBoxByName(this, "GroupText");
00376 
00377         
00378         mBtnSetGroup = LLUICtrlFactory::getButtonByName(this, "Set...");
00379         mBtnSetGroup->setClickedCallback(onClickSetGroup, this);
00380 
00381         
00382 
00383         mCheckDeedToGroup = LLUICtrlFactory::getCheckBoxByName(this, "check deed");
00384         childSetCommitCallback("check deed", onCommitAny, this);
00385 
00386         
00387         mBtnDeedToGroup = LLUICtrlFactory::getButtonByName(this, "Deed...");
00388         mBtnDeedToGroup->setClickedCallback(onClickDeed, this);
00389 
00390         
00391         mCheckContributeWithDeed = LLUICtrlFactory::getCheckBoxByName(this, "check contrib");
00392         childSetCommitCallback("check contrib", onCommitAny, this);
00393 
00394         
00395         
00396         mSaleInfoNotForSale = LLUICtrlFactory::getTextBoxByName(this, "Not for sale.");
00397         
00398         mSaleInfoForSale1 = LLUICtrlFactory::getTextBoxByName(this, "For Sale: Price L$[PRICE].");
00399 
00400         
00401         mBtnSellLand = LLUICtrlFactory::getButtonByName(this, "Sell Land...");
00402         mBtnSellLand->setClickedCallback(onClickSellLand, this);
00403         
00404         mSaleInfoForSale2 = LLUICtrlFactory::getTextBoxByName(this, "For sale to");
00405         
00406         mSaleInfoForSaleObjects = LLUICtrlFactory::getTextBoxByName(this, "Sell with landowners objects in parcel.");
00407         
00408         mSaleInfoForSaleNoObjects = LLUICtrlFactory::getTextBoxByName(this, "Selling with no objects in parcel.");
00409 
00410         
00411         mBtnStopSellLand = LLUICtrlFactory::getButtonByName(this, "Cancel Land Sale");
00412         mBtnStopSellLand->setClickedCallback(onClickStopSellLand, this);
00413 
00414         
00415         mTextClaimDateLabel = LLUICtrlFactory::getTextBoxByName(this, "Claimed:");
00416         mTextClaimDate = LLUICtrlFactory::getTextBoxByName(this, "DateClaimText");
00417 
00418         
00419         mTextPriceLabel = LLUICtrlFactory::getTextBoxByName(this, "PriceLabel");
00420         mTextPrice = LLUICtrlFactory::getTextBoxByName(this, "PriceText");
00421 
00422         
00423         mTextDwell = LLUICtrlFactory::getTextBoxByName(this, "DwellText");
00424 
00425         
00426         mBtnBuyLand = LLUICtrlFactory::getButtonByName(this, "Buy Land...");
00427         mBtnBuyLand->setClickedCallback(onClickBuyLand, (void*)&BUY_PERSONAL_LAND);
00428         
00429         mBtnBuyGroupLand = LLUICtrlFactory::getButtonByName(this, "Buy For Group...");
00430         mBtnBuyGroupLand->setClickedCallback(onClickBuyLand, (void*)&BUY_GROUP_LAND);
00431         
00432         
00433         mBtnBuyPass = LLUICtrlFactory::getButtonByName(this, "Buy Pass...");
00434         mBtnBuyPass->setClickedCallback(onClickBuyPass, this);
00435 
00436         mBtnReleaseLand = LLUICtrlFactory::getButtonByName(this, "Abandon Land...");
00437         mBtnReleaseLand->setClickedCallback(onClickRelease, NULL);
00438 
00439         mBtnReclaimLand = LLUICtrlFactory::getButtonByName(this, "Reclaim Land...");
00440         mBtnReclaimLand->setClickedCallback(onClickReclaim, NULL);
00441         
00442         mBtnStartAuction = LLUICtrlFactory::getButtonByName(this, "Linden Sale...");
00443         mBtnStartAuction->setClickedCallback(onClickStartAuction, NULL);
00444 
00445         return TRUE;
00446 }
00447 
00448 
00449 // virtual
00450 LLPanelLandGeneral::~LLPanelLandGeneral()
00451 { }
00452 
00453 
00454 // public
00455 void LLPanelLandGeneral::refresh()
00456 {
00457         mBtnStartAuction->setVisible(gAgent.isGodlike());
00458 
00459         LLParcel *parcel = mParcel->getParcel();
00460         bool region_owner = false;
00461         LLViewerRegion* regionp = gParcelMgr->getSelectionRegion();
00462         if(regionp && (regionp->getOwner() == gAgent.getID()))
00463         {
00464                 region_owner = true;
00465                 mBtnReleaseLand->setVisible(FALSE);
00466                 mBtnReclaimLand->setVisible(TRUE);
00467         }
00468         else
00469         {
00470                 mBtnReleaseLand->setVisible(TRUE);
00471                 mBtnReclaimLand->setVisible(FALSE);
00472         }
00473         if (!parcel)
00474         {
00475                 // nothing selected, disable panel
00476                 mEditName->setEnabled(FALSE);
00477                 mEditName->setText(LLString::null);
00478 
00479                 mEditDesc->setEnabled(FALSE);
00480                 mEditDesc->setText(LLString::null);
00481 
00482                 mTextSalePending->setText(LLString::null);
00483                 mTextSalePending->setEnabled(FALSE);
00484 
00485                 mBtnDeedToGroup->setEnabled(FALSE);
00486                 mBtnSetGroup->setEnabled(FALSE);
00487                 mBtnStartAuction->setEnabled(FALSE);
00488 
00489                 mCheckDeedToGroup       ->set(FALSE);
00490                 mCheckDeedToGroup       ->setEnabled(FALSE);
00491                 mCheckContributeWithDeed->set(FALSE);
00492                 mCheckContributeWithDeed->setEnabled(FALSE);
00493 
00494                 mTextOwner->setText(LLString::null);
00495                 mBtnProfile->setLabel(childGetText("profile_text"));
00496                 mBtnProfile->setEnabled(FALSE);
00497 
00498                 mTextClaimDate->setText(LLString::null);
00499                 mTextGroup->setText(LLString::null);
00500                 mTextPrice->setText(LLString::null);
00501 
00502                 mSaleInfoForSale1->setVisible(FALSE);
00503                 mSaleInfoForSale2->setVisible(FALSE);
00504                 mSaleInfoForSaleObjects->setVisible(FALSE);
00505                 mSaleInfoForSaleNoObjects->setVisible(FALSE);
00506                 mSaleInfoNotForSale->setVisible(FALSE);
00507                 mBtnSellLand->setVisible(FALSE);
00508                 mBtnStopSellLand->setVisible(FALSE);
00509 
00510                 mTextPriceLabel->setText(LLString::null);
00511                 mTextDwell->setText(LLString::null);
00512 
00513                 mBtnBuyLand->setEnabled(FALSE);
00514                 mBtnBuyGroupLand->setEnabled(FALSE);
00515                 mBtnReleaseLand->setEnabled(FALSE);
00516                 mBtnReclaimLand->setEnabled(FALSE);
00517                 mBtnBuyPass->setEnabled(FALSE);
00518         }
00519         else
00520         {
00521                 // something selected, hooray!
00522                 BOOL is_leased = (LLParcel::OS_LEASED == parcel->getOwnershipStatus());
00523                 BOOL region_xfer = FALSE;
00524                 if(regionp
00525                    && !(regionp->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL))
00526                 {
00527                         region_xfer = TRUE;
00528                 }
00529 
00530                 // estate owner/manager cannot edit other parts of the parcel
00531                 BOOL estate_manager_sellable = !parcel->getAuctionID()
00532                                                                                 && gAgent.canManageEstate()
00533                                                                                 // estate manager/owner can only sell parcels owned by estate owner
00534                                                                                 && regionp
00535                                                                                 && (parcel->getOwnerID() == regionp->getOwner());
00536                 BOOL owner_sellable = region_xfer && !parcel->getAuctionID()
00537                                                         && LLViewerParcelMgr::isParcelModifiableByAgent(
00538                                                                                 parcel, GP_LAND_SET_SALE_INFO);
00539                 BOOL can_be_sold = owner_sellable || estate_manager_sellable;
00540 
00541                 const LLUUID &owner_id = parcel->getOwnerID();
00542                 BOOL is_public = parcel->isPublic();
00543 
00544                 // Is it owned?
00545                 if (is_public)
00546                 {
00547                         mTextSalePending->setText(LLString::null);
00548                         mTextSalePending->setEnabled(FALSE);
00549                         mTextOwner->setText(childGetText("public_text"));
00550                         mTextOwner->setEnabled(FALSE);
00551                         mBtnProfile->setEnabled(FALSE);
00552                         mTextClaimDate->setText(LLString::null);
00553                         mTextClaimDate->setEnabled(FALSE);
00554                         mTextGroup->setText(childGetText("none_text"));
00555                         mTextGroup->setEnabled(FALSE);
00556                         mBtnStartAuction->setEnabled(FALSE);
00557                 }
00558                 else
00559                 {
00560                         if(!is_leased && (owner_id == gAgent.getID()))
00561                         {
00562                                 mTextSalePending->setText(childGetText("need_tier_to_modify"));
00563                                 mTextSalePending->setEnabled(TRUE);
00564                         }
00565                         else if(parcel->getAuctionID())
00566                         {
00567                                 mTextSalePending->setText(childGetText("auction_id_text"));
00568                                 mTextSalePending->setTextArg("[ID]", llformat("%u", parcel->getAuctionID()));
00569                                 mTextSalePending->setEnabled(TRUE);
00570                         }
00571                         else
00572                         {
00573                                 // not the owner, or it is leased
00574                                 mTextSalePending->setText(LLString::null);
00575                                 mTextSalePending->setEnabled(FALSE);
00576                         }
00577                         //refreshNames();
00578                         mTextOwner->setEnabled(TRUE);
00579 
00580                         // We support both group and personal profiles
00581                         mBtnProfile->setEnabled(TRUE);
00582 
00583                         if (parcel->getGroupID().isNull())
00584                         {
00585                                 // Not group owned, so "Profile"
00586                                 mBtnProfile->setLabel(childGetText("profile_text"));
00587 
00588                                 mTextGroup->setText(childGetText("none_text"));
00589                                 mTextGroup->setEnabled(FALSE);
00590                         }
00591                         else
00592                         {
00593                                 // Group owned, so "Info"
00594                                 mBtnProfile->setLabel(childGetText("info_text"));
00595 
00596                                 //mTextGroup->setText("HIPPOS!");//parcel->getGroupName());
00597                                 mTextGroup->setEnabled(TRUE);
00598                         }
00599 
00600                         // Display claim date
00601                         // *TODO:Localize (Time format may need Translating)
00602                         time_t claim_date = parcel->getClaimDate();
00603                         char time_buf[TIME_STR_LENGTH];         /*Flawfinder: ignore*/
00604                         mTextClaimDate->setText(LLString(formatted_time(claim_date, time_buf)));
00605                         mTextClaimDate->setEnabled(is_leased);
00606 
00607                         BOOL enable_auction = (gAgent.getGodLevel() >= GOD_LIAISON)
00608                                                                   && (owner_id == GOVERNOR_LINDEN_ID)
00609                                                                   && (parcel->getAuctionID() == 0);
00610                         mBtnStartAuction->setEnabled(enable_auction);
00611                 }
00612 
00613                 // Display options
00614                 BOOL can_edit_identity = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_IDENTITY);
00615                 mEditName->setEnabled(can_edit_identity);
00616                 mEditDesc->setEnabled(can_edit_identity);
00617 
00618                 BOOL can_edit_agent_only = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_NO_POWERS);
00619                 mBtnSetGroup->setEnabled(can_edit_agent_only && !parcel->getIsGroupOwned());
00620 
00621                 const LLUUID& group_id = parcel->getGroupID();
00622 
00623                 // Can only allow deeding if you own it and it's got a group.
00624                 BOOL enable_deed = (owner_id == gAgent.getID()
00625                                                         && group_id.notNull()
00626                                                         && gAgent.isInGroup(group_id));
00627                 // You don't need special powers to allow your object to
00628                 // be deeded to the group.
00629                 mCheckDeedToGroup->setEnabled(enable_deed);
00630                 mCheckDeedToGroup->set( parcel->getAllowDeedToGroup() );
00631                 mCheckContributeWithDeed->setEnabled(enable_deed && parcel->getAllowDeedToGroup());
00632                 mCheckContributeWithDeed->set(parcel->getContributeWithDeed());
00633 
00634                 // Actually doing the deeding requires you to have GP_LAND_DEED
00635                 // powers in the group.
00636                 BOOL can_deed = gAgent.hasPowerInGroup(group_id, GP_LAND_DEED);
00637                 mBtnDeedToGroup->setEnabled(   parcel->getAllowDeedToGroup()
00638                                                                         && group_id.notNull()
00639                                                                         && can_deed
00640                                                                         && !parcel->getIsGroupOwned()
00641                                                                         );
00642 
00643                 mEditName->setText( parcel->getName() );
00644                 mEditDesc->setText( parcel->getDesc() );
00645 
00646                 BOOL for_sale = parcel->getForSale();
00647                                 
00648                 mBtnSellLand->setVisible(FALSE);
00649                 mBtnStopSellLand->setVisible(FALSE);
00650                 
00651                 if (for_sale)
00652                 {
00653                         mSaleInfoForSale1->setVisible(TRUE);
00654                         mSaleInfoForSale2->setVisible(TRUE);
00655                         if (parcel->getSellWithObjects())
00656                         {
00657                                 mSaleInfoForSaleObjects->setVisible(TRUE);
00658                                 mSaleInfoForSaleNoObjects->setVisible(FALSE);
00659                         }
00660                         else
00661                         {
00662                                 mSaleInfoForSaleObjects->setVisible(FALSE);
00663                                 mSaleInfoForSaleNoObjects->setVisible(TRUE);
00664                         }
00665                         mSaleInfoNotForSale->setVisible(FALSE);
00666                         mSaleInfoForSale1->setTextArg("[PRICE]", llformat("%d", parcel->getSalePrice()));
00667                         if (can_be_sold)
00668                         {
00669                                 mBtnStopSellLand->setVisible(TRUE);
00670                         }
00671                 }
00672                 else
00673                 {
00674                         mSaleInfoForSale1->setVisible(FALSE);
00675                         mSaleInfoForSale2->setVisible(FALSE);
00676                         mSaleInfoForSaleObjects->setVisible(FALSE);
00677                         mSaleInfoForSaleNoObjects->setVisible(FALSE);
00678                         mSaleInfoNotForSale->setVisible(TRUE);
00679                         if (can_be_sold)
00680                         {
00681                                 mBtnSellLand->setVisible(TRUE);
00682                         }
00683                 }
00684                 
00685                 refreshNames();
00686 
00687                 mBtnBuyLand->setEnabled(
00688                         gParcelMgr->canAgentBuyParcel(parcel, false));
00689                 mBtnBuyGroupLand->setEnabled(
00690                         gParcelMgr->canAgentBuyParcel(parcel, true));
00691 
00692                 // show pricing information
00693                 S32 area;
00694                 S32 claim_price;
00695                 S32 rent_price;
00696                 F32 dwell;
00697                 gParcelMgr->getDisplayInfo(&area,
00698                                                                    &claim_price,
00699                                                                    &rent_price,
00700                                                                    &for_sale,
00701                                                                    &dwell);
00702 
00703                 // Area
00704                 LLUIString price = childGetText("area_size_text");
00705                 price.setArg("[AREA]", llformat("%d",area));    
00706                 mTextPriceLabel->setText(childGetText("area_text"));
00707                 mTextPrice->setText(price.getString());
00708                 
00709                 mTextDwell->setText(llformat("%.0f", dwell));
00710 
00711                 if(region_owner)
00712                 {
00713                         mBtnReclaimLand->setEnabled(
00714                                 !is_public && (parcel->getOwnerID() != gAgent.getID()));
00715                 }
00716                 else
00717                 {
00718                         BOOL is_owner_release = LLViewerParcelMgr::isParcelOwnedByAgent(parcel, GP_LAND_RELEASE);
00719                         BOOL is_manager_release = (gAgent.canManageEstate() && 
00720                                                                         regionp && 
00721                                                                         (parcel->getOwnerID() != regionp->getOwner()));
00722                         BOOL can_release = is_owner_release || is_manager_release;
00723                         mBtnReleaseLand->setEnabled( can_release );
00724                 }
00725 
00726                 BOOL use_pass = parcel->getParcelFlag(PF_USE_PASS_LIST) && !gParcelMgr->isCollisionBanned();;
00727                 mBtnBuyPass->setEnabled(use_pass);
00728         }
00729 }
00730 
00731 // public
00732 void LLPanelLandGeneral::refreshNames()
00733 {
00734         LLParcel *parcel = mParcel->getParcel();
00735         if (!parcel)
00736         {
00737                 mTextOwner->setText(LLString::null);
00738                 return;
00739         }
00740 
00741         LLString owner;
00742         if (parcel->getIsGroupOwned())
00743         {
00744                 owner = childGetText("group_owned_text");
00745         }
00746         else
00747         {
00748                 // Figure out the owner's name
00749                 char owner_first[MAX_STRING];   /*Flawfinder: ignore*/
00750                 char owner_last[MAX_STRING];    /*Flawfinder: ignore*/
00751                 gCacheName->getName(parcel->getOwnerID(), owner_first, owner_last);
00752                 owner = llformat("%s %s", owner_first, owner_last);
00753         }
00754 
00755         if(LLParcel::OS_LEASE_PENDING == parcel->getOwnershipStatus())
00756         {
00757                 owner += childGetText("sale_pending_text");
00758         }
00759         mTextOwner->setText(owner);
00760 
00761         LLString group;
00762         if(!parcel->getGroupID().isNull())
00763         {
00764                 char buffer[MAX_STRING];        /*Flawfinder: ignore*/
00765                 gCacheName->getGroupName(parcel->getGroupID(), buffer);
00766                 group = buffer;
00767         }
00768         mTextGroup->setText(group);
00769 
00770         const LLUUID& auth_buyer_id = parcel->getAuthorizedBuyerID();
00771         if(auth_buyer_id.notNull())
00772         {
00773                 LLString name;
00774                 char firstname[MAX_STRING];             /*Flawfinder: ignore*/
00775                 char lastname[MAX_STRING];              /*Flawfinder: ignore*/
00776                 gCacheName->getName(auth_buyer_id, firstname, lastname);
00777                 name.assign(firstname);
00778                 name.append(" ");
00779                 name.append(lastname);
00780 
00781                 mSaleInfoForSale2->setTextArg("[BUYER]", name);
00782         }
00783         else
00784         {
00785                 mSaleInfoForSale2->setTextArg("[BUYER]", childGetText("anyone"));
00786         }
00787 }
00788 
00789 
00790 // virtual
00791 void LLPanelLandGeneral::draw()
00792 {
00793         refreshNames();
00794         LLPanel::draw();
00795 }
00796 
00797 // static
00798 void LLPanelLandGeneral::onClickSetGroup(void* userdata)
00799 {
00800         LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)userdata;
00801         LLFloaterGroupPicker* fg;
00802 
00803         LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
00804 
00805         fg = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
00806         fg->setSelectCallback( cbGroupID, userdata );
00807 
00808         if (parent_floater)
00809         {
00810                 LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, fg);
00811                 fg->setOrigin(new_rect.mLeft, new_rect.mBottom);
00812                 parent_floater->addDependentFloater(fg);
00813         }
00814 }
00815 
00816 // static
00817 void LLPanelLandGeneral::onClickProfile(void* data)
00818 {
00819         LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
00820         LLParcel* parcel = panelp->mParcel->getParcel();
00821         if (!parcel) return;
00822 
00823         if (parcel->getIsGroupOwned())
00824         {
00825                 const LLUUID& group_id = parcel->getGroupID();
00826                 LLFloaterGroupInfo::showFromUUID(group_id);
00827         }
00828         else
00829         {
00830                 const LLUUID& avatar_id = parcel->getOwnerID();
00831                 LLFloaterAvatarInfo::showFromObject(avatar_id);
00832         }
00833 }
00834 
00835 // static
00836 void LLPanelLandGeneral::cbGroupID(LLUUID group_id, void* userdata)
00837 {
00838         LLPanelLandGeneral* self = (LLPanelLandGeneral*)userdata;
00839         self->setGroup(group_id);
00840 }
00841 
00842 // public
00843 void LLPanelLandGeneral::setGroup(const LLUUID& group_id)
00844 {
00845         LLParcel* parcel = mParcel->getParcel();
00846         if (!parcel) return;
00847 
00848         // Set parcel properties and send message
00849         parcel->setGroupID(group_id);
00850         //parcel->setGroupName(group_name);
00851         //mTextGroup->setText(group_name);
00852 
00853         // Send update
00854         gParcelMgr->sendParcelPropertiesUpdate(parcel);
00855 
00856         // Update UI
00857         refresh();
00858 }
00859 
00860 // static
00861 void LLPanelLandGeneral::onClickBuyLand(void* data)
00862 {
00863         BOOL* for_group = (BOOL*)data;
00864         gParcelMgr->startBuyLand(*for_group);
00865 }
00866 
00867 BOOL LLPanelLandGeneral::enableDeedToGroup(void* data)
00868 {
00869         LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
00870         LLParcel* parcel = panelp->mParcel->getParcel();
00871         return (parcel != NULL) && (parcel->getParcelFlag(PF_ALLOW_DEED_TO_GROUP));
00872 }
00873 
00874 // static
00875 void LLPanelLandGeneral::onClickDeed(void*)
00876 {
00877         //LLParcel* parcel = mParcel->getParcel();
00878         //if (parcel)
00879         //{
00880         gParcelMgr->startDeedLandToGroup();
00881         //}
00882 }
00883 
00884 // static
00885 void LLPanelLandGeneral::onClickRelease(void*)
00886 {
00887         gParcelMgr->startReleaseLand();
00888 }
00889 
00890 // static
00891 void LLPanelLandGeneral::onClickReclaim(void*)
00892 {
00893         lldebugs << "LLPanelLandGeneral::onClickReclaim()" << llendl;
00894         gParcelMgr->reclaimParcel();
00895 }
00896 
00897 // static
00898 BOOL LLPanelLandGeneral::enableBuyPass(void* data)
00899 {
00900         LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
00901         LLParcel* parcel = panelp != NULL ? panelp->mParcel->getParcel() : gParcelMgr->getParcelSelection()->getParcel();
00902         return (parcel != NULL) && (parcel->getParcelFlag(PF_USE_PASS_LIST) && !gParcelMgr->isCollisionBanned());
00903 }
00904 
00905 
00906 // static
00907 void LLPanelLandGeneral::onClickBuyPass(void* data)
00908 {
00909         LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
00910         LLParcel* parcel = panelp != NULL ? panelp->mParcel->getParcel() : gParcelMgr->getParcelSelection()->getParcel();
00911 
00912         if (!parcel) return;
00913 
00914         S32 pass_price = parcel->getPassPrice();
00915         LLString parcel_name = parcel->getName();
00916         F32 pass_hours = parcel->getPassHours();
00917 
00918         char cost[256], time[256];              /*Flawfinder: ignore*/
00919         snprintf(cost, sizeof(cost), "%d", pass_price);         /* Flawfinder: ignore */
00920         snprintf(time, sizeof(time), "%.2f", pass_hours);                       /* Flawfinder: ignore */
00921 
00922         LLStringBase<char>::format_map_t args;
00923         args["[COST]"] = cost;
00924         args["[PARCEL_NAME]"] = parcel_name;
00925         args["[TIME]"] = time;
00926         
00927         sBuyPassDialogHandle = gViewerWindow->alertXml("LandBuyPass", args, cbBuyPass)->getHandle();
00928 }
00929 
00930 // static
00931 void LLPanelLandGeneral::onClickStartAuction(void* data)
00932 {
00933         LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
00934         LLParcel* parcelp = panelp->mParcel->getParcel();
00935         if(parcelp)
00936         {
00937                 if(parcelp->getForSale())
00938                 {
00939                         gViewerWindow->alertXml("CannotStartAuctionAlreadForSale");
00940                 }
00941                 else
00942                 {
00943                         LLFloaterAuction::show();
00944                 }
00945         }
00946 }
00947 
00948 // static
00949 void LLPanelLandGeneral::cbBuyPass(S32 option, void* data)
00950 {
00951         if (0 == option)
00952         {
00953                 // User clicked OK
00954                 gParcelMgr->buyPass();
00955         }
00956 }
00957 
00958 //static 
00959 BOOL LLPanelLandGeneral::buyPassDialogVisible()
00960 {
00961         return LLFloater::getFloaterByHandle(sBuyPassDialogHandle) != NULL;
00962 }
00963 
00964 // static
00965 void LLPanelLandGeneral::onCommitAny(LLUICtrl *ctrl, void *userdata)
00966 {
00967         LLPanelLandGeneral *panelp = (LLPanelLandGeneral *)userdata;
00968 
00969         LLParcel* parcel = panelp->mParcel->getParcel();
00970         if (!parcel)
00971         {
00972                 return;
00973         }
00974 
00975         // Extract data from UI
00976         std::string name = panelp->mEditName->getText();
00977         std::string desc = panelp->mEditDesc->getText();
00978 
00979         // Valid data from UI
00980 
00981         // Stuff data into selected parcel
00982         parcel->setName(name.c_str());
00983         parcel->setDesc(desc.c_str());
00984 
00985         BOOL allow_deed_to_group= panelp->mCheckDeedToGroup->get();
00986         BOOL contribute_with_deed = panelp->mCheckContributeWithDeed->get();
00987 
00988         parcel->setParcelFlag(PF_ALLOW_DEED_TO_GROUP, allow_deed_to_group);
00989         parcel->setContributeWithDeed(contribute_with_deed);
00990 
00991         // Send update to server
00992         gParcelMgr->sendParcelPropertiesUpdate( parcel );
00993 
00994         // Might have changed properties, so let's redraw!
00995         panelp->refresh();
00996 }
00997 
00998 // static
00999 void LLPanelLandGeneral::onClickSellLand(void* data)
01000 {
01001         gParcelMgr->startSellLand();
01002 }
01003 
01004 // static
01005 void LLPanelLandGeneral::onClickStopSellLand(void* data)
01006 {
01007         LLPanelLandGeneral* panelp = (LLPanelLandGeneral*)data;
01008         LLParcel* parcel = panelp->mParcel->getParcel();
01009 
01010         parcel->setParcelFlag(PF_FOR_SALE, FALSE);
01011         parcel->setSalePrice(0);
01012         parcel->setAuthorizedBuyerID(LLUUID::null);
01013 
01014         gParcelMgr->sendParcelPropertiesUpdate(parcel);
01015 }
01016 
01017 //---------------------------------------------------------------------------
01018 // LLPanelLandObjects
01019 //---------------------------------------------------------------------------
01020 LLPanelLandObjects::LLPanelLandObjects(LLParcelSelectionHandle& parcel)
01021 :       LLPanel("land_objects_panel"), mParcel(parcel)
01022 {
01023 }
01024 
01025 
01026 
01027 BOOL LLPanelLandObjects::postBuild()
01028 {
01029         
01030         mFirstReply = TRUE;
01031         mParcelObjectBonus = LLUICtrlFactory::getTextBoxByName(this, "parcel_object_bonus");
01032         mSWTotalObjects = LLUICtrlFactory::getTextBoxByName(this, "objects_available");
01033         mObjectContribution = LLUICtrlFactory::getTextBoxByName(this, "object_contrib_text");
01034         mTotalObjects = LLUICtrlFactory::getTextBoxByName(this, "total_objects_text");
01035         mOwnerObjects = LLUICtrlFactory::getTextBoxByName(this, "owner_objects_text");
01036         
01037         mBtnShowOwnerObjects = LLUICtrlFactory::getButtonByName(this, "ShowOwner");
01038         mBtnShowOwnerObjects->setClickedCallback(onClickShowOwnerObjects, this);
01039         
01040         mBtnReturnOwnerObjects = LLUICtrlFactory::getButtonByName(this, "ReturnOwner...");
01041         mBtnReturnOwnerObjects->setClickedCallback(onClickReturnOwnerObjects, this);
01042         
01043         mGroupObjects = LLUICtrlFactory::getTextBoxByName(this, "group_objects_text");
01044         mBtnShowGroupObjects = LLUICtrlFactory::getButtonByName(this, "ShowGroup");
01045         mBtnShowGroupObjects->setClickedCallback(onClickShowGroupObjects, this);
01046         
01047         mBtnReturnGroupObjects = LLUICtrlFactory::getButtonByName(this, "ReturnGroup...");
01048         mBtnReturnGroupObjects->setClickedCallback(onClickReturnGroupObjects, this);
01049         
01050         mOtherObjects = LLUICtrlFactory::getTextBoxByName(this, "other_objects_text");
01051         mBtnShowOtherObjects = LLUICtrlFactory::getButtonByName(this, "ShowOther");
01052         mBtnShowOtherObjects->setClickedCallback(onClickShowOtherObjects, this);
01053         
01054         mBtnReturnOtherObjects = LLUICtrlFactory::getButtonByName(this, "ReturnOther...");
01055         mBtnReturnOtherObjects->setClickedCallback(onClickReturnOtherObjects, this);
01056         
01057         mSelectedObjects = LLUICtrlFactory::getTextBoxByName(this, "selected_objects_text");
01058         mCleanOtherObjectsTime = LLUICtrlFactory::getLineEditorByName(this, "clean other time");
01059         mCleanOtherObjectsTime->setFocusLostCallback(onLostFocus);      
01060         childSetPrevalidate("clean other time", LLLineEditor::prevalidateNonNegativeS32);
01061         childSetUserData("clean other time", this);
01062         
01063         mBtnRefresh = LLUICtrlFactory::getButtonByName(this, "Refresh List");
01064         mBtnRefresh->setClickedCallback(onClickRefresh, this);
01065         
01066         mBtnReturnOwnerList = LLUICtrlFactory::getButtonByName(this, "Return objects...");
01067         mBtnReturnOwnerList->setClickedCallback(onClickReturnOwnerList, this);
01068 
01069         LLUUID image_id;
01070 
01071         image_id.set( gViewerArt.getString("icon_avatar_online.tga") );
01072         mIconAvatarOnline = gImageList.getImage(image_id, MIPMAP_FALSE, TRUE);
01073         
01074         image_id.set( gViewerArt.getString("icon_avatar_offline.tga") );
01075         mIconAvatarOffline = gImageList.getImage(image_id, MIPMAP_FALSE, TRUE);
01076 
01077         image_id.set( gViewerArt.getString("icon_group.tga") );
01078         mIconGroup = gImageList.getImage(image_id, MIPMAP_FALSE, TRUE);
01079 
01080         mCurrentSortColumn = 3; // sort by number of objects by default.
01081         mCurrentSortAscending = FALSE;
01082 
01083         // Column widths for various columns
01084         const S32 SORTER_WIDTH          = 308;
01085         const S32 DESC_BTN_WIDTH        = 64;
01086         const S32 ICON_WIDTH            = 24;
01087         mColWidth[0] = ICON_WIDTH;      // type icon
01088         mColWidth[1] = -1;      // hidden type code
01089         mColWidth[2] = SORTER_WIDTH - mColWidth[0] - DESC_BTN_WIDTH;
01090         mColWidth[3] = DESC_BTN_WIDTH;                  // info
01091         mColWidth[4] = -1;                                              // type data 1
01092         mColWidth[5] = -1;
01093         mColWidth[6] = -1;      // type data 3
01094         mColWidth[7] = -1;      // type data 4
01095         mColWidth[8] = -1;      // type data 5
01096 
01097         // Adjust description for other widths
01098         S32 sum = 0;
01099         for (S32 i = 0; i < 8; i++)
01100         {
01101                 if (mColWidth[i] > 0)
01102                 {
01103                         sum += mColWidth[i];
01104                 }
01105         }
01106         mColWidth[8] = mRect.getWidth() - HPAD - sum - HPAD - HPAD;
01107 
01108         mBtnType = LLUICtrlFactory::getButtonByName(this, "Type");
01109         mBtnType->setClickedCallback(onClickType, this);
01110 
01111         mBtnName = LLUICtrlFactory::getButtonByName(this, "Name");
01112         mBtnName->setClickedCallback(onClickName, this);
01113 
01114         mBtnDescription = LLUICtrlFactory::getButtonByName(this, "Count");
01115         mBtnDescription->setClickedCallback(onClickDesc, this);
01116         
01117         mOwnerList = LLUICtrlFactory::getNameListByName(this, "owner list");
01118         childSetCommitCallback("owner list", onCommitList, this);
01119         mOwnerList->setDoubleClickCallback(onDoubleClickOwner);
01120 
01121         return TRUE;
01122 }
01123 
01124 
01125 
01126 
01127 // virtual
01128 LLPanelLandObjects::~LLPanelLandObjects()
01129 { }
01130 
01131 // static
01132 void LLPanelLandObjects::onDoubleClickOwner(void *userdata)
01133 {
01134         LLPanelLandObjects *self = (LLPanelLandObjects *)userdata;
01135 
01136         LLScrollListItem* item = self->mOwnerList->getFirstSelected();
01137         if (item)
01138         {
01139                 LLUUID owner_id = item->getUUID();
01140                 // Look up the selected name, for future dialog box use.
01141                 const LLScrollListCell* cell;
01142                 cell = item->getColumn(1);
01143                 if (!cell)
01144                 {
01145                         return;
01146                 }
01147                 // Is this a group?
01148                 BOOL is_group = cell->getText() == OWNER_GROUP;
01149                 if (is_group)
01150                 {
01151                         LLFloaterGroupInfo::showFromUUID(owner_id);
01152                 }
01153                 else
01154                 {
01155                         LLFloaterAvatarInfo::showFromDirectory(owner_id);
01156                 }
01157         }
01158 }
01159 
01160 // public
01161 void LLPanelLandObjects::refresh()
01162 {
01163         LLParcel *parcel = mParcel->getParcel();
01164 
01165         mBtnShowOwnerObjects->setEnabled(FALSE);
01166         mBtnShowGroupObjects->setEnabled(FALSE);
01167         mBtnShowOtherObjects->setEnabled(FALSE);
01168         mBtnReturnOwnerObjects->setEnabled(FALSE);
01169         mBtnReturnGroupObjects->setEnabled(FALSE);
01170         mBtnReturnOtherObjects->setEnabled(FALSE);
01171         mCleanOtherObjectsTime->setEnabled(FALSE);
01172         mBtnRefresh->                   setEnabled(FALSE);
01173         mBtnReturnOwnerList->   setEnabled(FALSE);
01174 
01175         mSelectedOwners.clear();
01176         mOwnerList->deleteAllItems();
01177         mOwnerList->setEnabled(FALSE);
01178 
01179         if (!parcel)
01180         {
01181                 mSWTotalObjects->setTextArg("[COUNT]", llformat("%d", 0));
01182                 mSWTotalObjects->setTextArg("[TOTAL]", llformat("%d", 0));
01183                 mSWTotalObjects->setTextArg("[AVAILABLE]", llformat("%d", 0));
01184                 mObjectContribution->setTextArg("[COUNT]", llformat("%d", 0));
01185                 mTotalObjects->setTextArg("[COUNT]", llformat("%d", 0));
01186                 mOwnerObjects->setTextArg("[COUNT]", llformat("%d", 0));
01187                 mGroupObjects->setTextArg("[COUNT]", llformat("%d", 0));
01188                 mOtherObjects->setTextArg("[COUNT]", llformat("%d", 0));
01189                 mSelectedObjects->setTextArg("[COUNT]", llformat("%d", 0));
01190         }
01191         else
01192         {
01193                 S32 sw_max = 0;
01194                 S32 sw_total = 0;
01195                 S32 max = 0;
01196                 S32 total = 0;
01197                 S32 owned = 0;
01198                 S32 group = 0;
01199                 S32 other = 0;
01200                 S32 selected = 0;
01201                 F32 parcel_object_bonus = 0.f;
01202 
01203                 gParcelMgr->getPrimInfo(sw_max, sw_total, 
01204                                                                   max, total, owned, group, other, selected,
01205                                                                   parcel_object_bonus, mOtherTime);
01206 
01207                 // Can't have more than region max tasks, regardless of parcel
01208                 // object bonus factor.
01209                 LLViewerRegion* region = gParcelMgr->getSelectionRegion();
01210                 if (region)
01211                 {
01212                         S32 max_tasks_per_region = (S32)region->getMaxTasks();
01213                         sw_max = llmin(sw_max, max_tasks_per_region);
01214                         max = llmin(max, max_tasks_per_region);
01215                 }
01216 
01217                 if (parcel_object_bonus != 1.0f)
01218                 {
01219                         mParcelObjectBonus->setVisible(TRUE);
01220                         mParcelObjectBonus->setTextArg("[BONUS]", llformat("%.2f", parcel_object_bonus));
01221                 }
01222                 else
01223                 {
01224                         mParcelObjectBonus->setVisible(FALSE);
01225                 }
01226 
01227                 if (sw_total > sw_max)
01228                 {
01229                         mSWTotalObjects->setText(childGetText("objects_deleted_text"));
01230                         mSWTotalObjects->setTextArg("[DELETED]", llformat("%d", sw_total - sw_max));
01231                 }
01232                 else
01233                 {
01234                         mSWTotalObjects->setText(childGetText("objects_available_text"));
01235                         mSWTotalObjects->setTextArg("[AVAILABLE]", llformat("%d", sw_max - sw_total));
01236                 }
01237                 mSWTotalObjects->setTextArg("[COUNT]", llformat("%d", sw_total));
01238                 mSWTotalObjects->setTextArg("[MAX]", llformat("%d", sw_max));
01239 
01240                 mObjectContribution->setTextArg("[COUNT]", llformat("%d", max));
01241                 mTotalObjects->setTextArg("[COUNT]", llformat("%d", total));
01242                 mOwnerObjects->setTextArg("[COUNT]", llformat("%d", owned));
01243                 mGroupObjects->setTextArg("[COUNT]", llformat("%d", group));
01244                 mOtherObjects->setTextArg("[COUNT]", llformat("%d", other));
01245                 mSelectedObjects->setTextArg("[COUNT]", llformat("%d", selected));
01246                 mCleanOtherObjectsTime->setText(llformat("%d", mOtherTime));
01247 
01248                 BOOL can_return_owned = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_RETURN_GROUP_OWNED);
01249                 BOOL can_return_group_set = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_RETURN_GROUP_SET);
01250                 BOOL can_return_other = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_RETURN_NON_GROUP);
01251 
01252                 if (can_return_owned || can_return_group_set || can_return_other)
01253                 {
01254                         if (owned && can_return_owned)
01255                         {
01256                                 mBtnShowOwnerObjects->setEnabled(TRUE);
01257                                 mBtnReturnOwnerObjects->setEnabled(TRUE);
01258                         }
01259                         if (group && can_return_group_set)
01260                         {
01261                                 mBtnShowGroupObjects->setEnabled(TRUE);
01262                                 mBtnReturnGroupObjects->setEnabled(TRUE);
01263                         }
01264                         if (other && can_return_other)
01265                         {
01266                                 mBtnShowOtherObjects->setEnabled(TRUE);
01267                                 mBtnReturnOtherObjects->setEnabled(TRUE);
01268                         }
01269 
01270                         mCleanOtherObjectsTime->setEnabled(TRUE);
01271                         mBtnRefresh->setEnabled(TRUE);
01272                 }
01273         }
01274 }
01275 
01276 // virtual
01277 void LLPanelLandObjects::draw()
01278 {
01279         LLPanel::draw();
01280 }
01281 
01282 void send_other_clean_time_message(S32 parcel_local_id, S32 other_clean_time)
01283 {
01284         LLMessageSystem *msg = gMessageSystem;
01285 
01286         LLViewerRegion* region = gParcelMgr->getSelectionRegion();
01287         if (!region) return;
01288 
01289         msg->newMessageFast(_PREHASH_ParcelSetOtherCleanTime);
01290         msg->nextBlockFast(_PREHASH_AgentData);
01291         msg->addUUIDFast(_PREHASH_AgentID,      gAgent.getID());
01292         msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
01293         msg->nextBlockFast(_PREHASH_ParcelData);
01294         msg->addS32Fast(_PREHASH_LocalID, parcel_local_id);
01295         msg->addS32Fast(_PREHASH_OtherCleanTime, other_clean_time);
01296 
01297         msg->sendReliable(region->getHost());
01298 }
01299 
01300 void send_return_objects_message(S32 parcel_local_id, S32 return_type, 
01301                                                                  uuid_list_t* owner_ids = NULL)
01302 {
01303         LLMessageSystem *msg = gMessageSystem;
01304 
01305         LLViewerRegion* region = gParcelMgr->getSelectionRegion();
01306         if (!region) return;
01307 
01308         msg->newMessageFast(_PREHASH_ParcelReturnObjects);
01309         msg->nextBlockFast(_PREHASH_AgentData);
01310         msg->addUUIDFast(_PREHASH_AgentID,      gAgent.getID());
01311         msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
01312         msg->nextBlockFast(_PREHASH_ParcelData);
01313         msg->addS32Fast(_PREHASH_LocalID, parcel_local_id);
01314         msg->addU32Fast(_PREHASH_ReturnType, (U32) return_type);
01315 
01316         // Dummy task id, not used
01317         msg->nextBlock("TaskIDs");
01318         msg->addUUID("TaskID", LLUUID::null);
01319 
01320         // Throw all return ids into the packet.
01321         // TODO: Check for too many ids.
01322         if (owner_ids)
01323         {
01324                 uuid_list_t::iterator end = owner_ids->end();
01325                 for (uuid_list_t::iterator it = owner_ids->begin();
01326                          it != end;
01327                          ++it)
01328                 {
01329                         msg->nextBlockFast(_PREHASH_OwnerIDs);
01330                         msg->addUUIDFast(_PREHASH_OwnerID, (*it));
01331                 }
01332         }
01333         else
01334         {
01335                 msg->nextBlockFast(_PREHASH_OwnerIDs);
01336                 msg->addUUIDFast(_PREHASH_OwnerID, LLUUID::null);
01337         }
01338 
01339         msg->sendReliable(region->getHost());
01340 }
01341 
01342 // static
01343 void LLPanelLandObjects::callbackReturnOwnerObjects(S32 option, void* userdata)
01344 {
01345         LLPanelLandObjects      *lop = (LLPanelLandObjects *)userdata;
01346         LLParcel *parcel = lop->mParcel->getParcel();
01347         if (0 == option)
01348         {
01349                 if (parcel)
01350                 {
01351                         LLUUID owner_id = parcel->getOwnerID(); 
01352                         LLString::format_map_t args;
01353                         if (owner_id == gAgentID)
01354                         {
01355                                 LLNotifyBox::showXml("OwnedObjectsReturned");
01356                         }
01357                         else
01358                         {
01359                                 char first[DB_FIRST_NAME_BUF_SIZE];     /*Flawfinder: ignore*/
01360                                 char last[DB_LAST_NAME_BUF_SIZE];       /*Flawfinder: ignore*/
01361                                 gCacheName->getName(owner_id, first, last);
01362                                 args["[FIRST]"] = first;
01363                                 args["[LAST]"] = last;
01364                                 LLNotifyBox::showXml("OtherObjectsReturned", args);
01365                         }
01366                         send_return_objects_message(parcel->getLocalID(), RT_OWNER);
01367                 }
01368         }
01369 
01370         gSelectMgr->unhighlightAll();
01371         gParcelMgr->sendParcelPropertiesUpdate( parcel );
01372         lop->refresh();
01373 }
01374 
01375 // static
01376 void LLPanelLandObjects::callbackReturnGroupObjects(S32 option, void* userdata)
01377 {
01378         LLPanelLandObjects      *lop = (LLPanelLandObjects *)userdata;
01379         LLParcel *parcel = lop->mParcel->getParcel();
01380         if (0 == option)
01381         {
01382                 if (parcel)
01383                 {
01384                         char group_name[MAX_STRING];            /*Flawfinder: ignore*/
01385                         gCacheName->getGroupName(parcel->getGroupID(), group_name);
01386                         LLString::format_map_t args;
01387                         args["[GROUPNAME]"] = group_name;
01388                         LLNotifyBox::showXml("GroupObjectsReturned", args);
01389                         send_return_objects_message(parcel->getLocalID(), RT_GROUP);
01390                 }
01391         }
01392         gSelectMgr->unhighlightAll();
01393         gParcelMgr->sendParcelPropertiesUpdate( parcel );
01394         lop->refresh();
01395 }
01396 
01397 // static
01398 void LLPanelLandObjects::callbackReturnOtherObjects(S32 option, void* userdata)
01399 {
01400         LLPanelLandObjects      *lop = (LLPanelLandObjects *)userdata;
01401         LLParcel *parcel = lop->mParcel->getParcel();
01402         if (0 == option)
01403         {
01404                 if (parcel)
01405                 {
01406                         LLNotifyBox::showXml("UnOwnedObjectsReturned");
01407                         send_return_objects_message(parcel->getLocalID(), RT_OTHER);
01408                 }
01409         }
01410         gSelectMgr->unhighlightAll();
01411         gParcelMgr->sendParcelPropertiesUpdate( parcel );
01412         lop->refresh();
01413 }
01414 
01415 // static
01416 void LLPanelLandObjects::callbackReturnOwnerList(S32 option, void* userdata)
01417 {
01418         LLPanelLandObjects      *self = (LLPanelLandObjects *)userdata;
01419         LLParcel *parcel = self->mParcel->getParcel();
01420         if (0 == option)
01421         {
01422                 if (parcel)
01423                 {
01424                         // Make sure we have something selected.
01425                         uuid_list_t::iterator selected = self->mSelectedOwners.begin();
01426                         if (selected != self->mSelectedOwners.end())
01427                         {
01428                                 LLString::format_map_t args;
01429                                 if (self->mSelectedIsGroup)
01430                                 {
01431                                         args["[GROUPNAME]"] = self->mSelectedName;
01432                                         LLNotifyBox::showXml("GroupObjectsReturned", args);
01433                                 }
01434                                 else
01435                                 {
01436                                         args["[NAME]"] = self->mSelectedName;
01437                                         LLNotifyBox::showXml("OtherObjectsReturned2", args);
01438                                 }
01439 
01440                                 send_return_objects_message(parcel->getLocalID(), RT_LIST, &(self->mSelectedOwners));
01441                         }
01442                 }
01443         }
01444         gSelectMgr->unhighlightAll();
01445         gParcelMgr->sendParcelPropertiesUpdate( parcel );
01446         self->refresh();
01447 }
01448 
01449 
01450 // static
01451 void LLPanelLandObjects::onClickReturnOwnerList(void* userdata)
01452 {
01453         LLPanelLandObjects      *self = (LLPanelLandObjects *)userdata;
01454 
01455         S32 sw_max, sw_total;
01456         S32 max, total;
01457         S32 owned, group, other, selected;
01458         F32 parcel_object_bonus;
01459         S32 other_time;
01460 
01461         gParcelMgr->getPrimInfo(sw_max, sw_total, max, total, owned, group, other, selected, parcel_object_bonus, other_time);
01462 
01463         LLParcel* parcelp = self->mParcel->getParcel();
01464         if (!parcelp) return;
01465 
01466         // Make sure we have something selected.
01467         if (self->mSelectedOwners.empty())
01468         {
01469                 return;
01470         }
01471         //uuid_list_t::iterator selected_itr = self->mSelectedOwners.begin();
01472         //if (selected_itr == self->mSelectedOwners.end()) return;
01473 
01474         send_parcel_select_objects(parcelp->getLocalID(), RT_LIST, &(self->mSelectedOwners));
01475 
01476         LLStringBase<char>::format_map_t args;
01477         args["[NAME]"] = self->mSelectedName;
01478         args["[N]"] = llformat("%d",self->mSelectedCount);
01479         if (self->mSelectedIsGroup)
01480         {
01481                 gViewerWindow->alertXml("ReturnObjectsDeededToGroup", args, callbackReturnOwnerList, userdata); 
01482         }
01483         else 
01484         {
01485                 gViewerWindow->alertXml("ReturnObjectsOwnedByUser", args, callbackReturnOwnerList, userdata);   
01486         }
01487 }
01488 
01489 
01490 // static
01491 void LLPanelLandObjects::onClickRefresh(void* userdata)
01492 {
01493         LLPanelLandObjects *self = (LLPanelLandObjects*)userdata;
01494 
01495         LLMessageSystem *msg = gMessageSystem;
01496 
01497         LLParcel* parcel = self->mParcel->getParcel();
01498         if (!parcel) return;
01499 
01500         LLViewerRegion* region = gParcelMgr->getSelectionRegion();
01501         if (!region) return;
01502 
01503         // ready the list for results
01504         self->mOwnerList->deleteAllItems();
01505         self->mOwnerList->addSimpleItem("Searching...");
01506         self->mOwnerList->setEnabled(FALSE);
01507         self->mFirstReply = TRUE;
01508 
01509         // send the message
01510         msg->newMessageFast(_PREHASH_ParcelObjectOwnersRequest);
01511         msg->nextBlockFast(_PREHASH_AgentData);
01512         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
01513         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01514         msg->nextBlockFast(_PREHASH_ParcelData);
01515         msg->addS32Fast(_PREHASH_LocalID, parcel->getLocalID());
01516 
01517         msg->sendReliable(region->getHost());
01518 }
01519 
01520 // static
01521 void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, void **)
01522 {
01523         LLPanelLandObjects* self = LLFloaterLand::getCurrentPanelLandObjects();
01524 
01525         if (!self)
01526         {
01527                 llwarns << "Received message for nonexistent LLPanelLandObject"
01528                                 << llendl;
01529                 return;
01530         }
01531         
01532         const LLFontGL* FONT = LLFontGL::sSansSerif;
01533 
01534         // Extract all of the owners.
01535         S32 rows = msg->getNumberOfBlocksFast(_PREHASH_Data);
01536         //uuid_list_t return_ids;
01537         LLUUID  owner_id;
01538         BOOL    is_group_owned;
01539         S32             object_count;
01540         BOOL    is_online;
01541         char object_count_str[MAX_STRING];      /*Flawfinder: ignore*/
01542         //BOOL b_need_refresh = FALSE;
01543 
01544         // If we were waiting for the first reply, clear the "Searching..." text.
01545         if (self->mFirstReply)
01546         {
01547                 self->mOwnerList->deleteAllItems();
01548                 self->mFirstReply = FALSE;
01549         }
01550 
01551         for(S32 i = 0; i < rows; ++i)
01552         {
01553                 msg->getUUIDFast(_PREHASH_Data, _PREHASH_OwnerID,               owner_id,               i);
01554                 msg->getBOOLFast(_PREHASH_Data, _PREHASH_IsGroupOwned,  is_group_owned, i);
01555                 msg->getS32Fast (_PREHASH_Data, _PREHASH_Count,                 object_count,   i);
01556                 msg->getBOOLFast(_PREHASH_Data, _PREHASH_OnlineStatus,  is_online,              i);
01557 
01558                 if (owner_id.isNull())
01559                 {
01560                         continue;
01561                 }
01562 
01563                 LLScrollListItem *row = new LLScrollListItem( TRUE, NULL, owner_id);
01564                 if (is_group_owned)
01565                 {
01566                         row->addColumn(self->mIconGroup, self->mColWidth[0]);
01567                         row->addColumn(OWNER_GROUP, FONT, self->mColWidth[1]);
01568                 }
01569                 else if (is_online)
01570                 {
01571                         row->addColumn(self->mIconAvatarOnline, self->mColWidth[0]);
01572                         row->addColumn(OWNER_ONLINE, FONT, self->mColWidth[1]);
01573                 }
01574                 else  // offline
01575                 {
01576                         row->addColumn(self->mIconAvatarOffline, self->mColWidth[0]);
01577                         row->addColumn(OWNER_OFFLINE, FONT, self->mColWidth[1]);
01578                 }
01579                 // Placeholder for name.
01580                 row->addColumn(LLString::null, FONT, self->mColWidth[2]);
01581 
01582                 snprintf(object_count_str, sizeof(object_count_str), "%d", object_count);               /* Flawfinder: ignore */
01583                 row->addColumn(object_count_str, FONT, self->mColWidth[3]);
01584 
01585                 if (is_group_owned)
01586                 {
01587                         self->mOwnerList->addGroupNameItem(row, ADD_BOTTOM);
01588                 }
01589                 else
01590                 {
01591                         self->mOwnerList->addNameItem(row, ADD_BOTTOM);
01592                 }
01593 
01594                 lldebugs << "object owner " << owner_id << " (" << (is_group_owned ? "group" : "agent")
01595                                 << ") owns " << object_count << " objects." << llendl;
01596         }
01597         self->mOwnerList->sortByColumn(self->mCurrentSortColumn, self->mCurrentSortAscending);
01598 
01599         // check for no results
01600         if (0 == self->mOwnerList->getItemCount())
01601         {
01602                 self->mOwnerList->addSimpleItem("None found.");
01603         }
01604         else
01605         {
01606                 self->mOwnerList->setEnabled(TRUE);
01607         }
01608 }
01609 
01610 void LLPanelLandObjects::sortBtnCore(S32 column)
01611 {
01612         if (column == (S32)mCurrentSortColumn)  // is this already our sorted column?
01613         {
01614                 mCurrentSortAscending = !mCurrentSortAscending;
01615         }
01616         else  // default to ascending first time a column is clicked
01617         {
01618                 mCurrentSortColumn = column;
01619                 mCurrentSortAscending = TRUE;
01620         }
01621 
01622         mOwnerList->sortByColumn(column, mCurrentSortAscending);
01623 }
01624 
01625 // static
01626 void LLPanelLandObjects::onCommitList(LLUICtrl* ctrl, void* data)
01627 {
01628         LLPanelLandObjects* self = (LLPanelLandObjects*)data;
01629 
01630         if (FALSE == self->mOwnerList->getCanSelect())
01631         {
01632                 return;
01633         }
01634         LLScrollListItem *item = self->mOwnerList->getFirstSelected();
01635         if (item)
01636         {
01637                 // Look up the selected name, for future dialog box use.
01638                 const LLScrollListCell* cell;
01639                 cell = item->getColumn(1);
01640                 if (!cell)
01641                 {
01642                         return;
01643                 }
01644                 // Is this a group?
01645                 self->mSelectedIsGroup = cell->getText() == OWNER_GROUP;
01646                 cell = item->getColumn(2);
01647                 self->mSelectedName = cell->getText();
01648                 cell = item->getColumn(3);
01649                 self->mSelectedCount = atoi(cell->getText().c_str());
01650 
01651                 // Set the selection, and enable the return button.
01652                 self->mSelectedOwners.clear();
01653                 self->mSelectedOwners.insert(item->getUUID());
01654                 self->mBtnReturnOwnerList->setEnabled(TRUE);
01655 
01656                 // Highlight this user's objects
01657                 clickShowCore(self, RT_LIST, &(self->mSelectedOwners));
01658         }
01659 }
01660 
01661 // static
01662 void LLPanelLandObjects::onClickType(void* userdata)
01663 {
01664         // Sort on hidden type column
01665         LLPanelLandObjects* self = (LLPanelLandObjects*)userdata;
01666         self->sortBtnCore(1);
01667 }
01668 
01669 // static
01670 void LLPanelLandObjects::onClickDesc(void* userdata)
01671 {
01672         LLPanelLandObjects* self = (LLPanelLandObjects*)userdata;
01673         self->sortBtnCore(3);
01674 }
01675 
01676 // static
01677 void LLPanelLandObjects::onClickName(void* userdata)
01678 {
01679         LLPanelLandObjects* self = (LLPanelLandObjects*)userdata;
01680         self->sortBtnCore(2);
01681 }
01682 
01683 // static
01684 void LLPanelLandObjects::clickShowCore(LLPanelLandObjects* self, S32 return_type, uuid_list_t* list)
01685 {
01686         LLParcel* parcel = self->mParcel->getParcel();
01687         if (!parcel) return;
01688 
01689         send_parcel_select_objects(parcel->getLocalID(), return_type, list);
01690 }
01691 
01692 // static
01693 void LLPanelLandObjects::onClickShowOwnerObjects(void* userdata)
01694 {
01695         clickShowCore((LLPanelLandObjects*)userdata, RT_OWNER);
01696 }
01697 
01698 // static
01699 void LLPanelLandObjects::onClickShowGroupObjects(void* userdata)
01700 {
01701         clickShowCore((LLPanelLandObjects*)userdata, (RT_GROUP));
01702 }
01703 
01704 // static
01705 void LLPanelLandObjects::onClickShowOtherObjects(void* userdata)
01706 {
01707         clickShowCore((LLPanelLandObjects*)userdata, RT_OTHER);
01708 }
01709 
01710 // static
01711 void LLPanelLandObjects::onClickReturnOwnerObjects(void* userdata)
01712 {
01713         S32 sw_max=0, sw_total=0;
01714         S32 max=0, total=0;
01715         S32 owned=0, group=0, other=0, selected=0;
01716         F32 parcel_object_bonus=0;
01717         S32 other_time=0;
01718 
01719         gParcelMgr->getPrimInfo(sw_max, sw_total, max, total, owned, group, other, selected, parcel_object_bonus, other_time);
01720 
01721         LLPanelLandObjects* panelp = (LLPanelLandObjects*)userdata;
01722         LLParcel* parcel = panelp->mParcel->getParcel();
01723         if (!parcel) return;
01724 
01725         send_parcel_select_objects(parcel->getLocalID(), RT_OWNER);
01726 
01727         LLUUID owner_id = parcel->getOwnerID();
01728         
01729         LLStringBase<char>::format_map_t args;
01730         args["[N]"] = llformat("%d",owned);
01731 
01732         if (owner_id == gAgent.getID())
01733         {
01734                 gViewerWindow->alertXml("ReturnObjectsOwnedBySelf", args, callbackReturnOwnerObjects, userdata);
01735         }
01736         else
01737         {
01738                 char first[DB_FIRST_NAME_BUF_SIZE];     /*Flawfinder: ignore*/
01739                 char last[DB_LAST_NAME_BUF_SIZE];       /*Flawfinder: ignore*/
01740                 gCacheName->getName(owner_id, first, last);
01741                 std::string name = first;
01742                 name += " ";
01743                 name += last;
01744                 args["[NAME]"] = name;
01745                 gViewerWindow->alertXml("ReturnObjectsOwnedByUser", args, callbackReturnOwnerObjects, userdata);
01746         }
01747 }
01748 
01749 // static
01750 void LLPanelLandObjects::onClickReturnGroupObjects(void* userdata)
01751 {
01752         S32 sw_max=0, sw_total=0;
01753         S32 max=0, total=0;
01754         S32 owned=0, group=0, other=0, selected=0;
01755         F32 parcel_object_bonus=0;
01756         S32 other_time=0;
01757         
01758         gParcelMgr->getPrimInfo(sw_max, sw_total, max, total, owned, group, other, selected, parcel_object_bonus, other_time);
01759 
01760         LLPanelLandObjects* panelp = (LLPanelLandObjects*)userdata;
01761         LLParcel* parcel = panelp->mParcel->getParcel();
01762         if (!parcel) return;
01763 
01764         send_parcel_select_objects(parcel->getLocalID(), RT_GROUP);
01765 
01766         char group_name[MAX_STRING];    /*Flawfinder: ignore*/
01767         gCacheName->getGroupName(parcel->getGroupID(), group_name);
01768         
01769         LLStringBase<char>::format_map_t args;
01770         args["[NAME]"] = group_name;
01771         args["[N]"] = llformat("%d",group);
01772 
01773         // create and show confirmation textbox
01774         gViewerWindow->alertXml("ReturnObjectsDeededToGroup", args, callbackReturnGroupObjects, userdata);
01775 }
01776 
01777 // static
01778 void LLPanelLandObjects::onClickReturnOtherObjects(void* userdata)
01779 {
01780         S32 sw_max=0, sw_total=0;
01781         S32 max=0, total=0;
01782         S32 owned=0, group=0, other=0, selected=0;
01783         F32 parcel_object_bonus=0;
01784         S32 other_time=0;
01785 
01786         gParcelMgr->getPrimInfo(sw_max, sw_total, max, total, owned, group, other, selected, parcel_object_bonus, other_time);
01787 
01788         LLPanelLandObjects* panelp = (LLPanelLandObjects*)userdata;
01789         LLParcel* parcel = panelp->mParcel->getParcel();
01790         if (!parcel) return;
01791 
01792         send_parcel_select_objects(parcel->getLocalID(), RT_OTHER);
01793 
01794         LLStringBase<char>::format_map_t args;
01795         args["[N]"] = llformat("%d", other);
01796         
01797         if (parcel->getIsGroupOwned())
01798         {
01799                 char group_name[MAX_STRING];    /*Flawfinder: ignore*/
01800                 gCacheName->getGroupName(parcel->getGroupID(), group_name);
01801                 args["[NAME]"] = group_name;
01802 
01803                 gViewerWindow->alertXml("ReturnObjectsNotOwnedByGroup", args, callbackReturnOtherObjects, userdata);
01804         }
01805         else
01806         {
01807                 LLUUID owner_id = parcel->getOwnerID();
01808 
01809                 if (owner_id == gAgent.getID())
01810                 {
01811                         gViewerWindow->alertXml("ReturnObjectsNotOwnedBySelf", args, callbackReturnOtherObjects, userdata);
01812                 }
01813                 else
01814                 {
01815                         char first[DB_FIRST_NAME_BUF_SIZE];     /*Flawfinder: ignore*/
01816                         char last[DB_LAST_NAME_BUF_SIZE];       /*Flawfinder: ignore*/
01817                         gCacheName->getName(owner_id, first, last);
01818                         std::string name;
01819                         name += first;
01820                         name += " ";
01821                         name += last;
01822                         args["[NAME]"] = name;
01823 
01824                         gViewerWindow->alertXml("ReturnObjectsNotOwnedByUser", args, callbackReturnOtherObjects, userdata);
01825                 }
01826         }
01827 }
01828 
01829 // static
01830 void LLPanelLandObjects::onLostFocus(LLUICtrl *caller, void* user_data)
01831 {
01832         LLPanelLandObjects      *lop = (LLPanelLandObjects *)user_data;
01833         LLParcel* parcel = lop->mParcel->getParcel();
01834         if (parcel)
01835         {
01836                 lop->mOtherTime = atoi(lop->mCleanOtherObjectsTime->getText().c_str());
01837 
01838                 parcel->setCleanOtherTime(lop->mOtherTime);
01839                 send_other_clean_time_message(parcel->getLocalID(), lop->mOtherTime);
01840         }
01841 }
01842 
01843 
01844 //---------------------------------------------------------------------------
01845 // LLPanelLandOptions
01846 //---------------------------------------------------------------------------
01847 
01848 LLPanelLandOptions::LLPanelLandOptions(LLParcelSelectionHandle& parcel)
01849 :       LLPanel("land_options_panel"),
01850         mCheckEditObjects(NULL),
01851         mCheckEditGroupObjects(NULL),
01852         mCheckAllObjectEntry(NULL),
01853         mCheckGroupObjectEntry(NULL),
01854         mCheckEditLand(NULL),
01855         mCheckSafe(NULL),
01856         mCheckFly(NULL),
01857         mCheckGroupScripts(NULL),
01858         mCheckOtherScripts(NULL),
01859         mCheckLandmark(NULL),
01860         mCheckShowDirectory(NULL),
01861         mCategoryCombo(NULL),
01862         mLandingTypeCombo(NULL),
01863         mSnapshotCtrl(NULL),
01864         mLocationText(NULL),
01865         mSetBtn(NULL),
01866         mClearBtn(NULL),
01867         mMatureCtrl(NULL),
01868         mPushRestrictionCtrl(NULL),
01869         mPublishHelpButton(NULL),
01870         mParcel(parcel)
01871 {
01872 }
01873 
01874 
01875 BOOL LLPanelLandOptions::postBuild()
01876 {
01877 
01878         
01879         mCheckEditObjects = LLUICtrlFactory::getCheckBoxByName(this, "edit objects check");
01880         childSetCommitCallback("edit objects check", onCommitAny, this);
01881         
01882         mCheckEditGroupObjects = LLUICtrlFactory::getCheckBoxByName(this, "edit group objects check");
01883         childSetCommitCallback("edit group objects check", onCommitAny, this);
01884 
01885         mCheckAllObjectEntry = LLUICtrlFactory::getCheckBoxByName(this, "all object entry check");
01886         childSetCommitCallback("all object entry check", onCommitAny, this);
01887 
01888         mCheckGroupObjectEntry = LLUICtrlFactory::getCheckBoxByName(this, "group object entry check");
01889         childSetCommitCallback("group object entry check", onCommitAny, this);
01890         
01891         mCheckEditLand = LLUICtrlFactory::getCheckBoxByName(this, "edit land check");
01892         childSetCommitCallback("edit land check", onCommitAny, this);
01893 
01894         
01895         mCheckLandmark = LLUICtrlFactory::getCheckBoxByName(this, "check landmark");
01896         childSetCommitCallback("check landmark", onCommitAny, this);
01897 
01898         
01899         mCheckGroupScripts = LLUICtrlFactory::getCheckBoxByName(this, "check group scripts");
01900         childSetCommitCallback("check group scripts", onCommitAny, this);
01901 
01902         
01903         mCheckFly = LLUICtrlFactory::getCheckBoxByName(this, "check fly");
01904         childSetCommitCallback("check fly", onCommitAny, this);
01905 
01906         
01907         mCheckOtherScripts = LLUICtrlFactory::getCheckBoxByName(this, "check other scripts");
01908         childSetCommitCallback("check other scripts", onCommitAny, this);
01909 
01910         
01911         mCheckSafe = LLUICtrlFactory::getCheckBoxByName(this, "check safe");
01912         childSetCommitCallback("check safe", onCommitAny, this);
01913 
01914         
01915         mPushRestrictionCtrl = LLUICtrlFactory::getCheckBoxByName(this, "PushRestrictCheck");
01916         childSetCommitCallback("PushRestrictCheck", onCommitAny, this);
01917 
01918         mCheckShowDirectory = LLUICtrlFactory::getCheckBoxByName(this, "ShowDirectoryCheck");
01919         childSetCommitCallback("ShowDirectoryCheck", onCommitAny, this);
01920 
01921         
01922         mCategoryCombo = LLUICtrlFactory::getComboBoxByName(this, "land category");
01923         childSetCommitCallback("land category", onCommitAny, this);
01924 
01925         mMatureCtrl = LLUICtrlFactory::getCheckBoxByName(this, "MatureCheck");
01926         childSetCommitCallback("MatureCheck", onCommitAny, this);
01927         
01928         mPublishHelpButton = LLUICtrlFactory::getButtonByName(this, "?");
01929         mPublishHelpButton->setClickedCallback(onClickPublishHelp, this);
01930 
01931 
01932         if (gAgent.isTeen())
01933         {
01934                 // Disable these buttons if they are PG (Teen) users
01935                 mPublishHelpButton->setVisible(FALSE);
01936                 mPublishHelpButton->setEnabled(FALSE);
01937                 mMatureCtrl->setVisible(FALSE);
01938                 mMatureCtrl->setEnabled(FALSE);
01939         }
01940 
01941                 // Load up the category list
01942         //now in xml file
01943         /*
01944         S32 i;
01945         for (i = 0; i < LLParcel::C_COUNT; i++)
01946         {
01947                 LLParcel::ECategory cat = (LLParcel::ECategory)i;
01948 
01949                 // Selecting Linden Location when you're not a god
01950                 // is also blocked on the server.
01951                 BOOL enabled = TRUE;
01952                 if (!gAgent.isGodlike()
01953                         && i == LLParcel::C_LINDEN) 
01954                 {
01955                         enabled = FALSE;
01956                 }
01957 
01958                 mCategoryCombo->add( LLParcel::getCategoryUIString(cat), ADD_BOTTOM, enabled );
01959         }*/
01960 
01961         
01962         mSnapshotCtrl = LLUICtrlFactory::getTexturePickerByName(this, "snapshot_ctrl");
01963         if (mSnapshotCtrl)
01964         {
01965                 mSnapshotCtrl->setCommitCallback( onCommitAny );
01966                 mSnapshotCtrl->setCallbackUserData( this );
01967                 mSnapshotCtrl->setAllowNoTexture ( TRUE );
01968                 mSnapshotCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
01969                 mSnapshotCtrl->setNonImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
01970         }
01971         else
01972         {
01973                 llwarns << "LLUICtrlFactory::getTexturePickerByName() returned NULL for 'snapshot_ctrl'" << llendl;
01974         }
01975 
01976 
01977         mLocationText = LLUICtrlFactory::getTextBoxByName(this, "landing_point");
01978 
01979         mSetBtn = LLUICtrlFactory::getButtonByName(this, "Set");
01980         mSetBtn->setClickedCallback(onClickSet, this);
01981 
01982         
01983         mClearBtn = LLUICtrlFactory::getButtonByName(this, "Clear");
01984         mClearBtn->setClickedCallback(onClickClear, this);
01985 
01986 
01987         mLandingTypeCombo = LLUICtrlFactory::getComboBoxByName(this, "landing type");
01988         childSetCommitCallback("landing type", onCommitAny, this);
01989 
01990         return TRUE;
01991 }
01992 
01993 
01994 // virtual
01995 LLPanelLandOptions::~LLPanelLandOptions()
01996 { }
01997 
01998 
01999 // public
02000 void LLPanelLandOptions::refresh()
02001 {
02002         LLParcel *parcel = mParcel->getParcel();
02003         
02004         if (!parcel)
02005         {
02006                 mCheckEditObjects       ->set(FALSE);
02007                 mCheckEditObjects       ->setEnabled(FALSE);
02008 
02009                 mCheckEditGroupObjects  ->set(FALSE);
02010                 mCheckEditGroupObjects  ->setEnabled(FALSE);
02011 
02012                 mCheckAllObjectEntry    ->set(FALSE);
02013                 mCheckAllObjectEntry    ->setEnabled(FALSE);
02014 
02015                 mCheckGroupObjectEntry  ->set(FALSE);
02016                 mCheckGroupObjectEntry  ->setEnabled(FALSE);
02017 
02018                 mCheckEditLand          ->set(FALSE);
02019                 mCheckEditLand          ->setEnabled(FALSE);
02020 
02021                 mCheckSafe                      ->set(FALSE);
02022                 mCheckSafe                      ->setEnabled(FALSE);
02023 
02024                 mCheckFly                       ->set(FALSE);
02025                 mCheckFly                       ->setEnabled(FALSE);
02026 
02027                 mCheckLandmark          ->set(FALSE);
02028                 mCheckLandmark          ->setEnabled(FALSE);
02029 
02030                 mCheckGroupScripts      ->set(FALSE);
02031                 mCheckGroupScripts      ->setEnabled(FALSE);
02032 
02033                 mCheckOtherScripts      ->set(FALSE);
02034                 mCheckOtherScripts      ->setEnabled(FALSE);
02035 
02036                 mCheckShowDirectory     ->set(FALSE);
02037                 mCheckShowDirectory     ->setEnabled(FALSE);
02038 
02039                 mPushRestrictionCtrl->set(FALSE);
02040                 mPushRestrictionCtrl->setEnabled(FALSE);
02041 
02042                 // *TODO:Translate
02043                 const char* none_string = LLParcel::getCategoryUIString(LLParcel::C_NONE);
02044                 mCategoryCombo->setSimple(LLString(none_string));
02045                 mCategoryCombo->setEnabled(FALSE);
02046 
02047                 mLandingTypeCombo->setCurrentByIndex(0);
02048                 mLandingTypeCombo->setEnabled(FALSE);
02049 
02050                 mSnapshotCtrl->setImageAssetID(LLUUID::null);
02051                 mSnapshotCtrl->setEnabled(FALSE);
02052 
02053                 mLocationText->setTextArg("[LANDING]", childGetText("landing_point_none"));
02054                 mSetBtn->setEnabled(FALSE);
02055                 mClearBtn->setEnabled(FALSE);
02056 
02057                 mMatureCtrl->setEnabled(FALSE);
02058                 mPublishHelpButton->setEnabled(FALSE);
02059         }
02060         else
02061         {
02062                 // something selected, hooray!
02063 
02064                 // Display options
02065                 BOOL can_change_options = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS);
02066                 mCheckEditObjects       ->set( parcel->getAllowModify() );
02067                 mCheckEditObjects       ->setEnabled( can_change_options );
02068                 
02069                 mCheckEditGroupObjects  ->set( parcel->getAllowGroupModify() ||  parcel->getAllowModify());
02070                 mCheckEditGroupObjects  ->setEnabled( can_change_options && !parcel->getAllowModify() );                // If others edit is enabled, then this is explicitly enabled.
02071 
02072                 mCheckAllObjectEntry    ->set( parcel->getAllowAllObjectEntry() );
02073                 mCheckAllObjectEntry    ->setEnabled( can_change_options );
02074 
02075                 mCheckGroupObjectEntry  ->set( parcel->getAllowGroupObjectEntry() ||  parcel->getAllowAllObjectEntry());
02076                 mCheckGroupObjectEntry  ->setEnabled( can_change_options && !parcel->getAllowAllObjectEntry() );
02077 
02078                 BOOL can_change_terraform = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_EDIT);
02079                 mCheckEditLand          ->set( parcel->getAllowTerraform() );
02080                 mCheckEditLand          ->setEnabled( can_change_terraform );
02081 
02082                 mCheckSafe                      ->set( !parcel->getAllowDamage() );
02083                 mCheckSafe                      ->setEnabled( can_change_options );
02084 
02085                 mCheckFly                       ->set( parcel->getAllowFly() );
02086                 mCheckFly                       ->setEnabled( can_change_options );
02087 
02088                 mCheckLandmark          ->set( parcel->getAllowLandmark() );
02089                 mCheckLandmark          ->setEnabled( can_change_options );
02090 
02091                 mCheckGroupScripts      ->set( parcel->getAllowGroupScripts() || parcel->getAllowOtherScripts());
02092                 mCheckGroupScripts      ->setEnabled( can_change_options && !parcel->getAllowOtherScripts());
02093 
02094                 mCheckOtherScripts      ->set( parcel->getAllowOtherScripts() );
02095                 mCheckOtherScripts      ->setEnabled( can_change_options );
02096 
02097                 mPushRestrictionCtrl->set( parcel->getRestrictPushObject() );
02098                 if(parcel->getRegionPushOverride())
02099                 {
02100                         mPushRestrictionCtrl->setLabel(childGetText("push_restrict_region_text"));
02101                         mPushRestrictionCtrl->setEnabled(false);
02102                         mPushRestrictionCtrl->set(TRUE);
02103                 }
02104                 else
02105                 {
02106                         mPushRestrictionCtrl->setLabel(childGetText("push_restrict_text"));
02107                         mPushRestrictionCtrl->setEnabled(can_change_options);
02108                 }
02109 
02110                 BOOL can_change_identity = 
02111                         LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_IDENTITY);
02112                 // Set by string in case the order in UI doesn't match the order by index.
02113                 // *TODO:Translate
02114                 LLParcel::ECategory cat = parcel->getCategory();
02115                 const char* category_string = LLParcel::getCategoryUIString(cat);
02116                 mCategoryCombo->setSimple(LLString(category_string));
02117                 mCategoryCombo->setEnabled( can_change_identity );
02118 
02119                 BOOL can_change_landing_point = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, 
02120                                                                                                                 GP_LAND_SET_LANDING_POINT);
02121                 mLandingTypeCombo->setCurrentByIndex((S32)parcel->getLandingType());
02122                 mLandingTypeCombo->setEnabled( can_change_landing_point );
02123 
02124                 mSnapshotCtrl->setImageAssetID(parcel->getSnapshotID());
02125                 mSnapshotCtrl->setEnabled( can_change_identity );
02126 
02127                 LLVector3 pos = parcel->getUserLocation();
02128                 if (pos.isExactlyZero())
02129                 {
02130                         mLocationText->setTextArg("[LANDING]", childGetText("landing_point_none"));
02131                 }
02132                 else
02133                 {
02134                         mLocationText->setTextArg("[LANDING]",llformat("%d, %d, %d",
02135                                                                                                                    llround(pos.mV[VX]),
02136                                                                                                                    llround(pos.mV[VY]),
02137                                                                                                                    llround(pos.mV[VZ])));
02138                 }
02139 
02140                 mSetBtn->setEnabled( can_change_landing_point );
02141                 mClearBtn->setEnabled( can_change_landing_point );
02142 
02143                 mMatureCtrl->set(parcel->getMaturePublish());
02144                 mMatureCtrl->setEnabled( can_change_identity );
02145                 mPublishHelpButton->setEnabled( can_change_identity );
02146 
02147                 if (gAgent.isTeen())
02148                 {
02149                         // Disable these buttons if they are PG (Teen) users
02150                         mPublishHelpButton->setVisible(FALSE);
02151                         mPublishHelpButton->setEnabled(FALSE);
02152                         mMatureCtrl->setVisible(FALSE);
02153                         mMatureCtrl->setEnabled(FALSE);
02154                 }
02155         }
02156 }
02157 
02158 // virtual
02159 void LLPanelLandOptions::draw()
02160 {
02161         LLParcel *parcel = gParcelMgr->getFloatingParcelSelection()->getParcel();
02162         
02163         if(parcel)
02164         {
02165                 LLViewerRegion* region;
02166                 region = gParcelMgr->getSelectionRegion();
02167                 llassert(region); // Region should never be null.
02168 
02169                 BOOL can_change_identity = region ? 
02170                         LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_IDENTITY) &&
02171                         ! (region->getRegionFlags() & REGION_FLAGS_BLOCK_PARCEL_SEARCH) : false;
02172 
02173                 // There is a bug with this panel whereby the Show Directory bit can be 
02174                 // slammed off by the Region based on an override.  Since this data is cached
02175                 // locally the change will not reflect in the panel, which could cause confusion
02176                 // A workaround for this is to flip the bit off in the locally cached version
02177                 // when we detect a mismatch case.
02178                 if(! can_change_identity && parcel->getParcelFlag(PF_SHOW_DIRECTORY))
02179                 {
02180                         parcel->setParcelFlag(PF_SHOW_DIRECTORY, FALSE);
02181                 }
02182                 mCheckShowDirectory     ->set(parcel->getParcelFlag(PF_SHOW_DIRECTORY));
02183                 mCheckShowDirectory     ->setEnabled(can_change_identity);
02184                 mCategoryCombo->setEnabled(can_change_identity);
02185         }
02186 
02187         LLPanel::draw();
02188 
02189 
02190 }
02191 // static
02192 void LLPanelLandOptions::onCommitAny(LLUICtrl *ctrl, void *userdata)
02193 {
02194         LLPanelLandOptions *self = (LLPanelLandOptions *)userdata;
02195 
02196         LLParcel* parcel = self->mParcel->getParcel();
02197         if (!parcel)
02198         {
02199                 return;
02200         }
02201 
02202         // Extract data from UI
02203         BOOL create_objects             = self->mCheckEditObjects->get();
02204         BOOL create_group_objects       = self->mCheckEditGroupObjects->get() || self->mCheckEditObjects->get();
02205         BOOL all_object_entry           = self->mCheckAllObjectEntry->get();
02206         BOOL group_object_entry = self->mCheckGroupObjectEntry->get() || self->mCheckAllObjectEntry->get();
02207         BOOL allow_terraform    = self->mCheckEditLand->get();
02208         BOOL allow_damage               = !self->mCheckSafe->get();
02209         BOOL allow_fly                  = self->mCheckFly->get();
02210         BOOL allow_landmark             = self->mCheckLandmark->get();
02211         BOOL allow_group_scripts        = self->mCheckGroupScripts->get() || self->mCheckOtherScripts->get();
02212         BOOL allow_other_scripts        = self->mCheckOtherScripts->get();
02213         BOOL allow_publish              = FALSE;
02214         BOOL mature_publish             = self->mMatureCtrl->get();
02215         BOOL push_restriction   = self->mPushRestrictionCtrl->get();
02216         BOOL show_directory             = self->mCheckShowDirectory->get();
02217         S32  category_index             = self->mCategoryCombo->getCurrentIndex();
02218         S32  landing_type_index = self->mLandingTypeCombo->getCurrentIndex();
02219         LLUUID snapshot_id              = self->mSnapshotCtrl->getImageAssetID();
02220         LLViewerRegion* region;
02221         region = gParcelMgr->getSelectionRegion();
02222 
02223         if (!allow_other_scripts && region && region->getAllowDamage())
02224         {
02225 
02226                 gViewerWindow->alertXml("UnableToDisableOutsideScripts");
02227                 return;
02228         }
02229 
02230         // Push data into current parcel
02231         parcel->setParcelFlag(PF_CREATE_OBJECTS, create_objects);
02232         parcel->setParcelFlag(PF_CREATE_GROUP_OBJECTS, create_group_objects);
02233         parcel->setParcelFlag(PF_ALLOW_ALL_OBJECT_ENTRY, all_object_entry);
02234         parcel->setParcelFlag(PF_ALLOW_GROUP_OBJECT_ENTRY, group_object_entry);
02235         parcel->setParcelFlag(PF_ALLOW_TERRAFORM, allow_terraform);
02236         parcel->setParcelFlag(PF_ALLOW_DAMAGE, allow_damage);
02237         parcel->setParcelFlag(PF_ALLOW_FLY, allow_fly);
02238         parcel->setParcelFlag(PF_ALLOW_LANDMARK, allow_landmark);
02239         parcel->setParcelFlag(PF_ALLOW_GROUP_SCRIPTS, allow_group_scripts);
02240         parcel->setParcelFlag(PF_ALLOW_OTHER_SCRIPTS, allow_other_scripts);
02241         parcel->setParcelFlag(PF_SHOW_DIRECTORY, show_directory);
02242         parcel->setParcelFlag(PF_ALLOW_PUBLISH, allow_publish);
02243         parcel->setParcelFlag(PF_MATURE_PUBLISH, mature_publish);
02244         parcel->setParcelFlag(PF_RESTRICT_PUSHOBJECT, push_restriction);
02245         parcel->setCategory((LLParcel::ECategory)category_index);
02246         parcel->setLandingType((LLParcel::ELandingType)landing_type_index);
02247         parcel->setSnapshotID(snapshot_id);
02248 
02249         // Send current parcel data upstream to server
02250         gParcelMgr->sendParcelPropertiesUpdate( parcel );
02251 
02252         // Might have changed properties, so let's redraw!
02253         self->refresh();
02254 }
02255 
02256 
02257 // static
02258 void LLPanelLandOptions::onClickSet(void* userdata)
02259 {
02260         LLPanelLandOptions* self = (LLPanelLandOptions*)userdata;
02261 
02262         LLParcel* selected_parcel = self->mParcel->getParcel();
02263         if (!selected_parcel) return;
02264 
02265         LLParcel* agent_parcel = gParcelMgr->getAgentParcel();
02266         if (!agent_parcel) return;
02267 
02268         if (agent_parcel->getLocalID() != selected_parcel->getLocalID())
02269         {
02270                 gViewerWindow->alertXml("MustBeInParcel");
02271                 return;
02272         }
02273 
02274         LLVector3 pos_region = gAgent.getPositionAgent();
02275         selected_parcel->setUserLocation(pos_region);
02276         selected_parcel->setUserLookAt(gAgent.getFrameAgent().getAtAxis());
02277 
02278         gParcelMgr->sendParcelPropertiesUpdate(selected_parcel);
02279 
02280         self->refresh();
02281 }
02282 
02283 void LLPanelLandOptions::onClickClear(void* userdata)
02284 {
02285         LLPanelLandOptions* self = (LLPanelLandOptions*)userdata;
02286 
02287         LLParcel* selected_parcel = self->mParcel->getParcel();
02288         if (!selected_parcel) return;
02289 
02290         // yes, this magic number of 0,0,0 means that it is clear
02291         LLVector3 zero_vec(0.f, 0.f, 0.f);
02292         selected_parcel->setUserLocation(zero_vec);
02293         selected_parcel->setUserLookAt(zero_vec);
02294 
02295         gParcelMgr->sendParcelPropertiesUpdate(selected_parcel);
02296 
02297         self->refresh();
02298 }
02299 
02300 // static
02301 void LLPanelLandOptions::onClickPublishHelp(void*)
02302 {
02303         LLViewerRegion* region = gParcelMgr->getSelectionRegion();
02304         LLParcel *parcel = gParcelMgr->getFloatingParcelSelection()->getParcel();
02305         llassert(region); // Region should never be null.
02306 
02307         bool can_change_identity = region && parcel ? 
02308                 LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_IDENTITY) &&
02309                 ! (region->getRegionFlags() & REGION_FLAGS_BLOCK_PARCEL_SEARCH) : false;
02310 
02311         if(! can_change_identity)
02312         {
02313                 gViewerWindow->alertXml("ClickPublishHelpLandDisabled");
02314         }
02315         else
02316         {
02317                 gViewerWindow->alertXml("ClickPublishHelpLand");
02318         }
02319 }
02320 
02321 //---------------------------------------------------------------------------
02322 // LLPanelLandMedia
02323 //---------------------------------------------------------------------------
02324 
02325 LLPanelLandMedia::LLPanelLandMedia(LLParcelSelectionHandle& parcel)
02326 :       LLPanel("land_media_panel"), mParcel(parcel)
02327 {
02328 }
02329 
02330 
02331 
02332 
02333 BOOL LLPanelLandMedia::postBuild()
02334 {
02335                 
02336         mCheckSoundLocal = LLUICtrlFactory::getCheckBoxByName(this, "check sound local");
02337         childSetCommitCallback("check sound local", onCommitAny, this);
02338 
02339         mRadioVoiceChat = LLUICtrlFactory::getRadioGroupByName(this, "parcel_voice_channel");
02340         childSetCommitCallback("parcel_voice_channel", onCommitAny, this);
02341 
02342         mMusicURLEdit = LLUICtrlFactory::getLineEditorByName(this, "music_url");
02343         childSetCommitCallback("music_url", onCommitAny, this);
02344 
02345 
02346         mMediaTextureCtrl = LLUICtrlFactory::getTexturePickerByName(this, "media texture");
02347         if (mMediaTextureCtrl)
02348         {
02349                 mMediaTextureCtrl->setCommitCallback( onCommitAny );
02350                 mMediaTextureCtrl->setCallbackUserData( this );
02351                 mMediaTextureCtrl->setAllowNoTexture ( TRUE );
02352                 mMediaTextureCtrl->setImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
02353                 mMediaTextureCtrl->setNonImmediateFilterPermMask(PERM_COPY | PERM_TRANSFER);
02354         }
02355         else
02356         {
02357                 llwarns << "LLUICtrlFactory::getTexturePickerByName() returned NULL for 'media texure'" << llendl;
02358         }
02359                 
02360         mMediaAutoScaleCheck = LLUICtrlFactory::getCheckBoxByName(this, "media_auto_scale");
02361         childSetCommitCallback("media_auto_scale", onCommitAny, this);
02362 
02363         mMediaURLEdit = LLUICtrlFactory::getLineEditorByName(this, "media_url");
02364         childSetCommitCallback("media_url", onCommitAny, this);
02365         
02366         return TRUE;
02367 }
02368 
02369 
02370 // virtual
02371 LLPanelLandMedia::~LLPanelLandMedia()
02372 { }
02373 
02374 
02375 // public
02376 void LLPanelLandMedia::refresh()
02377 {
02378         LLParcel *parcel = mParcel->getParcel();
02379 
02380         if (!parcel)
02381         {
02382                 mCheckSoundLocal->set(FALSE);
02383                 mCheckSoundLocal->setEnabled(FALSE);
02384 
02385                 mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatEstate);
02386                 mRadioVoiceChat->setEnabled(FALSE);
02387 
02388                 mMusicURLEdit->setText(LLString::null);
02389                 mMusicURLEdit->setEnabled(FALSE);
02390 
02391                 mMediaURLEdit->setText(LLString::null);
02392                 mMediaURLEdit->setEnabled(FALSE);
02393 
02394                 mMediaAutoScaleCheck->set ( FALSE );
02395                 mMediaAutoScaleCheck->setEnabled(FALSE);
02396 
02397                 mMediaTextureCtrl->clear();
02398                 mMediaTextureCtrl->setEnabled(FALSE);
02399 
02400                 #if 0
02401                 mMediaStopButton->setEnabled ( FALSE );
02402                 mMediaStartButton->setEnabled ( FALSE );
02403                 #endif
02404         }
02405         else
02406         {
02407                 // something selected, hooray!
02408 
02409                 // Display options
02410                 BOOL can_change_media = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_MEDIA);
02411 
02412                 mCheckSoundLocal->set( parcel->getSoundLocal() );
02413                 mCheckSoundLocal->setEnabled( can_change_media );
02414 
02415                 if(parcel->getVoiceEnabled())
02416                 {
02417                         if(parcel->getVoiceUseEstateChannel())
02418                                 mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatEstate);
02419                         else
02420                                 mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatPrivate);
02421                 }
02422                 else
02423                 {
02424                         mRadioVoiceChat->setSelectedIndex(kRadioVoiceChatDisable);
02425                 }
02426 
02427                 mRadioVoiceChat->setEnabled( can_change_media );
02428 
02429                 // don't display urls if you're not able to change it
02430                 // much requested change in forums so people can't 'steal' urls
02431                 // NOTE: bug#2009 means this is still vunerable - however, bug 
02432                 // should be closed since this bug opens up major security issues elsewhere.
02433                 if ( can_change_media )
02434                 {
02435                         mMusicURLEdit->setDrawAsterixes ( FALSE );
02436                         mMediaURLEdit->setDrawAsterixes ( FALSE );
02437                 }
02438                 else
02439                 {
02440                                 mMusicURLEdit->setDrawAsterixes ( TRUE );
02441                                 mMediaURLEdit->setDrawAsterixes ( TRUE );
02442                         }
02443 
02444                 mMusicURLEdit->setText(parcel->getMusicURL());
02445                 mMusicURLEdit->setEnabled( can_change_media );
02446 
02447                 mMediaURLEdit->setText(parcel->getMediaURL());
02448                 mMediaURLEdit->setEnabled( can_change_media );
02449 
02450                 mMediaAutoScaleCheck->set ( parcel->getMediaAutoScale () );
02451                 mMediaAutoScaleCheck->setEnabled ( can_change_media );
02452 
02453                 LLUUID tmp = parcel->getMediaID();
02454                 mMediaTextureCtrl->setImageAssetID ( parcel->getMediaID() );
02455                 mMediaTextureCtrl->setEnabled( can_change_media );
02456 
02457                 #if 0
02458                 // there is a media url and a media texture selected
02459                 if ( ( ! ( std::string ( parcel->getMediaURL() ).empty () ) ) && ( ! ( parcel->getMediaID ().isNull () ) ) )
02460                 {
02461                         // turn on transport controls if allowed for this parcel
02462                         mMediaStopButton->setEnabled ( editable );
02463                         mMediaStartButton->setEnabled ( editable );
02464                 }
02465                 else
02466                 {
02467                         // no media url or no media texture
02468                         mMediaStopButton->setEnabled ( FALSE );
02469                         mMediaStartButton->setEnabled ( FALSE );
02470                 };
02471                 #endif
02472         }
02473 }
02474 
02475 // static
02476 void LLPanelLandMedia::onCommitAny(LLUICtrl *ctrl, void *userdata)
02477 {
02478         LLPanelLandMedia *self = (LLPanelLandMedia *)userdata;
02479 
02480         LLParcel* parcel = self->mParcel->getParcel();
02481         if (!parcel)
02482         {
02483                 return;
02484         }
02485 
02486         // Extract data from UI
02487         BOOL sound_local                = self->mCheckSoundLocal->get();
02488         int voice_setting               = self->mRadioVoiceChat->getSelectedIndex();
02489         std::string music_url   = self->mMusicURLEdit->getText();
02490         std::string media_url   = self->mMediaURLEdit->getText();
02491         U8 media_auto_scale             = self->mMediaAutoScaleCheck->get();
02492         LLUUID media_id                 = self->mMediaTextureCtrl->getImageAssetID();
02493 
02494         BOOL voice_enabled;
02495         BOOL voice_estate_chan;
02496         
02497         switch(voice_setting)
02498         {
02499                 default:
02500                 case kRadioVoiceChatEstate:
02501                         voice_enabled = TRUE;
02502                         voice_estate_chan = TRUE;
02503                 break;
02504                 case kRadioVoiceChatPrivate:
02505                         voice_enabled = TRUE;
02506                         voice_estate_chan = FALSE;
02507                 break;
02508                 case kRadioVoiceChatDisable:
02509                         voice_enabled = FALSE;
02510                         voice_estate_chan = FALSE;
02511                 break;
02512         }
02513         
02514         // Remove leading/trailing whitespace (common when copying/pasting)
02515         LLString::trim(music_url);
02516         LLString::trim(media_url);
02517 
02518         // Push data into current parcel
02519         parcel->setParcelFlag(PF_ALLOW_VOICE_CHAT, voice_enabled);
02520         parcel->setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, voice_estate_chan);
02521         parcel->setParcelFlag(PF_SOUND_LOCAL, sound_local);
02522         parcel->setMusicURL(music_url.c_str());
02523         parcel->setMediaURL(media_url.c_str());
02524         parcel->setMediaID(media_id);
02525         parcel->setMediaAutoScale ( media_auto_scale );
02526 
02527         // Send current parcel data upstream to server
02528         gParcelMgr->sendParcelPropertiesUpdate( parcel );
02529 
02530         // Might have changed properties, so let's redraw!
02531         self->refresh();
02532 }
02533 
02534 void LLPanelLandMedia::onClickStopMedia ( void* data )
02535 {
02536         LLMediaEngine::getInstance ()->stop ();
02537 }
02538 
02539 void LLPanelLandMedia::onClickStartMedia ( void* data )
02540 {
02541         // force a commit
02542         gFocusMgr.setKeyboardFocus ( NULL, NULL );
02543 
02544         // force a reload
02545         LLMediaEngine::getInstance ()->convertImageAndLoadUrl ( true, false, std::string());
02546 }
02547 
02548 //---------------------------------------------------------------------------
02549 // LLPanelLandAccess
02550 //---------------------------------------------------------------------------
02551 
02552 LLPanelLandAccess::LLPanelLandAccess(LLParcelSelectionHandle& parcel)
02553 :       LLPanel("land_access_panel"), mParcel(parcel)
02554 {
02555 }
02556 
02557 
02558 
02559 BOOL LLPanelLandAccess::postBuild()
02560 {
02561 
02562         
02563         mCheckGroup = LLUICtrlFactory::getCheckBoxByName(this, "GroupCheck");
02564         childSetCommitCallback("GroupCheck", onCommitAny, this);
02565         
02566         mCheckAccess = LLUICtrlFactory::getCheckBoxByName(this, "AccessCheck");
02567         childSetCommitCallback("AccessCheck", onCommitAny, this);
02568 
02569         mListAccess = LLUICtrlFactory::getNameListByName(this, "AccessList");
02570         mListAccess->sortByColumn(0, TRUE); // ascending
02571 
02572         mBtnAddAccess = LLUICtrlFactory::getButtonByName(this, "Add...");
02573 
02574         mBtnAddAccess->setClickedCallback(onClickAdd, this);
02575 
02576         mBtnRemoveAccess = LLUICtrlFactory::getButtonByName(this, "Remove");
02577 
02578         mBtnRemoveAccess->setClickedCallback(onClickRemove, this);
02579         
02580         mCheckPass = LLUICtrlFactory::getCheckBoxByName(this, "PassCheck");
02581         childSetCommitCallback("PassCheck", onCommitAny, this);
02582 
02583         
02584         mSpinPrice = LLUICtrlFactory::getSpinnerByName(this, "PriceSpin");
02585         childSetCommitCallback("PriceSpin", onCommitAny, this);
02586         
02587         mSpinHours = LLUICtrlFactory::getSpinnerByName(this, "HoursSpin");
02588         childSetCommitCallback("HoursSpin", onCommitAny, this);
02589 
02590 
02591         return TRUE;
02592 }
02593 
02594 
02595 LLPanelLandAccess::~LLPanelLandAccess()
02596 { 
02597 }
02598 
02599 void LLPanelLandAccess::refresh()
02600 {
02601         mListAccess->deleteAllItems();
02602 
02603         LLParcel *parcel = mParcel->getParcel();
02604 
02605         if (parcel)
02606         {
02607                 // Display options
02608                 BOOL use_group = parcel->getParcelFlag(PF_USE_ACCESS_GROUP);
02609                 mCheckGroup->set( use_group );
02610 
02611                 char group_name[MAX_STRING];    /*Flawfinder: ignore*/
02612                 gCacheName->getGroupName(parcel->getGroupID(), group_name);
02613                 mCheckGroup->setLabelArg( "[GROUP]", LLString(group_name) );
02614 
02615                 S32 count = parcel->mAccessList.size();
02616 
02617                 BOOL use_list = parcel->getParcelFlag(PF_USE_ACCESS_LIST);
02618                 mCheckAccess->set( use_list );
02619                 mCheckAccess->setLabelArg( "[LISTED]", llformat("%d",count));
02620                 mCheckAccess->setLabelArg( "[MAX]", llformat("%d",PARCEL_MAX_ACCESS_LIST));
02621 
02622                 access_map_const_iterator cit = parcel->mAccessList.begin();
02623                 access_map_const_iterator end = parcel->mAccessList.end();
02624 
02625                 for (; cit != end; ++cit)
02626                 {
02627                         const LLAccessEntry& entry = (*cit).second;
02628                         LLString suffix;
02629                         if (entry.mTime != 0)
02630                         {
02631                                 S32 now = time(NULL);
02632                                 S32 seconds = entry.mTime - now;
02633                                 if (seconds < 0) seconds = 0;
02634                                 suffix.assign(" (");
02635                                 if (seconds >= 120)
02636                                 {
02637                                         char buf[30];   /*Flawfinder: ignore*/
02638                                         snprintf(buf, sizeof(buf), "%d minutes", (seconds/60));         /* Flawfinder: ignore */
02639                                         suffix.append(buf);
02640                                 }
02641                                 else if (seconds >= 60)
02642                                 {
02643                                         suffix.append("1 minute");
02644                                 }
02645                                 else
02646                                 {
02647                                         char buf[30];           /*Flawfinder: ignore*/
02648                                         snprintf(buf, sizeof(buf), "%d seconds", seconds);              /* Flawfinder: ignore */
02649                                         suffix.append(buf);
02650                                 }
02651                                 suffix.append(" remaining)");
02652                         }
02653                         mListAccess->addNameItem(entry.mID, ADD_SORTED, TRUE, suffix);
02654                 }
02655                 
02656                 BOOL can_manage_allowed = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_MANAGE_ALLOWED);
02657 
02658                 BOOL enable_add = can_manage_allowed && (count < PARCEL_MAX_ACCESS_LIST);
02659                 mBtnAddAccess->setEnabled(enable_add);
02660 
02661                 BOOL enable_remove = can_manage_allowed && (count > 0);
02662                 mBtnRemoveAccess->setEnabled(enable_remove);
02663 
02664                 // Can only sell passes when limiting the access.
02665                 BOOL can_manage_passes = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_MANAGE_PASSES);
02666                 mCheckPass->setEnabled( (use_group || use_list) && can_manage_passes );
02667 
02668                 BOOL use_pass = parcel->getParcelFlag(PF_USE_PASS_LIST);
02669                 mCheckPass->set( use_pass );
02670 
02671                 BOOL enable_pass = can_manage_passes && use_pass;
02672                 mSpinPrice->setEnabled( enable_pass );
02673                 mSpinHours->setEnabled( enable_pass );
02674 
02675                 S32 pass_price = parcel->getPassPrice();
02676                 mSpinPrice->set( F32(pass_price) );
02677 
02678                 F32 pass_hours = parcel->getPassHours();
02679                 mSpinHours->set( pass_hours );
02680 
02681                 mCheckGroup->setEnabled( can_manage_allowed );
02682                 mCheckAccess->setEnabled( can_manage_allowed );
02683 
02684         }
02685         else
02686         {
02687                 mCheckGroup->set(FALSE);
02688                 mCheckGroup->setLabelArg( "[GROUP]", LLString::null );
02689                 mCheckAccess->set(FALSE);
02690                 mCheckAccess->setLabelArg( "[LISTED]", llformat("%d",0));
02691                 mBtnAddAccess->setEnabled(FALSE);
02692                 mBtnRemoveAccess->setEnabled(FALSE);
02693                 mSpinPrice->set((F32)PARCEL_PASS_PRICE_DEFAULT);
02694                 mSpinPrice->setEnabled(FALSE);
02695                 mSpinHours->set( PARCEL_PASS_HOURS_DEFAULT );
02696                 mSpinHours->setEnabled(FALSE);
02697                 mCheckGroup->setEnabled(FALSE);
02698                 mCheckAccess->setEnabled(FALSE);
02699         }
02700 }
02701 
02702 // public
02703 void LLPanelLandAccess::refreshNames()
02704 {
02705         LLParcel* parcel = mParcel->getParcel();
02706         char group_name[DB_GROUP_NAME_BUF_SIZE];                /*Flawfinder: ignore*/
02707         group_name[0] = '\0';
02708         if(parcel)
02709         {
02710                 gCacheName->getGroupName(parcel->getGroupID(), group_name);
02711         }
02712         mCheckGroup->setLabelArg("[GROUP]", LLString(group_name));
02713 }
02714 
02715 
02716 // virtual
02717 void LLPanelLandAccess::draw()
02718 {
02719         refreshNames();
02720         LLPanel::draw();
02721 }
02722 
02723 
02724 void LLPanelLandAccess::onAccessLevelChange(LLUICtrl*, void *userdata)
02725 {
02726         LLPanelLandAccess::onCommitAny(NULL, userdata);
02727 }
02728 
02729 // static
02730 void LLPanelLandAccess::onCommitAny(LLUICtrl *ctrl, void *userdata)
02731 {
02732         LLPanelLandAccess *self = (LLPanelLandAccess *)userdata;
02733 
02734         LLParcel* parcel = self->mParcel->getParcel();
02735         if (!parcel)
02736         {
02737                 return;
02738         }
02739 
02740         // Extract data from UI
02741         BOOL use_access_group   = self->mCheckGroup->get();
02742         BOOL use_access_list    = self->mCheckAccess->get();
02743         BOOL use_pass_list              = self->mCheckPass->get();
02744         
02745 
02746 
02747         // Must be limiting access to sell passes
02748         if (!use_access_group && !use_access_list)
02749         {
02750                 use_pass_list = FALSE;
02751         }
02752 
02753         S32 pass_price = llfloor(self->mSpinPrice->get());
02754         F32 pass_hours = self->mSpinHours->get();
02755 
02756         // Validate extracted data
02757 
02758         // Push data into current parcel
02759         parcel->setParcelFlag(PF_USE_ACCESS_GROUP,      use_access_group);
02760         parcel->setParcelFlag(PF_USE_ACCESS_LIST,       use_access_list);
02761         parcel->setParcelFlag(PF_USE_PASS_LIST,         use_pass_list);
02762 
02763         parcel->setPassPrice( pass_price );
02764         parcel->setPassHours( pass_hours );
02765 
02766         // Send current parcel data upstream to server
02767         gParcelMgr->sendParcelPropertiesUpdate( parcel );
02768 
02769         // Might have changed properties, so let's redraw!
02770         self->refresh();
02771 }
02772 
02773 // static
02774 void LLPanelLandAccess::onClickAdd(void* data)
02775 {
02776         LLPanelLandAccess* panelp = (LLPanelLandAccess*)data;
02777         gFloaterView->getParentFloater(panelp)->addDependentFloater(LLFloaterAvatarPicker::show(callbackAvatarID, data) );
02778 }
02779 
02780 // static
02781 void LLPanelLandAccess::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata)
02782 {
02783         LLPanelLandAccess* self = (LLPanelLandAccess*)userdata;
02784         if (names.empty() || ids.empty()) return;
02785         self->addAvatar(ids[0]);
02786 }
02787 
02788 
02789 void LLPanelLandAccess::addAvatar(LLUUID id)
02790 {
02791         LLParcel* parcel = mParcel->getParcel();
02792         if (!parcel) return;
02793 
02794         parcel->addToAccessList(id, 0);
02795 
02796         gParcelMgr->sendParcelAccessListUpdate(AL_ACCESS);
02797 
02798         refresh();
02799 }
02800 
02801 
02802 // static
02803 void LLPanelLandAccess::onClickRemove(void* data)
02804 {
02805         LLPanelLandAccess* self = (LLPanelLandAccess*)data;
02806         if (!self) return;
02807 
02808         LLScrollListItem* item = self->mListAccess->getFirstSelected();
02809         if (!item) return;
02810 
02811         LLParcel* parcel = self->mParcel->getParcel();
02812         if (!parcel) return;
02813 
02814         const LLUUID& agent_id = item->getUUID();
02815 
02816         parcel->removeFromAccessList(agent_id);
02817 
02818         gParcelMgr->sendParcelAccessListUpdate(AL_ACCESS);
02819 
02820         self->refresh();
02821 }
02822 
02823 
02824 
02825 //---------------------------------------------------------------------------
02826 // LLPanelLandBan
02827 //---------------------------------------------------------------------------
02828 LLPanelLandBan::LLPanelLandBan(LLParcelSelectionHandle& parcel)
02829 :       LLPanel("land_ban_panel"), mParcel(parcel)
02830 {
02831 
02832 }
02833 
02834 
02835 
02836 BOOL LLPanelLandBan::postBuild()
02837 {
02838 
02839         mCheck = LLUICtrlFactory::getCheckBoxByName(this, "LandBanCheck");
02840         childSetCommitCallback("LandBanCheck", onCommitAny, this);
02841         
02842         mList = LLUICtrlFactory::getNameListByName(this, "LandBanList");
02843         mList->sortByColumn(0, TRUE); // ascending
02844 
02845         mBtnAdd = LLUICtrlFactory::getButtonByName(this, "Add...");
02846         
02847         mBtnAdd->setClickedCallback(onClickAdd, this);
02848 
02849         mBtnRemove = LLUICtrlFactory::getButtonByName(this, "Remove");
02850         
02851         mBtnRemove->setClickedCallback(onClickRemove, this);
02852 
02853         mCheckDenyAnonymous = LLUICtrlFactory::getCheckBoxByName(this, "DenyAnonymousCheck");
02854         childSetCommitCallback("DenyAnonymousCheck", onCommitAny, this);
02855 
02856         mCheckDenyIdentified = LLUICtrlFactory::getCheckBoxByName(this, "DenyIdentifiedCheck");
02857         childSetCommitCallback("DenyIdentifiedCheck", onCommitAny, this);
02858 
02859         mCheckDenyTransacted = LLUICtrlFactory::getCheckBoxByName(this, "DenyTransactedCheck");
02860         childSetCommitCallback("DenyTransactedCheck", onCommitAny, this);
02861 
02862         return TRUE;
02863 
02864 }
02865 
02866 
02867 LLPanelLandBan::~LLPanelLandBan()
02868 { }
02869 
02870 void LLPanelLandBan::refresh()
02871 {
02872         mList->deleteAllItems();
02873 
02874         LLParcel *parcel = mParcel->getParcel();
02875 
02876         if (parcel)
02877         {
02878                 // Display options
02879 
02880                 S32 count = parcel->mBanList.size();
02881 
02882                 BOOL use_ban = parcel->getParcelFlag(PF_USE_BAN_LIST);
02883                 mCheck->set( use_ban );
02884                 mCheck->setLabelArg( "[LISTED]", llformat("%d",count));
02885                 mCheck->setLabelArg( "[MAX]", llformat("%d",PARCEL_MAX_ACCESS_LIST));
02886 
02887                 access_map_const_iterator cit = parcel->mBanList.begin();
02888                 access_map_const_iterator end = parcel->mBanList.end();
02889                 for ( ; cit != end; ++cit)
02890                 {
02891                         const LLAccessEntry& entry = (*cit).second;
02892                         LLString suffix;
02893                         if (entry.mTime != 0)
02894                         {
02895                                 S32 now = time(NULL);
02896                                 S32 seconds = entry.mTime - now;
02897                                 if (seconds < 0) seconds = 0;
02898                                 suffix.assign(" (");
02899                                 if (seconds >= 120)
02900                                 {
02901                                         char buf[30];           /*Flawfinder: ignore*/
02902                                         snprintf(buf, sizeof(buf), "%d minutes", (seconds/60));         /* Flawfinder: ignore */
02903                                         suffix.append(buf);
02904                                 }
02905                                 else if (seconds >= 60)
02906                                 {
02907                                         suffix.append("1 minute");
02908                                 }
02909                                 else
02910                                 {
02911                                         char buf[30];   /*Flawfinder: ignore*/
02912                                         snprintf(buf, sizeof(buf), "%d seconds", seconds);              /* Flawfinder: ignore */
02913                                         suffix.append(buf);
02914                                 }
02915                                 suffix.append(" remaining)");
02916                         }
02917                         mList->addNameItem(entry.mID, ADD_SORTED, TRUE, suffix);
02918                 }
02919 
02920                 BOOL can_manage_banned = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_MANAGE_BANNED);
02921                 mCheck->setEnabled( can_manage_banned );
02922                 mCheckDenyAnonymous->setEnabled( FALSE );
02923                 mCheckDenyIdentified->setEnabled( FALSE );
02924                 mCheckDenyTransacted->setEnabled( FALSE );
02925 
02926                 if(parcel->getRegionDenyAnonymousOverride())
02927                 {
02928                         mCheckDenyAnonymous->set(TRUE);
02929                 }
02930                 else if(can_manage_banned)
02931                 {
02932                         mCheckDenyAnonymous->setEnabled(TRUE);
02933                         mCheckDenyAnonymous->set(parcel->getParcelFlag(PF_DENY_ANONYMOUS));
02934                 }
02935                 if(parcel->getRegionDenyIdentifiedOverride())
02936                 {
02937                         mCheckDenyIdentified->set(TRUE);
02938                 }
02939                 else if(can_manage_banned)
02940                 {
02941                         mCheckDenyIdentified->setEnabled(TRUE);
02942                         mCheckDenyIdentified->set(parcel->getParcelFlag(PF_DENY_IDENTIFIED));
02943                 }
02944                 if(parcel->getRegionDenyTransactedOverride())
02945                 {
02946                         mCheckDenyTransacted->set(TRUE);
02947                 }
02948                 else if(can_manage_banned)
02949                 {
02950                         mCheckDenyTransacted->setEnabled(TRUE);
02951                         mCheckDenyTransacted->set(parcel->getParcelFlag(PF_DENY_TRANSACTED));
02952                 }
02953 
02954 
02955                 BOOL enable_add = can_manage_banned && (count < PARCEL_MAX_ACCESS_LIST);
02956                 mBtnAdd->setEnabled(enable_add);
02957 
02958                 BOOL enable_remove = can_manage_banned && (count > 0);
02959                 mBtnRemove->setEnabled(enable_remove);
02960         }
02961         else
02962         {
02963                 mCheck->set(FALSE);
02964                 mCheck->setLabelArg( "[LISTED]", llformat("%d",0));
02965                 mCheck->setEnabled(FALSE);
02966                 mBtnAdd->setEnabled(FALSE);
02967                 mBtnRemove->setEnabled(FALSE);
02968                 mCheckDenyAnonymous->set(FALSE);
02969                 mCheckDenyAnonymous->setEnabled(FALSE);
02970                 mCheckDenyIdentified->set(FALSE);
02971                 mCheckDenyIdentified->setEnabled(FALSE);
02972                 mCheckDenyTransacted->set(FALSE);
02973                 mCheckDenyTransacted->setEnabled(FALSE);
02974         }
02975 }
02976 
02977 // static
02978 void LLPanelLandBan::onCommitAny(LLUICtrl *ctrl, void *userdata)
02979 {
02980         LLPanelLandBan *self = (LLPanelLandBan*)userdata;
02981 
02982         LLParcel* parcel = self->mParcel->getParcel();
02983         if (!parcel)
02984         {
02985                 return;
02986         }
02987 
02988         // Extract data from UI
02989         BOOL use_ban_list = self->mCheck->get();
02990         BOOL deny_access_anonymous = self->mCheckDenyAnonymous->get();
02991         BOOL deny_access_identified = self->mCheckDenyIdentified->get();
02992         BOOL deny_access_transacted = self->mCheckDenyTransacted->get();        
02993 
02994         // Push data into current parcel
02995         parcel->setParcelFlag(PF_USE_BAN_LIST,          use_ban_list);
02996         parcel->setParcelFlag(PF_DENY_ANONYMOUS, deny_access_anonymous);
02997         parcel->setParcelFlag(PF_DENY_IDENTIFIED, deny_access_identified);
02998         parcel->setParcelFlag(PF_DENY_TRANSACTED, deny_access_transacted);
02999 
03000         // Send current parcel data upstream to server
03001         gParcelMgr->sendParcelPropertiesUpdate( parcel );
03002 
03003         // Might have changed properties, so let's redraw!
03004         self->refresh();
03005 }
03006 
03007 // static
03008 void LLPanelLandBan::onClickAdd(void* data)
03009 {
03010         LLPanelLandBan* panelp = (LLPanelLandBan*)data;
03011         gFloaterView->getParentFloater(panelp)->addDependentFloater(LLFloaterAvatarPicker::show(callbackAvatarID, data) );
03012 }
03013 
03014 // static
03015 void LLPanelLandBan::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata)
03016 {
03017         LLPanelLandBan* self = (LLPanelLandBan*)userdata;
03018         if (names.empty() || ids.empty()) return;
03019         self->addAvatar(ids[0]);
03020 }
03021 
03022 
03023 void LLPanelLandBan::addAvatar(LLUUID id)
03024 {
03025         LLParcel* parcel = mParcel->getParcel();
03026         if (!parcel) return;
03027 
03028         parcel->addToBanList(id, 0);
03029 
03030         gParcelMgr->sendParcelAccessListUpdate(AL_BAN);
03031 
03032         refresh();
03033 }
03034 
03035 
03036 // static
03037 void LLPanelLandBan::onClickRemove(void* data)
03038 {
03039         LLPanelLandBan* self = (LLPanelLandBan*)data;
03040         if (!self) return;
03041 
03042         LLScrollListItem* item = self->mList->getFirstSelected();
03043         if (!item) return;
03044 
03045         LLParcel* parcel = self->mParcel->getParcel();
03046         if (!parcel) return;
03047 
03048         const LLUUID& agent_id = item->getUUID();
03049 
03050         parcel->removeFromBanList(agent_id);
03051 
03052         gParcelMgr->sendParcelAccessListUpdate(AL_BAN);
03053 
03054         self->refresh();
03055 }
03056 
03057 //---------------------------------------------------------------------------
03058 // LLPanelLandCovenant
03059 //---------------------------------------------------------------------------
03060 LLPanelLandCovenant::LLPanelLandCovenant(LLParcelSelectionHandle& parcel)
03061 :       LLPanel("land_covenant_panel"), mParcel(parcel)
03062 {       
03063 }
03064 
03065 LLPanelLandCovenant::~LLPanelLandCovenant()
03066 {
03067 }
03068 
03069 BOOL LLPanelLandCovenant::postBuild()
03070 {
03071         refresh();
03072         return TRUE;
03073 }
03074 
03075 // virtual
03076 void LLPanelLandCovenant::refresh()
03077 {
03078         LLViewerRegion* region = gParcelMgr->getSelectionRegion();
03079         if(!region) return;
03080                 
03081         LLTextBox* region_name = (LLTextBox*)getChildByName("region_name_text");
03082         if (region_name)
03083         {
03084                 region_name->setText(region->getName());
03085         }
03086 
03087         LLTextBox* resellable_clause = (LLTextBox*)getChildByName("resellable_clause");
03088         if (resellable_clause)
03089         {
03090                 if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL)
03091                 {
03092                         resellable_clause->setText(childGetText("can_not_resell"));
03093                 }
03094                 else
03095                 {
03096                         resellable_clause->setText(childGetText("can_resell"));
03097                 }
03098         }
03099         
03100         LLTextBox* changeable_clause = (LLTextBox*)getChildByName("changeable_clause");
03101         if (changeable_clause)
03102         {
03103                 if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES)
03104                 {
03105                         changeable_clause->setText(childGetText("can_change"));
03106                 }
03107                 else
03108                 {
03109                         changeable_clause->setText(childGetText("can_not_change"));
03110                 }
03111         }
03112         
03113         // send EstateCovenantInfo message
03114         LLMessageSystem *msg = gMessageSystem;
03115         msg->newMessage("EstateCovenantRequest");
03116         msg->nextBlockFast(_PREHASH_AgentData);
03117         msg->addUUIDFast(_PREHASH_AgentID,      gAgent.getID());
03118         msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
03119         msg->sendReliable(region->getHost());
03120 }
03121 
03122 // static
03123 void LLPanelLandCovenant::updateCovenantText(const std::string &string)
03124 {
03125         LLPanelLandCovenant* self = LLFloaterLand::getCurrentPanelLandCovenant();
03126         if (self)
03127         {
03128                 LLViewerTextEditor* editor = (LLViewerTextEditor*)self->getChildByName("covenant_editor");
03129                 if (editor)
03130                 {
03131                         editor->setHandleEditKeysDirectly(TRUE);
03132                         editor->setText(string);
03133                 }
03134         }
03135 }
03136 
03137 // static
03138 void LLPanelLandCovenant::updateEstateName(const std::string& name)
03139 {
03140         LLPanelLandCovenant* self = LLFloaterLand::getCurrentPanelLandCovenant();
03141         if (self)
03142         {
03143                 LLTextBox* editor = (LLTextBox*)self->getChildByName("estate_name_text");
03144                 if (editor) editor->setText(name);
03145         }
03146 }
03147 
03148 // static
03149 void LLPanelLandCovenant::updateLastModified(const std::string& text)
03150 {
03151         LLPanelLandCovenant* self = LLFloaterLand::getCurrentPanelLandCovenant();
03152         if (self)
03153         {
03154                 LLTextBox* editor = (LLTextBox*)self->getChildByName("covenant_timestamp_text");
03155                 if (editor) editor->setText(text);
03156         }
03157 }
03158 
03159 // static
03160 void LLPanelLandCovenant::updateEstateOwnerName(const std::string& name)
03161 {
03162         LLPanelLandCovenant* self = LLFloaterLand::getCurrentPanelLandCovenant();
03163         if (self)
03164         {
03165                 LLTextBox* editor = (LLTextBox*)self->getChildByName("estate_owner_text");
03166                 if (editor) editor->setText(name);
03167         }
03168 }

Generated on Thu Jul 1 06:08:34 2010 for Second Life Viewer by  doxygen 1.4.7