llpanelpermissions.cpp

Go to the documentation of this file.
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"                // for getBalance()
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 "lluictrlfactory.h"
00065 #include "roles_constants.h"
00066 
00070 
00071 // Default constructor
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 = getChild<LLTextBox>("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         // base class will take care of everything
00130 }
00131 
00132 
00133 void LLPanelPermissions::refresh()
00134 {
00135         LLButton*       BtnDeedToGroup = getChild<LLButton>("button deed");
00136         if(BtnDeedToGroup)
00137         {       
00138                 LLString deedText;
00139                 if (gSavedSettings.getWarning("DeedObject"))
00140                 {
00141                         deedText = getString("text deed continued");
00142                 }
00143                 else
00144                 {
00145                         deedText = getString("text deed");
00146                 }
00147                 BtnDeedToGroup->setLabelSelected(deedText);
00148                 BtnDeedToGroup->setLabelUnselected(deedText);
00149         }
00150         BOOL root_selected = TRUE;
00151         LLSelectNode* nodep = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
00152         S32 object_count = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount();
00153         if(!nodep || 0 == object_count)
00154         {
00155                 nodep = LLSelectMgr::getInstance()->getSelection()->getFirstNode();
00156                 object_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
00157                 root_selected = FALSE;
00158         }
00159 
00160         //BOOL attachment_selected = LLSelectMgr::getInstance()->getSelection()->isAttachment();
00161         //attachment_selected = false;
00162         LLViewerObject* objectp = NULL;
00163         if(nodep) objectp = nodep->getObject();
00164         if(!nodep || !objectp)// || attachment_selected)
00165         {
00166                 // ...nothing selected
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                 //Next owner can:
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                 //checkbox for sale
00218                 childSetValue("checkbox for sale",FALSE);
00219                 childSetEnabled("checkbox for sale",false);
00220 
00221                 //checkbox include in search
00222                 childSetValue("search_check", FALSE);
00223                 childSetEnabled("search_check", false);
00224                 
00225                 LLRadioGroup*   RadioSaleType = getChild<LLRadioGroup>("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 = getChild<LLComboBox>("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         // figure out a few variables
00254         BOOL is_one_object = (object_count == 1);
00255 
00256         // BUG: fails if a root and non-root are both single-selected.
00257         BOOL is_perm_modify = (LLSelectMgr::getInstance()->getSelection()->getFirstRootNode() 
00258                                                         && LLSelectMgr::getInstance()->selectGetRootsModify()) 
00259                                                         || LLSelectMgr::getInstance()->selectGetModify();
00260         const LLView* keyboard_focus_view = gFocusMgr.getKeyboardFocus();
00261         S32 string_index = 0;
00262         LLString MODIFY_INFO_STRINGS[] =
00263         {
00264                 getString("text modify info 1"),
00265                 getString("text modify info 2"),
00266                 getString("text modify info 3"),
00267                 getString("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         // Update creator text field
00283         childSetEnabled("Creator:",true);
00284         BOOL creators_identical;
00285         LLString creator_name;
00286         creators_identical = LLSelectMgr::getInstance()->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         // Update owner text field
00294         childSetEnabled("Owner:",true);
00295 
00296         BOOL owners_identical;
00297         LLString owner_name;
00298         owners_identical = LLSelectMgr::getInstance()->selectGetOwner(mOwnerID, owner_name);
00299 
00300 //      llinfos << "owners_identical " << (owners_identical ? "TRUE": "FALSE") << llendl;
00301 
00302         if (mOwnerID.isNull())
00303         {
00304                 if(LLSelectMgr::getInstance()->selectIsGroupOwned())
00305                 {
00306                         // Group owned already displayed by selectGetOwner
00307                 }
00308                 else
00309                 {
00310                         // Display last owner if public
00311                         LLString last_owner_name;
00312                         LLSelectMgr::getInstance()->selectGetLastOwner(mLastOwnerID, last_owner_name);
00313 
00314                         // It should never happen that the last owner is null and the owner
00315                         // is null, but it seems to be a bug in the simulator right now. JC
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() || LLSelectMgr::getInstance()->selectIsGroupOwned()));
00327 
00328         // update group text field
00329         childSetEnabled("Group:",true);
00330         childSetText("Group Name",LLString::null);
00331         LLUUID group_id;
00332         BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
00333         if (groups_identical)
00334         {
00335                 if(mLabelGroupName)
00336                 {
00337                         mLabelGroupName->setNameID(group_id, TRUE);
00338                         mLabelGroupName->setEnabled(TRUE);
00339                 }
00340         }
00341         else
00342         {
00343                 if(mLabelGroupName)
00344                 {
00345                         mLabelGroupName->setNameID(LLUUID::null, TRUE);
00346                         mLabelGroupName->refresh(LLUUID::null, "", "", TRUE);
00347                         mLabelGroupName->setEnabled(FALSE);
00348                 }
00349         }
00350         
00351         childSetEnabled("button set group",owners_identical && (mOwnerID == gAgent.getID()));
00352 
00353         // figure out the contents of the name, description, & category
00354         BOOL edit_name_desc = FALSE;
00355         if(is_one_object && objectp->permModify())
00356         {
00357                 edit_name_desc = TRUE;
00358         }
00359         if(is_one_object)
00360         {
00361                 childSetEnabled("Name:",true);
00362                 LLLineEditor* LineEditorObjectName = getChild<LLLineEditor>("Object Name");
00363                 if(keyboard_focus_view != LineEditorObjectName)
00364                 {
00365                         childSetText("Object Name",nodep->mName);
00366                 }
00367 
00368                 childSetEnabled("Description:",true);
00369                 LLLineEditor*   LineEditorObjectDesc = getChild<LLLineEditor>("Object Description");
00370                 if(LineEditorObjectDesc)
00371                 {
00372                         if(keyboard_focus_view != LineEditorObjectDesc)
00373                         {
00374                                 LineEditorObjectDesc->setText(nodep->mDescription);
00375                         }
00376                 }
00377         }
00378 
00379         if(edit_name_desc)
00380         {
00381                 childSetEnabled("Object Name",true);
00382                 childSetEnabled("Object Description",true);
00383         }
00384         else
00385         {
00386                 childSetEnabled("Object Name",false);
00387                 childSetEnabled("Object Description",false);
00388         }
00389 
00390 
00391         // Pre-compute object info string
00392         S32 prim_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
00393         S32 obj_count = LLSelectMgr::getInstance()->getSelection()->getRootObjectCount();
00394 
00395         LLString object_info_string;
00396         if (1 == obj_count)
00397         {
00398                 object_info_string.assign("1 Object, ");
00399         }
00400         else
00401         {
00402                 char buffer[MAX_STRING];                /*Flawfinder: ignore*/
00403                 snprintf(buffer, MAX_STRING, "%d Objects, ", obj_count);                        /* Flawfinder: ignore */
00404                 object_info_string.assign(buffer);
00405         }
00406         if (1 == prim_count)
00407         {
00408                 object_info_string.append("1 Primitive");
00409         }
00410         else
00411         {
00412                 char buffer[MAX_STRING];                /*Flawfinder: ignore*/
00413                 snprintf(buffer, MAX_STRING, "%d Primitives", prim_count);                      /* Flawfinder: ignore */
00414                 object_info_string.append(buffer);
00415         }
00416         childSetText("prim info",object_info_string);
00417         childSetEnabled("prim info",true);
00418 
00419         S32 price;
00420         BOOL is_for_sale = LLSelectMgr::getInstance()->selectIsForSale(price);
00421         if (!is_for_sale)
00422         {
00423                 price = DEFAULT_PRICE;
00424         }
00425 
00426         BOOL self_owned = (gAgent.getID() == mOwnerID);
00427         BOOL group_owned = LLSelectMgr::getInstance()->selectIsGroupOwned() ;
00428         BOOL public_owned = (mOwnerID.isNull() && !LLSelectMgr::getInstance()->selectIsGroupOwned());
00429         BOOL can_transfer = LLSelectMgr::getInstance()->selectGetRootsTransfer();
00430         BOOL can_copy = LLSelectMgr::getInstance()->selectGetRootsCopy();
00431 
00432         if(!owners_identical)
00433         {
00434                 childSetEnabled("Price:  L$",false);
00435                 childSetText("EdCost",LLString::null);
00436                 childSetEnabled("EdCost",false);
00437         }
00438         else if(self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
00439         {
00440                 LLLineEditor*   EditPrice = getChild<LLLineEditor>("EdCost");
00441                 if(keyboard_focus_view != EditPrice)
00442                 {
00443                         childSetText("EdCost",llformat("%d",price));
00444                 }
00445                 if(is_for_sale && is_one_object && can_transfer)
00446                 {
00447                         childSetEnabled("Price:  L$",true);
00448                         childSetEnabled("EdCost",true);
00449                 }
00450                 else
00451                 {
00452                         childSetEnabled("Price:  L$",false);
00453                         childSetEnabled("EdCost",false);
00454                 }
00455         }
00456         else if(!public_owned)
00457         {
00458                 // ...someone, not you, owns it
00459                 childSetEnabled("Price:  L$",false);
00460                 childSetText("EdCost",llformat("%d",price));
00461                 childSetEnabled("EdCost",false);
00462         }
00463         else
00464         {
00465                 // ...public object
00466                 childSetEnabled("Price:  L$",false);
00467                 childSetText("EdCost",LLString::null);
00468                 childSetEnabled("EdCost",false);
00469         }
00470 
00471         // Enable and disable the permissions checkboxes
00472         // based on who owns the object.
00473         // TODO: Creator permissions
00474 
00475         BOOL valid_base_perms           = FALSE;
00476         BOOL valid_owner_perms          = FALSE;
00477         BOOL valid_group_perms          = FALSE;
00478         BOOL valid_everyone_perms       = FALSE;
00479         BOOL valid_next_perms           = FALSE;
00480 
00481         U32 base_mask_on;
00482         U32 base_mask_off;
00483         U32 owner_mask_on;
00484         U32 owner_mask_off;
00485         U32 group_mask_on;
00486         U32 group_mask_off;
00487         U32 everyone_mask_on;
00488         U32 everyone_mask_off;
00489         U32 next_owner_mask_on = 0;
00490         U32 next_owner_mask_off = 0;
00491 
00492         valid_base_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_BASE,
00493                                                                           &base_mask_on,
00494                                                                           &base_mask_off);
00495 
00496         valid_owner_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_OWNER,
00497                                                                           &owner_mask_on,
00498                                                                           &owner_mask_off);
00499 
00500         valid_group_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_GROUP,
00501                                                                           &group_mask_on,
00502                                                                           &group_mask_off);
00503         
00504         valid_everyone_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_EVERYONE,
00505                                                                           &everyone_mask_on,
00506                                                                           &everyone_mask_off);
00507         
00508         valid_next_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_NEXT_OWNER,
00509                                                                           &next_owner_mask_on,
00510                                                                           &next_owner_mask_off);
00511 
00512         
00513         if( gSavedSettings.getBOOL("DebugPermissions") )
00514         {
00515                 std::string perm_string;
00516                 if (valid_base_perms)
00517                 {
00518                         perm_string = "B: ";
00519                         perm_string += mask_to_string(base_mask_on);
00520                         childSetText("B:",perm_string);
00521                         childSetVisible("B:",true);
00522                         
00523                         perm_string = "O: ";
00524                         perm_string += mask_to_string(owner_mask_on);
00525                         childSetText("O:",perm_string);
00526                         childSetVisible("O:",true);
00527                         
00528                         perm_string = "G: ";
00529                         perm_string += mask_to_string(group_mask_on);
00530                         childSetText("G:",perm_string);
00531                         childSetVisible("G:",true);
00532                         
00533                         perm_string = "E: ";
00534                         perm_string += mask_to_string(everyone_mask_on);
00535                         childSetText("E:",perm_string);
00536                         childSetVisible("E:",true);
00537                         
00538                         perm_string = "N: ";
00539                         perm_string += mask_to_string(next_owner_mask_on);
00540                         childSetText("N:",perm_string);
00541                         childSetVisible("N:",true);
00542                 }
00543                 perm_string = "F: ";
00544                 U32 flag_mask = 0x0;
00545                 if (objectp->permMove())
00546                         flag_mask |= PERM_MOVE;
00547                 if (objectp->permModify())
00548                         flag_mask |= PERM_MODIFY;
00549                 if (objectp->permCopy())
00550                         flag_mask |= PERM_COPY;
00551                 if (objectp->permTransfer())
00552                         flag_mask |= PERM_TRANSFER;
00553                 perm_string += mask_to_string(flag_mask);
00554                 childSetText("F:",perm_string);
00555                 childSetVisible("F:",true);
00556         }
00557         else
00558         {
00559                 childSetVisible("B:",false);
00560                 childSetVisible("O:",false);
00561                 childSetVisible("G:",false);
00562                 childSetVisible("E:",false);
00563                 childSetVisible("N:",false);
00564                 childSetVisible("F:",false);
00565         }
00566 
00567         bool has_change_perm_ability = false;
00568         bool has_change_sale_ability = false;
00569 
00570         if(valid_base_perms 
00571            && (self_owned 
00572                    || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_MANIPULATE))))
00573         {
00574                 has_change_perm_ability = true;
00575         }
00576         if(valid_base_perms 
00577            && (self_owned 
00578                    || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_SET_SALE))))
00579         {
00580                 has_change_sale_ability = true;
00581         }
00582 
00583         if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
00584         {
00585                 // ...must select root to choose permissions
00586                 childSetValue("perm_modify", getString("text modify warning"));
00587         }
00588 
00589         if (has_change_perm_ability)
00590         {
00591                 childSetEnabled("checkbox share with group",true);
00592                 childSetEnabled("checkbox allow everyone move",owner_mask_on & PERM_MOVE);
00593                 childSetEnabled("checkbox allow everyone copy",owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
00594         }
00595         else
00596         {
00597                 childSetEnabled("checkbox share with group", FALSE);
00598                 childSetEnabled("checkbox allow everyone move", FALSE);
00599                 childSetEnabled("checkbox allow everyone copy", FALSE);
00600         }
00601 
00602         if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
00603         {
00604                 childSetEnabled("checkbox for sale", can_transfer || (!can_transfer && is_for_sale));
00605                 childSetEnabled("sale type",is_for_sale && can_transfer);
00606 
00607                 childSetEnabled("Next owner can:", TRUE);
00608                 childSetEnabled("checkbox next owner can modify",base_mask_on & PERM_MODIFY);
00609                 childSetEnabled("checkbox next owner can copy",base_mask_on & PERM_COPY);
00610                 childSetEnabled("checkbox next owner can transfer",next_owner_mask_on & PERM_COPY);
00611         }
00612         else 
00613         {
00614                 childSetEnabled("checkbox for sale",FALSE);
00615                 childSetEnabled("sale type",FALSE);
00616 
00617                 childSetEnabled("Next owner can:",FALSE);
00618                 childSetEnabled("checkbox next owner can modify",FALSE);
00619                 childSetEnabled("checkbox next owner can copy",FALSE);
00620                 childSetEnabled("checkbox next owner can transfer",FALSE);
00621         }
00622 
00623         if(valid_group_perms)
00624         {
00625                 if((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
00626                 {
00627                         childSetValue("checkbox share with group",TRUE);
00628                         childSetTentative("checkbox share with group",FALSE);
00629                         childSetEnabled("button deed",gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
00630                 }
00631                 else if((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
00632                 {
00633                         childSetValue("checkbox share with group",FALSE);
00634                         childSetTentative("checkbox share with group",false);
00635                         childSetEnabled("button deed",false);
00636                 }
00637                 else
00638                 {
00639                         childSetValue("checkbox share with group",TRUE);
00640                         childSetTentative("checkbox share with group",true);
00641                         childSetEnabled("button deed",gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
00642                 }
00643         }                       
00644 
00645         if(valid_everyone_perms)
00646         {
00647                 // Move
00648                 if(everyone_mask_on & PERM_MOVE)
00649                 {
00650                         childSetValue("checkbox allow everyone move",TRUE);
00651                         childSetTentative("checkbox allow everyone move",false);
00652                 }
00653                 else if(everyone_mask_off & PERM_MOVE)
00654                 {
00655                         childSetValue("checkbox allow everyone move",FALSE);
00656                         childSetTentative("checkbox allow everyone move",false);
00657                 }
00658                 else
00659                 {
00660                         childSetValue("checkbox allow everyone move",TRUE);
00661                         childSetTentative("checkbox allow everyone move",true);
00662                 }
00663 
00664                 // Copy == everyone can't copy
00665                 if(everyone_mask_on & PERM_COPY)
00666                 {
00667                         childSetValue("checkbox allow everyone copy",TRUE);
00668                         childSetTentative("checkbox allow everyone copy",!can_copy || !can_transfer);
00669                 }
00670                 else if(everyone_mask_off & PERM_COPY)
00671                 {
00672                         childSetValue("checkbox allow everyone copy",FALSE);
00673                         childSetTentative("checkbox allow everyone copy",false);
00674                 }
00675                 else
00676                 {
00677                         childSetValue("checkbox allow everyone copy",TRUE);
00678                         childSetTentative("checkbox allow everyone copy",true);
00679                 }
00680         }
00681 
00682         if(valid_next_perms)
00683         {
00684                 // Modify == next owner canot modify
00685                 if(next_owner_mask_on & PERM_MODIFY)
00686                 {
00687                         childSetValue("checkbox next owner can modify",TRUE);
00688                         childSetTentative("checkbox next owner can modify",false);
00689                 }
00690                 else if(next_owner_mask_off & PERM_MODIFY)
00691                 {
00692                         childSetValue("checkbox next owner can modify",FALSE);
00693                         childSetTentative("checkbox next owner can modify",false);
00694                 }
00695                 else
00696                 {
00697                         childSetValue("checkbox next owner can modify",TRUE);
00698                         childSetTentative("checkbox next owner can modify",true);
00699                 }
00700 
00701                 // Copy == next owner cannot copy
00702                 if(next_owner_mask_on & PERM_COPY)
00703                 {                       
00704                         childSetValue("checkbox next owner can copy",TRUE);
00705                         childSetTentative("checkbox next owner can copy",!can_copy);
00706                 }
00707                 else if(next_owner_mask_off & PERM_COPY)
00708                 {
00709                         childSetValue("checkbox next owner can copy",FALSE);
00710                         childSetTentative("checkbox next owner can copy",FALSE);
00711                 }
00712                 else
00713                 {
00714                         childSetValue("checkbox next owner can copy",TRUE);
00715                         childSetTentative("checkbox next owner can copy",TRUE);
00716                 }
00717 
00718                 // Transfer == next owner cannot transfer
00719                 if(next_owner_mask_on & PERM_TRANSFER)
00720                 {
00721                         childSetValue("checkbox next owner can transfer",TRUE);
00722                         childSetTentative("checkbox next owner can transfer",!can_transfer);
00723                 }
00724                 else if(next_owner_mask_off & PERM_TRANSFER)
00725                 {
00726                         childSetValue("checkbox next owner can transfer",FALSE);
00727                         childSetTentative("checkbox next owner can transfer",FALSE);
00728                 }
00729                 else
00730                 {
00731                         childSetValue("checkbox next owner can transfer",TRUE);
00732                         childSetTentative("checkbox next owner can transfer",TRUE);
00733                 }
00734         }
00735 
00736         // reflect sale information
00737         LLSaleInfo sale_info;
00738         BOOL valid_sale_info = LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
00739         LLSaleInfo::EForSale sale_type = sale_info.getSaleType();
00740 
00741         LLRadioGroup* RadioSaleType = getChild<LLRadioGroup>("sale type");
00742         if(RadioSaleType)
00743         {
00744                 if (valid_sale_info)
00745                 {
00746                         RadioSaleType->setSelectedIndex((S32)sale_type - 1);
00747                 }
00748                 else
00749                 {
00750                         // default option is sell copy, determined to be safest
00751                         RadioSaleType->setSelectedIndex((S32)LLSaleInfo::FS_COPY - 1);
00752                 }
00753         }
00754 
00755         childSetValue("checkbox for sale", is_for_sale);
00756 
00757         // HACK: There are some old objects in world that are set for sale,
00758         // but are no-transfer.  We need to let users turn for-sale off, but only
00759         // if for-sale is set.
00760         bool cannot_actually_sell = !can_transfer || (!can_copy && sale_type == LLSaleInfo::FS_COPY);
00761         if (is_for_sale && has_change_sale_ability && cannot_actually_sell)
00762         {
00763                 childSetEnabled("checkbox for sale", true);
00764         }
00765                 
00766         // Check search status of objects
00767         BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
00768         bool include_in_search;
00769         bool all_include_in_search = LLSelectMgr::getInstance()->selectionGetIncludeInSearch(&include_in_search);
00770         childSetEnabled("search_check", has_change_sale_ability && all_volume);
00771         childSetValue("search_check", include_in_search);
00772         childSetTentative("search_check", ! all_include_in_search);
00773 
00774         // Click action (touch, sit, buy)
00775         U8 click_action = 0;
00776         if (LLSelectMgr::getInstance()->selectionGetClickAction(&click_action))
00777         {
00778                 LLComboBox*     ComboClickAction = getChild<LLComboBox>("clickaction");
00779                 if(ComboClickAction)
00780                 {
00781                         ComboClickAction->setCurrentByIndex((S32)click_action);
00782                 }
00783         }
00784         childSetEnabled("label click action",is_perm_modify && all_volume);
00785         childSetEnabled("clickaction",is_perm_modify && all_volume);
00786 }
00787 
00788 
00789 // static
00790 void LLPanelPermissions::onClickClaim(void*)
00791 {
00792         // try to claim ownership
00793         LLSelectMgr::getInstance()->sendOwner(gAgent.getID(), gAgent.getGroupID());
00794 }
00795 
00796 // static
00797 void LLPanelPermissions::onClickRelease(void*)
00798 {
00799         // try to release ownership
00800         LLSelectMgr::getInstance()->sendOwner(LLUUID::null, LLUUID::null);
00801 }
00802 
00803 // static
00804 void LLPanelPermissions::onClickCreator(void *data)
00805 {
00806         LLPanelPermissions *self = (LLPanelPermissions *)data;
00807 
00808         LLFloaterAvatarInfo::showFromObject(self->mCreatorID);
00809 }
00810 
00811 // static
00812 void LLPanelPermissions::onClickOwner(void *data)
00813 {
00814         LLPanelPermissions *self = (LLPanelPermissions *)data;
00815 
00816         if (LLSelectMgr::getInstance()->selectIsGroupOwned())
00817         {
00818                 LLUUID group_id;
00819                 LLSelectMgr::getInstance()->selectGetGroup(group_id);
00820                 LLFloaterGroupInfo::showFromUUID(group_id);
00821         }
00822         else
00823         {
00824                 LLFloaterAvatarInfo::showFromObject(self->mOwnerID);
00825         }
00826 }
00827 
00828 void LLPanelPermissions::onClickGroup(void* data)
00829 {
00830         LLPanelPermissions* panelp = (LLPanelPermissions*)data;
00831         LLUUID owner_id;
00832         LLString name;
00833         BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, name);
00834         LLFloater* parent_floater = gFloaterView->getParentFloater(panelp);
00835 
00836         if(owners_identical && (owner_id == gAgent.getID()))
00837         {
00838                 LLFloaterGroupPicker* fg;
00839                 fg = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID()));
00840                 fg->setSelectCallback( cbGroupID, data );
00841 
00842                 if (parent_floater)
00843                 {
00844                         LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, fg);
00845                         fg->setOrigin(new_rect.mLeft, new_rect.mBottom);
00846                         parent_floater->addDependentFloater(fg);
00847                 }
00848         }
00849 }
00850 
00851 // static
00852 void LLPanelPermissions::cbGroupID(LLUUID group_id, void* userdata)
00853 {
00854         LLPanelPermissions* self = (LLPanelPermissions*)userdata;
00855         if(self->mLabelGroupName)
00856         {
00857                 self->mLabelGroupName->setNameID(group_id, TRUE);
00858         }
00859         LLSelectMgr::getInstance()->sendGroup(group_id);
00860 }
00861 
00862 void callback_deed_to_group(S32 option, void*)
00863 {
00864         if (0 == option)
00865         {
00866                 LLUUID group_id;
00867                 BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
00868                 if(group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
00869                 {
00870                         LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
00871 //                      LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
00872                 }
00873         }
00874 }
00875 
00876 void LLPanelPermissions::onClickDeedToGroup(void* data)
00877 {
00878                         gViewerWindow->alertXml( "DeedObjectToGroup",
00879                         callback_deed_to_group, NULL);
00880 }
00881 
00885 
00886 // static
00887 void LLPanelPermissions::onCommitPerm(LLUICtrl *ctrl, void *data, U8 field, U32 perm)
00888 {
00889         LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
00890         if(!object) return;
00891 
00892         // Checkbox will have toggled itself
00893         // LLPanelPermissions* self = (LLPanelPermissions*)data;
00894         LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
00895         BOOL new_state = check->get();
00896         
00897         LLSelectMgr::getInstance()->selectionSetObjectPermissions(field, new_state, perm);
00898 }
00899 
00900 // static
00901 void LLPanelPermissions::onCommitGroupShare(LLUICtrl *ctrl, void *data)
00902 {
00903         onCommitPerm(ctrl, data, PERM_GROUP, PERM_MODIFY | PERM_MOVE | PERM_COPY);
00904 }
00905 
00906 // static
00907 void LLPanelPermissions::onCommitEveryoneMove(LLUICtrl *ctrl, void *data)
00908 {
00909         onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_MOVE);
00910 }
00911 
00912 
00913 // static
00914 void LLPanelPermissions::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
00915 {
00916         onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_COPY);
00917 }
00918 
00919 // static
00920 void LLPanelPermissions::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
00921 {
00922         //llinfos << "LLPanelPermissions::onCommitNextOwnerModify" << llendl;
00923         onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
00924 }
00925 
00926 // static
00927 void LLPanelPermissions::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
00928 {
00929         //llinfos << "LLPanelPermissions::onCommitNextOwnerCopy" << llendl;
00930         onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
00931 }
00932 
00933 // static
00934 void LLPanelPermissions::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
00935 {
00936         //llinfos << "LLPanelPermissions::onCommitNextOwnerTransfer" << llendl;
00937         onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
00938 }
00939 
00940 // static
00941 void LLPanelPermissions::onCommitName(LLUICtrl*, void* data)
00942 {
00943         //llinfos << "LLPanelPermissions::onCommitName()" << llendl;
00944         LLPanelPermissions* self = (LLPanelPermissions*)data;
00945         LLLineEditor*   tb = self->getChild<LLLineEditor>("Object Name");
00946         if(tb)
00947         {
00948                 LLSelectMgr::getInstance()->selectionSetObjectName(tb->getText());
00949 //              LLSelectMgr::getInstance()->selectionSetObjectName(self->mLabelObjectName->getText());
00950         }
00951 }
00952 
00953 
00954 // static
00955 void LLPanelPermissions::onCommitDesc(LLUICtrl*, void* data)
00956 {
00957         //llinfos << "LLPanelPermissions::onCommitDesc()" << llendl;
00958         LLPanelPermissions* self = (LLPanelPermissions*)data;
00959         LLLineEditor*   le = self->getChild<LLLineEditor>("Object Description");
00960         if(le)
00961         {
00962                 LLSelectMgr::getInstance()->selectionSetObjectDescription(le->getText());
00963         }
00964 }
00965 
00966 // static
00967 void LLPanelPermissions::onCommitSaleInfo(LLUICtrl*, void* data)
00968 {
00969         LLPanelPermissions* self = (LLPanelPermissions*)data;
00970         self->setAllSaleInfo();
00971 }
00972 
00973 // static
00974 void LLPanelPermissions::onCommitSaleType(LLUICtrl*, void* data)
00975 {
00976         LLPanelPermissions* self = (LLPanelPermissions*)data;
00977         self->setAllSaleInfo();
00978 }
00979 
00980 void LLPanelPermissions::setAllSaleInfo()
00981 {
00982         llinfos << "LLPanelPermissions::setAllSaleInfo()" << llendl;
00983         LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT;
00984 
00985         LLCheckBoxCtrl* mCheckPurchase = getChild<LLCheckBoxCtrl>("checkbox for sale");
00986 
00987         if(mCheckPurchase && mCheckPurchase->get())
00988         {
00989                 LLRadioGroup* RadioSaleType = getChild<LLRadioGroup>("sale type");
00990                 if(RadioSaleType)
00991                 {
00992                         switch(RadioSaleType->getSelectedIndex())
00993                         {
00994                         case 0:
00995                                 sale_type = LLSaleInfo::FS_ORIGINAL;
00996                                 break;
00997                         case 1:
00998                                 sale_type = LLSaleInfo::FS_COPY;
00999                                 break;
01000                         case 2:
01001                                 sale_type = LLSaleInfo::FS_CONTENTS;
01002                                 break;
01003                         default:
01004                                 sale_type = LLSaleInfo::FS_COPY;
01005                                 break;
01006                         }
01007                 }
01008         }
01009         LLLineEditor*   mEditPrice = getChild<LLLineEditor>("EdCost");
01010 
01011         S32 price = -1;
01012         if(mEditPrice)
01013         {
01014                 price = atoi(mEditPrice->getText().c_str());
01015         }
01016         // Invalid data - turn off the sale
01017         if (price < 0)
01018         {
01019                 sale_type = LLSaleInfo::FS_NOT;
01020                 price = 0;
01021         }
01022 
01023         LLSaleInfo sale_info(sale_type, price);
01024         LLSelectMgr::getInstance()->selectionSetObjectSaleInfo(sale_info);
01025 
01026         // If turned off for-sale, make sure click-action buy is turned
01027         // off as well
01028         if (sale_type == LLSaleInfo::FS_NOT)
01029         {
01030                 U8 click_action = 0;
01031                 LLSelectMgr::getInstance()->selectionGetClickAction(&click_action);
01032                 if (click_action == CLICK_ACTION_BUY)
01033                 {
01034                         LLSelectMgr::getInstance()->selectionSetClickAction(CLICK_ACTION_TOUCH);
01035                 }
01036         }
01037 }
01038 
01039 struct LLSelectionPayable : public LLSelectedObjectFunctor
01040 {
01041         virtual bool apply(LLViewerObject* obj)
01042         {
01043                 // can pay if you or your parent has money() event in script
01044                 LLViewerObject* parent = (LLViewerObject*)obj->getParent();
01045                 return (obj->flagTakesMoney() 
01046                            || (parent && parent->flagTakesMoney()));
01047         }
01048 };
01049 
01050 // static
01051 void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*)
01052 {
01053         LLComboBox* box = (LLComboBox*)ctrl;
01054         if (!box) return;
01055 
01056         U8 click_action = (U8)box->getCurrentIndex();
01057         if (click_action == CLICK_ACTION_BUY)
01058         {
01059                 LLSaleInfo sale_info;
01060                 LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
01061                 if (!sale_info.isForSale())
01062                 {
01063                         gViewerWindow->alertXml("CantSetBuyObject");
01064 
01065                         // Set click action back to its old value
01066                         U8 click_action = 0;
01067                         LLSelectMgr::getInstance()->selectionGetClickAction(&click_action);
01068                         box->setCurrentByIndex((S32)click_action);
01069 
01070                         return;
01071                 }
01072         }
01073         else if (click_action == CLICK_ACTION_PAY)
01074         {
01075                 // Verify object has script with money() handler
01076                 LLSelectionPayable payable;
01077                 bool can_pay = LLSelectMgr::getInstance()->getSelection()->applyToObjects(&payable);
01078                 if (!can_pay)
01079                 {
01080                         // Warn, but do it anyway.
01081                         gViewerWindow->alertXml("ClickActionNotPayable");
01082                 }
01083         }
01084         LLSelectMgr::getInstance()->selectionSetClickAction(click_action);
01085 }
01086 
01087 // static
01088 void LLPanelPermissions::onCommitIncludeInSearch(LLUICtrl* ctrl, void*)
01089 {
01090         LLCheckBoxCtrl* box = (LLCheckBoxCtrl*)ctrl;
01091         llassert(box);
01092 
01093         LLSelectMgr::getInstance()->selectionSetIncludeInSearch(box->get());
01094 }
01095 

Generated on Fri May 16 08:33:55 2008 for SecondLife by  doxygen 1.5.5