00001
00034 #include "llviewerprecompiledheaders.h"
00035
00036 #include "llpanelpermissions.h"
00037
00038 #include "lluuid.h"
00039 #include "llpermissions.h"
00040 #include "llcategory.h"
00041 #include "llclickaction.h"
00042 #include "llfocusmgr.h"
00043 #include "llstring.h"
00044
00045 #include "llviewerwindow.h"
00046 #include "llresmgr.h"
00047 #include "lltextbox.h"
00048 #include "llbutton.h"
00049 #include "llcheckboxctrl.h"
00050 #include "llviewerobject.h"
00051 #include "llselectmgr.h"
00052 #include "llagent.h"
00053 #include "llstatusbar.h"
00054 #include "lllineeditor.h"
00055 #include "llradiogroup.h"
00056 #include "llcombobox.h"
00057 #include "llfloateravatarinfo.h"
00058 #include "lluiconstants.h"
00059 #include "lldbstrings.h"
00060 #include "llfloatergroupinfo.h"
00061 #include "llfloatergroups.h"
00062 #include "llnamebox.h"
00063 #include "llviewercontrol.h"
00064 #include "llvieweruictrlfactory.h"
00065 #include "roles_constants.h"
00066
00070
00071
00072 LLPanelPermissions::LLPanelPermissions(const std::string& title) :
00073 LLPanel(title)
00074 {
00075 setMouseOpaque(FALSE);
00076 }
00077
00078 BOOL LLPanelPermissions::postBuild()
00079 {
00080 this->childSetCommitCallback("Object Name",LLPanelPermissions::onCommitName,this);
00081 this->childSetPrevalidate("Object Name",LLLineEditor::prevalidatePrintableNotPipe);
00082 this->childSetCommitCallback("Object Description",LLPanelPermissions::onCommitDesc,this);
00083 this->childSetPrevalidate("Object Description",LLLineEditor::prevalidatePrintableNotPipe);
00084
00085
00086 this->childSetAction("button owner profile",LLPanelPermissions::onClickOwner,this);
00087 this->childSetAction("button creator profile",LLPanelPermissions::onClickCreator,this);
00088
00089 this->childSetAction("button set group",LLPanelPermissions::onClickGroup,this);
00090
00091 this->childSetCommitCallback("checkbox share with group",LLPanelPermissions::onCommitGroupShare,this);
00092
00093 this->childSetAction("button deed",LLPanelPermissions::onClickDeedToGroup,this);
00094
00095 this->childSetCommitCallback("checkbox allow everyone move",LLPanelPermissions::onCommitEveryoneMove,this);
00096
00097 this->childSetCommitCallback("checkbox allow everyone copy",LLPanelPermissions::onCommitEveryoneCopy,this);
00098
00099 this->childSetCommitCallback("checkbox for sale",LLPanelPermissions::onCommitSaleInfo,this);
00100
00101 this->childSetCommitCallback("EdCost",LLPanelPermissions::onCommitSaleInfo,this);
00102 this->childSetPrevalidate("EdCost",LLLineEditor::prevalidateNonNegativeS32);
00103
00104 this->childSetCommitCallback("sale type",LLPanelPermissions::onCommitSaleType,this);
00105
00106 this->childSetCommitCallback("checkbox next owner can modify",LLPanelPermissions::onCommitNextOwnerModify,this);
00107 this->childSetCommitCallback("checkbox next owner can copy",LLPanelPermissions::onCommitNextOwnerCopy,this);
00108 this->childSetCommitCallback("checkbox next owner can transfer",LLPanelPermissions::onCommitNextOwnerTransfer,this);
00109 this->childSetCommitCallback("clickaction",LLPanelPermissions::onCommitClickAction,this);
00110 this->childSetCommitCallback("search_check",LLPanelPermissions::onCommitIncludeInSearch,this);
00111
00112 LLTextBox* group_rect_proxy = gUICtrlFactory->getTextBoxByName(this,"Group Name Proxy");
00113 if(group_rect_proxy )
00114 {
00115 mLabelGroupName = new LLNameBox("Group Name", group_rect_proxy->getRect());
00116 addChild(mLabelGroupName);
00117 }
00118 else
00119 {
00120 mLabelGroupName = NULL;
00121 }
00122
00123 return TRUE;
00124 }
00125
00126
00127 LLPanelPermissions::~LLPanelPermissions()
00128 {
00129
00130 }
00131
00132
00133 void LLPanelPermissions::refresh()
00134 {
00135 LLButton* BtnDeedToGroup = gUICtrlFactory->getButtonByName(this,"button deed");
00136 if(BtnDeedToGroup)
00137 {
00138 LLString deedText;
00139 if (gSavedSettings.getWarning("DeedObject"))
00140 {
00141 deedText = this->childGetText("text deed continued");
00142 }
00143 else
00144 {
00145 deedText = this->childGetText("text deed");
00146 }
00147 BtnDeedToGroup->setLabelSelected(deedText);
00148 BtnDeedToGroup->setLabelUnselected(deedText);
00149 }
00150 BOOL root_selected = TRUE;
00151 LLSelectNode* nodep = gSelectMgr->getSelection()->getFirstRootNode();
00152 S32 object_count = gSelectMgr->getSelection()->getRootObjectCount();
00153 if(!nodep || 0 == object_count)
00154 {
00155 nodep = gSelectMgr->getSelection()->getFirstNode();
00156 object_count = gSelectMgr->getSelection()->getObjectCount();
00157 root_selected = FALSE;
00158 }
00159
00160
00161
00162 LLViewerObject* objectp = NULL;
00163 if(nodep) objectp = nodep->getObject();
00164 if(!nodep || !objectp)
00165 {
00166
00167 childSetEnabled("perm_modify",false);
00168 childSetText("perm_modify",LLString::null);
00169
00170 childSetEnabled("Creator:",false);
00171 childSetText("Creator Name",LLString::null);
00172 childSetEnabled("Creator Name",false);
00173 childSetEnabled("button creator profile",false);
00174
00175 childSetEnabled("Owner:",false);
00176 childSetText("Owner Name",LLString::null);
00177 childSetEnabled("Owner Name",false);
00178 childSetEnabled("button owner profile",false);
00179
00180 childSetEnabled("Group:",false);
00181 childSetText("Group Name",LLString::null);
00182 childSetEnabled("Group Name",false);
00183 childSetEnabled("button set group",false);
00184
00185 childSetText("Object Name",LLString::null);
00186 childSetEnabled("Object Name",false);
00187 childSetEnabled("Name:",false);
00188 childSetText("Group Name",LLString::null);
00189 childSetEnabled("Group Name",false);
00190 childSetEnabled("Description:",false);
00191 childSetText("Object Description",LLString::null);
00192 childSetEnabled("Object Description",false);
00193
00194 childSetText("prim info",LLString::null);
00195 childSetEnabled("prim info",false);
00196
00197 childSetEnabled("Permissions:",false);
00198
00199 childSetValue("checkbox share with group",FALSE);
00200 childSetEnabled("checkbox share with group",false);
00201 childSetEnabled("button deed",false);
00202
00203 childSetValue("checkbox allow everyone move",FALSE);
00204 childSetEnabled("checkbox allow everyone move",false);
00205 childSetValue("checkbox allow everyone copy",FALSE);
00206 childSetEnabled("checkbox allow everyone copy",false);
00207
00208
00209 childSetEnabled("Next owner can:",false);
00210 childSetValue("checkbox next owner can modify",FALSE);
00211 childSetEnabled("checkbox next owner can modify",false);
00212 childSetValue("checkbox next owner can copy",FALSE);
00213 childSetEnabled("checkbox next owner can copy",false);
00214 childSetValue("checkbox next owner can transfer",FALSE);
00215 childSetEnabled("checkbox next owner can transfer",false);
00216
00217
00218 childSetValue("checkbox for sale",FALSE);
00219 childSetEnabled("checkbox for sale",false);
00220
00221
00222 childSetValue("search_check", FALSE);
00223 childSetEnabled("search_check", false);
00224
00225 LLRadioGroup* RadioSaleType = gUICtrlFactory->getRadioGroupByName(this,"sale type");
00226 if(RadioSaleType)
00227 {
00228 RadioSaleType->setSelectedIndex(-1);
00229 RadioSaleType->setEnabled(FALSE);
00230 }
00231
00232 childSetEnabled("Price: L$",false);
00233 childSetText("EdCost",LLString::null);
00234 childSetEnabled("EdCost",false);
00235
00236 childSetEnabled("label click action",false);
00237 LLComboBox* ComboClickAction = gUICtrlFactory->getComboBoxByName(this,"clickaction");
00238 if(ComboClickAction)
00239 {
00240 ComboClickAction->setEnabled(FALSE);
00241 ComboClickAction->clear();
00242 }
00243 childSetVisible("B:",false);
00244 childSetVisible("O:",false);
00245 childSetVisible("G:",false);
00246 childSetVisible("E:",false);
00247 childSetVisible("N:",false);
00248 childSetVisible("F:",false);
00249
00250 return;
00251 }
00252
00253
00254 BOOL is_one_object = (object_count == 1);
00255
00256
00257 BOOL is_perm_modify = (gSelectMgr->getSelection()->getFirstRootNode()
00258 && gSelectMgr->selectGetRootsModify())
00259 || gSelectMgr->selectGetModify();
00260 const LLView* keyboard_focus_view = gFocusMgr.getKeyboardFocus();
00261 S32 string_index = 0;
00262 LLString MODIFY_INFO_STRINGS[] =
00263 {
00264 childGetText("text modify info 1"),
00265 childGetText("text modify info 2"),
00266 childGetText("text modify info 3"),
00267 childGetText("text modify info 4")
00268 };
00269 if(!is_perm_modify)
00270 {
00271 string_index += 2;
00272 }
00273 if(!is_one_object)
00274 {
00275 ++string_index;
00276 }
00277 childSetEnabled("perm_modify",true);
00278 childSetText("perm_modify",MODIFY_INFO_STRINGS[string_index]);
00279
00280 childSetEnabled("Permissions:",true);
00281
00282
00283 childSetEnabled("Creator:",true);
00284 BOOL creators_identical;
00285 LLString creator_name;
00286 creators_identical = gSelectMgr->selectGetCreator(mCreatorID,
00287 creator_name);
00288
00289 childSetText("Creator Name",creator_name);
00290 childSetEnabled("Creator Name",TRUE);
00291 childSetEnabled("button creator profile", creators_identical && mCreatorID.notNull() );
00292
00293
00294 childSetEnabled("Owner:",true);
00295
00296 BOOL owners_identical;
00297 LLString owner_name;
00298 owners_identical = gSelectMgr->selectGetOwner(mOwnerID, owner_name);
00299
00300
00301
00302 if (mOwnerID.isNull())
00303 {
00304 if(gSelectMgr->selectIsGroupOwned())
00305 {
00306
00307 }
00308 else
00309 {
00310
00311 LLString last_owner_name;
00312 gSelectMgr->selectGetLastOwner(mLastOwnerID, last_owner_name);
00313
00314
00315
00316 if (!mLastOwnerID.isNull() && !last_owner_name.empty())
00317 {
00318 owner_name.append(", last ");
00319 owner_name.append( last_owner_name );
00320 }
00321 }
00322 }
00323
00324 childSetText("Owner Name",owner_name);
00325 childSetEnabled("Owner Name",TRUE);
00326 childSetEnabled("button owner profile",owners_identical && (mOwnerID.notNull() || gSelectMgr->selectIsGroupOwned()));
00327
00328
00329 childSetEnabled("Group:",true);
00330 LLUUID group_id;
00331 BOOL groups_identical = gSelectMgr->selectGetGroup(group_id);
00332 if (groups_identical)
00333 {
00334 if(mLabelGroupName)
00335 {
00336 mLabelGroupName->setNameID(group_id, TRUE);
00337 mLabelGroupName->setEnabled(TRUE);
00338 }
00339 }
00340 childSetEnabled("button set group",owners_identical && (mOwnerID == gAgent.getID()));
00341
00342
00343 BOOL edit_name_desc = FALSE;
00344 if(is_one_object && objectp->permModify())
00345 {
00346 edit_name_desc = TRUE;
00347 }
00348 if(is_one_object)
00349 {
00350 childSetEnabled("Name:",true);
00351 LLLineEditor* LineEditorObjectName = gUICtrlFactory->getLineEditorByName(this,"Object Name");
00352 if(keyboard_focus_view != LineEditorObjectName)
00353 {
00354 childSetText("Object Name",nodep->mName);
00355 }
00356
00357 childSetEnabled("Description:",true);
00358 LLLineEditor* LineEditorObjectDesc = gUICtrlFactory->getLineEditorByName(this,"Object Description");
00359 if(LineEditorObjectDesc)
00360 {
00361 if(keyboard_focus_view != LineEditorObjectDesc)
00362 {
00363 LineEditorObjectDesc->setText(nodep->mDescription);
00364 }
00365 }
00366 }
00367
00368 if(edit_name_desc)
00369 {
00370 childSetEnabled("Object Name",true);
00371 childSetEnabled("Object Description",true);
00372 }
00373 else
00374 {
00375 childSetEnabled("Object Name",false);
00376 childSetEnabled("Object Description",false);
00377 }
00378
00379
00380
00381 S32 prim_count = gSelectMgr->getSelection()->getObjectCount();
00382 S32 obj_count = gSelectMgr->getSelection()->getRootObjectCount();
00383
00384 LLString object_info_string;
00385 if (1 == obj_count)
00386 {
00387 object_info_string.assign("1 Object, ");
00388 }
00389 else
00390 {
00391 char buffer[MAX_STRING];
00392 snprintf(buffer, MAX_STRING, "%d Objects, ", obj_count);
00393 object_info_string.assign(buffer);
00394 }
00395 if (1 == prim_count)
00396 {
00397 object_info_string.append("1 Primitive");
00398 }
00399 else
00400 {
00401 char buffer[MAX_STRING];
00402 snprintf(buffer, MAX_STRING, "%d Primitives", prim_count);
00403 object_info_string.append(buffer);
00404 }
00405 childSetText("prim info",object_info_string);
00406 childSetEnabled("prim info",true);
00407
00408 S32 price;
00409 BOOL is_for_sale = gSelectMgr->selectIsForSale(price);
00410 if (!is_for_sale)
00411 {
00412 price = DEFAULT_PRICE;
00413 }
00414
00415 BOOL self_owned = (gAgent.getID() == mOwnerID);
00416 BOOL group_owned = gSelectMgr->selectIsGroupOwned() ;
00417 BOOL public_owned = (mOwnerID.isNull() && !gSelectMgr->selectIsGroupOwned());
00418 BOOL can_transfer = gSelectMgr->selectGetRootsTransfer();
00419 BOOL can_copy = gSelectMgr->selectGetRootsCopy();
00420
00421 if(!owners_identical)
00422 {
00423 childSetEnabled("Price: L$",false);
00424 childSetText("EdCost",LLString::null);
00425 childSetEnabled("EdCost",false);
00426 }
00427 else if(self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
00428 {
00429 LLLineEditor* EditPrice = gUICtrlFactory->getLineEditorByName(this,"EdCost");
00430 if(keyboard_focus_view != EditPrice)
00431 {
00432 childSetText("EdCost",llformat("%d",price));
00433 }
00434 if(is_for_sale && is_one_object && can_transfer)
00435 {
00436 childSetEnabled("Price: L$",true);
00437 childSetEnabled("EdCost",true);
00438 }
00439 else
00440 {
00441 childSetEnabled("Price: L$",false);
00442 childSetEnabled("EdCost",false);
00443 }
00444 }
00445 else if(!public_owned)
00446 {
00447
00448 childSetEnabled("Price: L$",false);
00449 childSetText("EdCost",llformat("%d",price));
00450 childSetEnabled("EdCost",false);
00451 }
00452 else
00453 {
00454
00455 childSetEnabled("Price: L$",false);
00456 childSetText("EdCost",LLString::null);
00457 childSetEnabled("EdCost",false);
00458 }
00459
00460
00461
00462
00463
00464 BOOL valid_base_perms = FALSE;
00465 BOOL valid_owner_perms = FALSE;
00466 BOOL valid_group_perms = FALSE;
00467 BOOL valid_everyone_perms = FALSE;
00468 BOOL valid_next_perms = FALSE;
00469
00470 U32 base_mask_on;
00471 U32 base_mask_off;
00472 U32 owner_mask_on;
00473 U32 owner_mask_off;
00474 U32 group_mask_on;
00475 U32 group_mask_off;
00476 U32 everyone_mask_on;
00477 U32 everyone_mask_off;
00478 U32 next_owner_mask_on = 0;
00479 U32 next_owner_mask_off = 0;
00480
00481 valid_base_perms = gSelectMgr->selectGetPerm(PERM_BASE,
00482 &base_mask_on,
00483 &base_mask_off);
00484
00485 valid_owner_perms = gSelectMgr->selectGetPerm(PERM_OWNER,
00486 &owner_mask_on,
00487 &owner_mask_off);
00488
00489 valid_group_perms = gSelectMgr->selectGetPerm(PERM_GROUP,
00490 &group_mask_on,
00491 &group_mask_off);
00492
00493 valid_everyone_perms = gSelectMgr->selectGetPerm(PERM_EVERYONE,
00494 &everyone_mask_on,
00495 &everyone_mask_off);
00496
00497 valid_next_perms = gSelectMgr->selectGetPerm(PERM_NEXT_OWNER,
00498 &next_owner_mask_on,
00499 &next_owner_mask_off);
00500
00501
00502 if( gSavedSettings.getBOOL("DebugPermissions") )
00503 {
00504 std::string perm_string;
00505 if (valid_base_perms)
00506 {
00507 perm_string = "B: ";
00508 perm_string += mask_to_string(base_mask_on);
00509 childSetText("B:",perm_string);
00510 childSetVisible("B:",true);
00511
00512 perm_string = "O: ";
00513 perm_string += mask_to_string(owner_mask_on);
00514 childSetText("O:",perm_string);
00515 childSetVisible("O:",true);
00516
00517 perm_string = "G: ";
00518 perm_string += mask_to_string(group_mask_on);
00519 childSetText("G:",perm_string);
00520 childSetVisible("G:",true);
00521
00522 perm_string = "E: ";
00523 perm_string += mask_to_string(everyone_mask_on);
00524 childSetText("E:",perm_string);
00525 childSetVisible("E:",true);
00526
00527 perm_string = "N: ";
00528 perm_string += mask_to_string(next_owner_mask_on);
00529 childSetText("N:",perm_string);
00530 childSetVisible("N:",true);
00531 }
00532 perm_string = "F: ";
00533 U32 flag_mask = 0x0;
00534 if (objectp->permMove())
00535 flag_mask |= PERM_MOVE;
00536 if (objectp->permModify())
00537 flag_mask |= PERM_MODIFY;
00538 if (objectp->permCopy())
00539 flag_mask |= PERM_COPY;
00540 if (objectp->permTransfer())
00541 flag_mask |= PERM_TRANSFER;
00542 perm_string += mask_to_string(flag_mask);
00543 childSetText("F:",perm_string);
00544 childSetVisible("F:",true);
00545 }
00546 else
00547 {
00548 childSetVisible("B:",false);
00549 childSetVisible("O:",false);
00550 childSetVisible("G:",false);
00551 childSetVisible("E:",false);
00552 childSetVisible("N:",false);
00553 childSetVisible("F:",false);
00554 }
00555
00556 bool has_change_perm_ability = false;
00557 bool has_change_sale_ability = false;
00558
00559 if(valid_base_perms
00560 && (self_owned
00561 || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_MANIPULATE))))
00562 {
00563 has_change_perm_ability = true;
00564 }
00565 if(valid_base_perms
00566 && (self_owned
00567 || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_SET_SALE))))
00568 {
00569 has_change_sale_ability = true;
00570 }
00571
00572 if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
00573 {
00574
00575 childSetValue("perm_modify", childGetText("text modify warning"));
00576 }
00577
00578 if (has_change_perm_ability)
00579 {
00580 childSetEnabled("checkbox share with group",true);
00581 childSetEnabled("checkbox allow everyone move",owner_mask_on & PERM_MOVE);
00582 childSetEnabled("checkbox allow everyone copy",owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
00583 }
00584 else
00585 {
00586 childSetEnabled("checkbox share with group", FALSE);
00587 childSetEnabled("checkbox allow everyone move", FALSE);
00588 childSetEnabled("checkbox allow everyone copy", FALSE);
00589 }
00590
00591 if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
00592 {
00593 childSetEnabled("checkbox for sale", can_transfer || (!can_transfer && is_for_sale));
00594 childSetEnabled("sale type",is_for_sale && can_transfer);
00595
00596 childSetEnabled("Next owner can:", TRUE);
00597 childSetEnabled("checkbox next owner can modify",base_mask_on & PERM_MODIFY);
00598 childSetEnabled("checkbox next owner can copy",base_mask_on & PERM_COPY);
00599 childSetEnabled("checkbox next owner can transfer",next_owner_mask_on & PERM_COPY);
00600 }
00601 else
00602 {
00603 childSetEnabled("checkbox for sale",FALSE);
00604 childSetEnabled("sale type",FALSE);
00605
00606 childSetEnabled("Next owner can:",FALSE);
00607 childSetEnabled("checkbox next owner can modify",FALSE);
00608 childSetEnabled("checkbox next owner can copy",FALSE);
00609 childSetEnabled("checkbox next owner can transfer",FALSE);
00610 }
00611
00612 if(valid_group_perms)
00613 {
00614 if((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
00615 {
00616 childSetValue("checkbox share with group",TRUE);
00617 childSetTentative("checkbox share with group",FALSE);
00618 childSetEnabled("button deed",gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
00619 }
00620 else if((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
00621 {
00622 childSetValue("checkbox share with group",FALSE);
00623 childSetTentative("checkbox share with group",false);
00624 childSetEnabled("button deed",false);
00625 }
00626 else
00627 {
00628 childSetValue("checkbox share with group",TRUE);
00629 childSetTentative("checkbox share with group",true);
00630 childSetEnabled("button deed",gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
00631 }
00632 }
00633
00634 if(valid_everyone_perms)
00635 {
00636
00637 if(everyone_mask_on & PERM_MOVE)
00638 {
00639 childSetValue("checkbox allow everyone move",TRUE);
00640 childSetTentative("checkbox allow everyone move",false);
00641 }
00642 else if(everyone_mask_off & PERM_MOVE)
00643 {
00644 childSetValue("checkbox allow everyone move",FALSE);
00645 childSetTentative("checkbox allow everyone move",false);
00646 }
00647 else
00648 {
00649 childSetValue("checkbox allow everyone move",TRUE);
00650 childSetTentative("checkbox allow everyone move",true);
00651 }
00652
00653
00654 if(everyone_mask_on & PERM_COPY)
00655 {
00656 childSetValue("checkbox allow everyone copy",TRUE);
00657 childSetTentative("checkbox allow everyone copy",!can_copy || !can_transfer);
00658 }
00659 else if(everyone_mask_off & PERM_COPY)
00660 {
00661 childSetValue("checkbox allow everyone copy",FALSE);
00662 childSetTentative("checkbox allow everyone copy",false);
00663 }
00664 else
00665 {
00666 childSetValue("checkbox allow everyone copy",TRUE);
00667 childSetTentative("checkbox allow everyone copy",true);
00668 }
00669 }
00670
00671 if(valid_next_perms)
00672 {
00673
00674 if(next_owner_mask_on & PERM_MODIFY)
00675 {
00676 childSetValue("checkbox next owner can modify",TRUE);
00677 childSetTentative("checkbox next owner can modify",false);
00678 }
00679 else if(next_owner_mask_off & PERM_MODIFY)
00680 {
00681 childSetValue("checkbox next owner can modify",FALSE);
00682 childSetTentative("checkbox next owner can modify",false);
00683 }
00684 else
00685 {
00686 childSetValue("checkbox next owner can modify",TRUE);
00687 childSetTentative("checkbox next owner can modify",true);
00688 }
00689
00690
00691 if(next_owner_mask_on & PERM_COPY)
00692 {
00693 childSetValue("checkbox next owner can copy",TRUE);
00694 childSetTentative("checkbox next owner can copy",!can_copy);
00695 }
00696 else if(next_owner_mask_off & PERM_COPY)
00697 {
00698 childSetValue("checkbox next owner can copy",FALSE);
00699 childSetTentative("checkbox next owner can copy",FALSE);
00700 }
00701 else
00702 {
00703 childSetValue("checkbox next owner can copy",TRUE);
00704 childSetTentative("checkbox next owner can copy",TRUE);
00705 }
00706
00707
00708 if(next_owner_mask_on & PERM_TRANSFER)
00709 {
00710 childSetValue("checkbox next owner can transfer",TRUE);
00711 childSetTentative("checkbox next owner can transfer",!can_transfer);
00712 }
00713 else if(next_owner_mask_off & PERM_TRANSFER)
00714 {
00715 childSetValue("checkbox next owner can transfer",FALSE);
00716 childSetTentative("checkbox next owner can transfer",FALSE);
00717 }
00718 else
00719 {
00720 childSetValue("checkbox next owner can transfer",TRUE);
00721 childSetTentative("checkbox next owner can transfer",TRUE);
00722 }
00723 }
00724
00725
00726 LLSaleInfo sale_info;
00727 BOOL valid_sale_info = gSelectMgr->selectGetSaleInfo(sale_info);
00728 LLSaleInfo::EForSale sale_type = sale_info.getSaleType();
00729
00730 LLRadioGroup* RadioSaleType = gUICtrlFactory->getRadioGroupByName(this,"sale type");
00731 if(RadioSaleType)
00732 {
00733 if (valid_sale_info)
00734 {
00735 RadioSaleType->setSelectedIndex((S32)sale_type - 1);
00736 }
00737 else
00738 {
00739
00740 RadioSaleType->setSelectedIndex((S32)LLSaleInfo::FS_COPY - 1);
00741 }
00742 }
00743
00744 childSetValue("checkbox for sale", is_for_sale);
00745
00746
00747
00748
00749 bool cannot_actually_sell = !can_transfer || (!can_copy && sale_type == LLSaleInfo::FS_COPY);
00750 if (is_for_sale && has_change_sale_ability && cannot_actually_sell)
00751 {
00752 childSetEnabled("checkbox for sale", true);
00753 }
00754
00755
00756 BOOL all_volume = gSelectMgr->selectionAllPCode( LL_PCODE_VOLUME );
00757 bool include_in_search;
00758 bool all_include_in_search = gSelectMgr->selectionGetIncludeInSearch(&include_in_search);
00759 childSetEnabled("search_check", has_change_sale_ability && all_volume);
00760 childSetValue("search_check", include_in_search);
00761 childSetTentative("search_check", ! all_include_in_search);
00762
00763
00764 U8 click_action = 0;
00765 if (gSelectMgr->selectionGetClickAction(&click_action))
00766 {
00767 LLComboBox* ComboClickAction = gUICtrlFactory->getComboBoxByName(this,"clickaction");
00768 if(ComboClickAction)
00769 {
00770 ComboClickAction->setCurrentByIndex((S32)click_action);
00771 }
00772 }
00773 childSetEnabled("label click action",is_perm_modify && all_volume);
00774 childSetEnabled("clickaction",is_perm_modify && all_volume);
00775 }
00776
00777
00778
00779 void LLPanelPermissions::onClickClaim(void*)
00780 {
00781
00782 gSelectMgr->sendOwner(gAgent.getID(), gAgent.getGroupID());
00783 }
00784
00785
00786 void LLPanelPermissions::onClickRelease(void*)
00787 {
00788
00789 gSelectMgr->sendOwner(LLUUID::null, LLUUID::null);
00790 }
00791
00792
00793 void LLPanelPermissions::onClickCreator(void *data)
00794 {
00795 LLPanelPermissions *self = (LLPanelPermissions *)data;
00796
00797 LLFloaterAvatarInfo::showFromObject(self->mCreatorID);
00798 }
00799
00800
00801 void LLPanelPermissions::onClickOwner(void *data)
00802 {
00803 LLPanelPermissions *self = (LLPanelPermissions *)data;
00804
00805 if (gSelectMgr->selectIsGroupOwned())
00806 {
00807 LLUUID group_id;
00808 gSelectMgr->selectGetGroup(group_id);
00809 LLFloaterGroupInfo::showFromUUID(group_id);
00810 }
00811 else
00812 {
00813 LLFloaterAvatarInfo::showFromObject(self->mOwnerID);
00814 }
00815 }
00816
00817 void LLPanelPermissions::onClickGroup(void* data)
00818 {
00819 LLPanelPermissions* panelp = (LLPanelPermissions*)data;
00820 LLUUID owner_id;
00821 LLString name;
00822 BOOL owners_identical = gSelectMgr->selectGetOwner(owner_id, name);
00823 LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
00824
00825 if(owners_identical && (owner_id == gAgent.getID()))
00826 {
00827 LLFloaterGroupPicker* fg;
00828 fg = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
00829 fg->setSelectCallback( cbGroupID, data );
00830
00831 if (parent_floater)
00832 {
00833 LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, fg);
00834 fg->setOrigin(new_rect.mLeft, new_rect.mBottom);
00835 parent_floater->addDependentFloater(fg);
00836 }
00837 }
00838 }
00839
00840
00841 void LLPanelPermissions::cbGroupID(LLUUID group_id, void* userdata)
00842 {
00843 LLPanelPermissions* self = (LLPanelPermissions*)userdata;
00844 if(self->mLabelGroupName)
00845 {
00846 self->mLabelGroupName->setNameID(group_id, TRUE);
00847 }
00848 gSelectMgr->sendGroup(group_id);
00849 }
00850
00851 void callback_deed_to_group(S32 option, void*)
00852 {
00853 if (0 == option)
00854 {
00855 LLUUID group_id;
00856 BOOL groups_identical = gSelectMgr->selectGetGroup(group_id);
00857 if(groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
00858 {
00859 gSelectMgr->sendOwner(LLUUID::null, group_id, FALSE);
00860
00861 }
00862 }
00863 }
00864
00865 void LLPanelPermissions::onClickDeedToGroup(void* data)
00866 {
00867 gViewerWindow->alertXml( "DeedObjectToGroup",
00868 callback_deed_to_group, NULL);
00869 }
00870
00874
00875
00876 void LLPanelPermissions::onCommitPerm(LLUICtrl *ctrl, void *data, U8 field, U32 perm)
00877 {
00878 LLViewerObject* object = gSelectMgr->getSelection()->getFirstRootObject();
00879 if(!object) return;
00880
00881
00882
00883 LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
00884 BOOL new_state = check->get();
00885
00886 gSelectMgr->selectionSetObjectPermissions(field, new_state, perm);
00887 }
00888
00889
00890 void LLPanelPermissions::onCommitGroupShare(LLUICtrl *ctrl, void *data)
00891 {
00892 onCommitPerm(ctrl, data, PERM_GROUP, PERM_MODIFY | PERM_MOVE | PERM_COPY);
00893 }
00894
00895
00896 void LLPanelPermissions::onCommitEveryoneMove(LLUICtrl *ctrl, void *data)
00897 {
00898 onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_MOVE);
00899 }
00900
00901
00902
00903 void LLPanelPermissions::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
00904 {
00905 onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_COPY);
00906 }
00907
00908
00909 void LLPanelPermissions::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
00910 {
00911
00912 onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
00913 }
00914
00915
00916 void LLPanelPermissions::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
00917 {
00918
00919 onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
00920 }
00921
00922
00923 void LLPanelPermissions::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
00924 {
00925
00926 onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
00927 }
00928
00929
00930 void LLPanelPermissions::onCommitName(LLUICtrl*, void* data)
00931 {
00932
00933 LLPanelPermissions* self = (LLPanelPermissions*)data;
00934 LLLineEditor* tb = gUICtrlFactory->getLineEditorByName(self,"Object Name");
00935 if(tb)
00936 {
00937 gSelectMgr->selectionSetObjectName(tb->getText());
00938
00939 }
00940 }
00941
00942
00943
00944 void LLPanelPermissions::onCommitDesc(LLUICtrl*, void* data)
00945 {
00946
00947 LLPanelPermissions* self = (LLPanelPermissions*)data;
00948 LLLineEditor* le = gUICtrlFactory->getLineEditorByName(self,"Object Description");
00949 if(le)
00950 {
00951 gSelectMgr->selectionSetObjectDescription(le->getText());
00952 }
00953 }
00954
00955
00956 void LLPanelPermissions::onCommitSaleInfo(LLUICtrl*, void* data)
00957 {
00958 LLPanelPermissions* self = (LLPanelPermissions*)data;
00959 self->setAllSaleInfo();
00960 }
00961
00962
00963 void LLPanelPermissions::onCommitSaleType(LLUICtrl*, void* data)
00964 {
00965 LLPanelPermissions* self = (LLPanelPermissions*)data;
00966 self->setAllSaleInfo();
00967 }
00968
00969 void LLPanelPermissions::setAllSaleInfo()
00970 {
00971 llinfos << "LLPanelPermissions::setAllSaleInfo()" << llendl;
00972 LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT;
00973
00974 LLCheckBoxCtrl* mCheckPurchase = gUICtrlFactory->getCheckBoxByName(this,"checkbox for sale");
00975
00976 if(mCheckPurchase && mCheckPurchase->get())
00977 {
00978 LLRadioGroup* RadioSaleType = gUICtrlFactory->getRadioGroupByName(this,"sale type");
00979 if(RadioSaleType)
00980 {
00981 switch(RadioSaleType->getSelectedIndex())
00982 {
00983 case 0:
00984 sale_type = LLSaleInfo::FS_ORIGINAL;
00985 break;
00986 case 1:
00987 sale_type = LLSaleInfo::FS_COPY;
00988 break;
00989 case 2:
00990 sale_type = LLSaleInfo::FS_CONTENTS;
00991 break;
00992 default:
00993 sale_type = LLSaleInfo::FS_COPY;
00994 break;
00995 }
00996 }
00997 }
00998 LLLineEditor* mEditPrice = gUICtrlFactory->getLineEditorByName(this,"EdCost");
00999
01000 S32 price = -1;
01001 if(mEditPrice)
01002 {
01003 price = atoi(mEditPrice->getText().c_str());
01004 }
01005
01006 if (price < 0)
01007 {
01008 sale_type = LLSaleInfo::FS_NOT;
01009 price = 0;
01010 }
01011
01012 LLSaleInfo sale_info(sale_type, price);
01013 gSelectMgr->selectionSetObjectSaleInfo(sale_info);
01014
01015
01016
01017 if (sale_type == LLSaleInfo::FS_NOT)
01018 {
01019 U8 click_action = 0;
01020 gSelectMgr->selectionGetClickAction(&click_action);
01021 if (click_action == CLICK_ACTION_BUY)
01022 {
01023 gSelectMgr->selectionSetClickAction(CLICK_ACTION_TOUCH);
01024 }
01025 }
01026 }
01027
01028 struct LLSelectionPayable : public LLSelectedObjectFunctor
01029 {
01030 virtual bool apply(LLViewerObject* obj)
01031 {
01032
01033 LLViewerObject* parent = (LLViewerObject*)obj->getParent();
01034 return (obj->flagTakesMoney()
01035 || (parent && parent->flagTakesMoney()));
01036 }
01037 };
01038
01039
01040 void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*)
01041 {
01042 LLComboBox* box = (LLComboBox*)ctrl;
01043 if (!box) return;
01044
01045 U8 click_action = (U8)box->getCurrentIndex();
01046 if (click_action == CLICK_ACTION_BUY)
01047 {
01048 LLSaleInfo sale_info;
01049 gSelectMgr->selectGetSaleInfo(sale_info);
01050 if (!sale_info.isForSale())
01051 {
01052 gViewerWindow->alertXml("CantSetBuyObject");
01053
01054
01055 U8 click_action = 0;
01056 gSelectMgr->selectionGetClickAction(&click_action);
01057 box->setCurrentByIndex((S32)click_action);
01058
01059 return;
01060 }
01061 }
01062 else if (click_action == CLICK_ACTION_PAY)
01063 {
01064
01065 LLSelectionPayable payable;
01066 bool can_pay = gSelectMgr->getSelection()->applyToObjects(&payable);
01067 if (!can_pay)
01068 {
01069
01070 gViewerWindow->alertXml("ClickActionNotPayable");
01071 }
01072 }
01073 gSelectMgr->selectionSetClickAction(click_action);
01074 }
01075
01076
01077 void LLPanelPermissions::onCommitIncludeInSearch(LLUICtrl* ctrl, void*)
01078 {
01079 LLCheckBoxCtrl* box = (LLCheckBoxCtrl*)ctrl;
01080 llassert(box);
01081
01082 gSelectMgr->selectionSetIncludeInSearch(box->get());
01083 }
01084