aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelpermissions.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelpermissions.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelpermissions.cpp')
-rw-r--r--linden/indra/newview/llpanelpermissions.cpp1047
1 files changed, 1047 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelpermissions.cpp b/linden/indra/newview/llpanelpermissions.cpp
new file mode 100644
index 0000000..84509a9
--- /dev/null
+++ b/linden/indra/newview/llpanelpermissions.cpp
@@ -0,0 +1,1047 @@
1/**
2 * @file llpanelpermissions.cpp
3 * @brief LLPanelPermissions class implementation
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28//*****************************************************************************
29//
30// This class represents the panel in the build view for
31// viewing/editing object names, owners, permissions, etc.
32//
33//*****************************************************************************
34
35#include "llviewerprecompiledheaders.h"
36
37#include "llpanelpermissions.h"
38
39#include "lluuid.h"
40#include "llpermissions.h"
41#include "llcategory.h"
42#include "llclickaction.h"
43#include "llfocusmgr.h"
44#include "llstring.h"
45
46#include "llviewerwindow.h"
47#include "llresmgr.h"
48#include "lltextbox.h"
49#include "llbutton.h"
50#include "llcheckboxctrl.h"
51#include "llviewerobject.h"
52#include "llselectmgr.h"
53#include "llagent.h"
54#include "llstatusbar.h" // for getBalance()
55#include "lllineeditor.h"
56#include "llradiogroup.h"
57#include "llcombobox.h"
58#include "llfloateravatarinfo.h"
59#include "lluiconstants.h"
60#include "lldbstrings.h"
61#include "llfloatergroupinfo.h"
62#include "llfloatergroups.h"
63#include "llnamebox.h"
64#include "llviewercontrol.h"
65#include "llvieweruictrlfactory.h"
66#include "roles_constants.h"
67
68///----------------------------------------------------------------------------
69/// Class llpanelpermissions
70///----------------------------------------------------------------------------
71
72// Default constructor
73
74BOOL LLPanelPermissions::postBuild()
75{
76 this->childSetCommitCallback("Object Name",LLPanelPermissions::onCommitName,this);
77 this->childSetPrevalidate("Object Name",LLLineEditor::prevalidatePrintableNotPipe);
78 this->childSetCommitCallback("Object Description",LLPanelPermissions::onCommitDesc,this);
79 this->childSetPrevalidate("Object Description",LLLineEditor::prevalidatePrintableNotPipe);
80
81
82 this->childSetAction("button owner profile",LLPanelPermissions::onClickOwner,this);
83 this->childSetAction("button creator profile",LLPanelPermissions::onClickCreator,this);
84
85 this->childSetAction("button set group",LLPanelPermissions::onClickGroup,this);
86
87 this->childSetCommitCallback("checkbox share with group",LLPanelPermissions::onCommitGroupShare,this);
88
89 this->childSetAction("button deed",LLPanelPermissions::onClickDeedToGroup,this);
90
91 this->childSetCommitCallback("checkbox allow everyone move",LLPanelPermissions::onCommitEveryoneMove,this);
92
93 this->childSetCommitCallback("checkbox allow everyone copy",LLPanelPermissions::onCommitEveryoneCopy,this);
94
95 this->childSetCommitCallback("checkbox for sale",LLPanelPermissions::onCommitSaleInfo,this);
96
97 this->childSetCommitCallback("EdCost",LLPanelPermissions::onCommitSaleInfo,this);
98 this->childSetPrevalidate("EdCost",LLLineEditor::prevalidateNonNegativeS32);
99
100 this->childSetCommitCallback("sale type",LLPanelPermissions::onCommitSaleType,this);
101
102 this->childSetCommitCallback("checkbox next owner can modify",LLPanelPermissions::onCommitNextOwnerModify,this);
103 this->childSetCommitCallback("checkbox next owner can copy",LLPanelPermissions::onCommitNextOwnerCopy,this);
104 this->childSetCommitCallback("checkbox next owner can transfer",LLPanelPermissions::onCommitNextOwnerTransfer,this);
105 this->childSetCommitCallback("clickaction",LLPanelPermissions::onCommitClickAction,this);
106
107 LLTextBox* LabelGroupNameRectProxy = gUICtrlFactory->getTextBoxByName(this,"Group Name Proxy");
108 if(LabelGroupNameRectProxy )
109 {
110 mLabelGroupName = new LLNameBox("Group Name",LabelGroupNameRectProxy->getRect());
111 addChild(mLabelGroupName);
112 }else
113 mLabelGroupName = NULL;
114
115 return TRUE;
116}
117
118LLPanelPermissions::LLPanelPermissions(const std::string& title) :
119 LLPanel(title)
120{
121 setMouseOpaque(FALSE);
122}
123
124// Destroys the object
125LLPanelPermissions::~LLPanelPermissions()
126{
127 // base class will take care of everything
128}
129
130
131void LLPanelPermissions::refresh()
132{
133
134 LLButton* BtnDeedToGroup = gUICtrlFactory->getButtonByName(this,"button deed");
135 if(BtnDeedToGroup)
136 {
137 LLString deedText;
138 if (gSavedSettings.getWarning("DeedObject"))
139 {
140 deedText = this->childGetText("text deed continued");
141 }
142 else
143 {
144 deedText = this->childGetText("text deed");
145 }
146 BtnDeedToGroup->setLabelSelected(deedText);
147 BtnDeedToGroup->setLabelUnselected(deedText);
148 }
149 BOOL root_selected = TRUE;
150 LLSelectNode* nodep = gSelectMgr->getFirstRootNode();
151 S32 object_count = gSelectMgr->getRootObjectCount();
152 if(!nodep || 0 == object_count)
153 {
154 nodep = gSelectMgr->getFirstNode();
155 object_count = gSelectMgr->getObjectCount();
156 root_selected = FALSE;
157 }
158
159 //BOOL attachment_selected = gSelectMgr->selectionIsAttachment();
160 //attachment_selected = false;
161 LLViewerObject* objectp = NULL;
162 if(nodep) objectp = nodep->getObject();
163 if(!nodep || !objectp)// || attachment_selected)
164 {
165 // ...nothing selected
166 childSetEnabled("perm_modify",false);
167 childSetText("perm_modify","");
168
169 childSetEnabled("Creator:",false);
170 childSetText("Creator Name","");
171 childSetEnabled("Creator Name",false);
172 childSetEnabled("button creator profile",false);
173
174 childSetEnabled("Owner:",false);
175 childSetText("Owner Name","");
176 childSetEnabled("Owner Name",false);
177 childSetEnabled("button owner profile",false);
178
179 childSetEnabled("Group:",false);
180 childSetText("Group Name","");
181 childSetEnabled("Group Name",false);
182 childSetEnabled("button set group",false);
183
184 childSetText("Object Name","");
185 childSetEnabled("Object Name",false);
186 childSetEnabled("Name:",false);
187 childSetText("Group Name","");
188 childSetEnabled("Group Name",false);
189 childSetEnabled("Description:",false);
190 childSetText("Object Description","");
191 childSetEnabled("Object Description",false);
192
193 childSetText("prim info","");
194 childSetEnabled("prim info",false);
195
196 childSetEnabled("Permissions:",false);
197
198 childSetValue("checkbox share with group",FALSE);
199 childSetEnabled("checkbox share with group",false);
200 childSetEnabled("button deed",false);
201
202 childSetValue("checkbox allow everyone move",FALSE);
203 childSetEnabled("checkbox allow everyone move",false);
204 childSetValue("checkbox allow everyone copy",FALSE);
205 childSetEnabled("checkbox allow everyone copy",false);
206
207 //Next owner can:
208 childSetEnabled("Next owner can:",false);
209 childSetValue("checkbox next owner can modify",FALSE);
210 childSetEnabled("checkbox next owner can modify",false);
211 childSetValue("checkbox next owner can copy",FALSE);
212 childSetEnabled("checkbox next owner can copy",false);
213 childSetValue("checkbox next owner can transfer",FALSE);
214 childSetEnabled("checkbox next owner can transfer",false);
215
216 //checkbox for sale
217 childSetValue("checkbox for sale",FALSE);
218 childSetEnabled("checkbox for sale",false);
219
220 LLRadioGroup* RadioSaleType = gUICtrlFactory->getRadioGroupByName(this,"sale type");
221 if(RadioSaleType)
222 {
223 RadioSaleType->setSelectedIndex(-1);
224 RadioSaleType->setEnabled(FALSE);
225 }
226
227 childSetEnabled("Price: L$",false);
228 childSetText("EdCost",false);
229 childSetEnabled("EdCost",false);
230
231 childSetEnabled("label click action",false);
232 LLComboBox* ComboClickAction = gUICtrlFactory->getComboBoxByName(this,"clickaction");
233 if(ComboClickAction)
234 {
235 ComboClickAction->setEnabled(FALSE);
236 ComboClickAction->clear();
237 }
238 childSetVisible("B:",false);
239 childSetVisible("O:",false);
240 childSetVisible("G:",false);
241 childSetVisible("E:",false);
242 childSetVisible("N:",false);
243 childSetVisible("F:",false);
244
245 return;
246 }
247
248 // figure out a few variables
249 BOOL is_one_object = (object_count == 1);
250
251 // BUG: fails if a root and non-root are both single-selected.
252 BOOL is_perm_modify = (gSelectMgr->getFirstRootNode()
253 && gSelectMgr->selectGetRootsModify())
254 || gSelectMgr->selectGetModify();
255 const LLView* keyboard_focus_view = gFocusMgr.getKeyboardFocus();
256 S32 string_index = 0;
257 LLString MODIFY_INFO_STRINGS[] =
258 {
259 childGetText("text modify info 1"),
260 childGetText("text modify info 2"),
261 childGetText("text modify info 3"),
262 childGetText("text modify info 4")
263 };
264 if(!is_perm_modify)
265 {
266 string_index += 2;
267 }
268 if(!is_one_object)
269 {
270 ++string_index;
271 }
272 childSetEnabled("perm_modify",true);
273 childSetText("perm_modify",MODIFY_INFO_STRINGS[string_index]);
274
275 childSetEnabled("Permissions:",true);
276
277 // Update creator text field
278 childSetEnabled("Creator:",true);
279 BOOL creators_identical;
280 LLString creator_name;
281 creators_identical = gSelectMgr->selectGetCreator(mCreatorID,
282 creator_name);
283
284 childSetText("Creator Name",creator_name);
285 childSetEnabled("Creator Name",TRUE);
286 childSetEnabled("button creator profile", creators_identical && mCreatorID.notNull() );
287
288 // Update owner text field
289 childSetEnabled("Owner:",true);
290
291 BOOL owners_identical;
292 LLString owner_name;
293 owners_identical = gSelectMgr->selectGetOwner(mOwnerID, owner_name);
294
295// llinfos << "owners_identical " << (owners_identical ? "TRUE": "FALSE") << llendl;
296
297 if (mOwnerID.isNull())
298 {
299 if(gSelectMgr->selectIsGroupOwned())
300 {
301 // Group owned already displayed by selectGetOwner
302 }
303 else
304 {
305 // Display last owner if public
306 LLString last_owner_name;
307 gSelectMgr->selectGetLastOwner(mLastOwnerID, last_owner_name);
308
309 // It should never happen that the last owner is null and the owner
310 // is null, but it seems to be a bug in the simulator right now. JC
311 if (!mLastOwnerID.isNull() && !last_owner_name.empty())
312 {
313 owner_name.append(", last ");
314 owner_name.append( last_owner_name );
315 }
316 }
317 }
318
319 childSetText("Owner Name",owner_name);
320 childSetEnabled("Owner Name",TRUE);
321 childSetEnabled("button owner profile",owners_identical && (mOwnerID.notNull() || gSelectMgr->selectIsGroupOwned()));
322
323 // update group text field
324 childSetEnabled("Group:",true);
325 LLUUID group_id;
326 BOOL groups_identical = gSelectMgr->selectGetGroup(group_id);
327 if (groups_identical)
328 {
329 if(mLabelGroupName)
330 {
331 mLabelGroupName->setNameID(group_id, TRUE);
332 mLabelGroupName->setEnabled(TRUE);
333 }
334 }
335 childSetEnabled("button set group",owners_identical && (mOwnerID == gAgent.getID()));
336
337 // figure out the contents of the name, description, & category
338 BOOL edit_name_desc = FALSE;
339 if(is_one_object && objectp->permModify())
340 {
341 edit_name_desc = TRUE;
342 }
343 if(is_one_object)
344 {
345 childSetEnabled("Name:",true);
346 LLLineEditor* LineEditorObjectName = gUICtrlFactory->getLineEditorByName(this,"Object Name");
347 if(keyboard_focus_view != LineEditorObjectName)
348 {
349 childSetText("Object Name",nodep->mName);
350 }
351
352 childSetEnabled("Description:",true);
353 LLLineEditor* LineEditorObjectDesc = gUICtrlFactory->getLineEditorByName(this,"Object Description");
354 if(LineEditorObjectDesc)
355 {
356 if(keyboard_focus_view != LineEditorObjectDesc)
357 {
358 LineEditorObjectDesc->setText(nodep->mDescription);
359 }
360 }
361 }
362
363 if(edit_name_desc)
364 {
365 childSetEnabled("Object Name",true);
366 childSetEnabled("Object Description",true);
367 }
368 else
369 {
370 childSetEnabled("Object Name",false);
371 childSetEnabled("Object Description",false);
372 }
373
374
375 // Pre-compute object info string
376 S32 prim_count = gSelectMgr->getObjectCount();
377 S32 obj_count = gSelectMgr->getRootObjectCount();
378
379 LLString object_info_string;
380 if (1 == obj_count)
381 {
382 object_info_string.assign("1 Object, ");
383 }
384 else
385 {
386 char buffer[MAX_STRING];
387 sprintf(buffer, "%d Objects, ", obj_count);
388 object_info_string.assign(buffer);
389 }
390 if (1 == prim_count)
391 {
392 object_info_string.append("1 Primitive");
393 }
394 else
395 {
396 char buffer[MAX_STRING];
397 sprintf(buffer, "%d Primitives", prim_count);
398 object_info_string.append(buffer);
399 }
400 childSetText("prim info",object_info_string);
401 childSetEnabled("prim info",true);
402
403 S32 price;
404 BOOL is_for_sale = gSelectMgr->selectIsForSale(price);
405 if (!is_for_sale)
406 {
407 price = DEFAULT_PRICE;
408 }
409
410 BOOL self_owned = (gAgent.getID() == mOwnerID);
411 BOOL group_owned = gSelectMgr->selectIsGroupOwned() ;
412 BOOL public_owned = (mOwnerID.isNull() && !gSelectMgr->selectIsGroupOwned());
413 BOOL can_transfer = gSelectMgr->selectGetRootsTransfer();
414 BOOL can_copy = gSelectMgr->selectGetRootsCopy();
415
416 if(!owners_identical)
417 {
418 childSetEnabled("Price: L$",false);
419 childSetText("EdCost","");
420 childSetEnabled("EdCost",false);
421 }
422 else if(self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
423 {
424 LLLineEditor* EditPrice = gUICtrlFactory->getLineEditorByName(this,"EdCost");
425 if(keyboard_focus_view != EditPrice)
426 {
427 childSetText("EdCost",llformat("%d",price));
428 }
429 if(is_for_sale && is_one_object && can_transfer)
430 {
431 childSetEnabled("Price: L$",true);
432 childSetEnabled("EdCost",true);
433 }
434 else
435 {
436 childSetEnabled("Price: L$",false);
437 childSetEnabled("EdCost",false);
438 }
439 }
440 else if(!public_owned)
441 {
442 // ...someone, not you, owns it
443 childSetEnabled("Price: L$",false);
444 childSetText("EdCost",llformat("%d",price));
445 childSetEnabled("EdCost",false);
446 }
447 else
448 {
449 // ...public object
450 childSetEnabled("Price: L$",false);
451 childSetText("EdCost","");
452 childSetEnabled("EdCost",false);
453 }
454
455 // Enable and disable the permissions checkboxes
456 // based on who owns the object.
457 // TODO: Creator permissions
458
459 BOOL valid_base_perms = FALSE;
460 BOOL valid_owner_perms = FALSE;
461 BOOL valid_group_perms = FALSE;
462 BOOL valid_everyone_perms = FALSE;
463 BOOL valid_next_perms = FALSE;
464
465 U32 base_mask_on;
466 U32 base_mask_off;
467 U32 owner_mask_on;
468 U32 owner_mask_off;
469 U32 group_mask_on;
470 U32 group_mask_off;
471 U32 everyone_mask_on;
472 U32 everyone_mask_off;
473 U32 next_owner_mask_on = 0;
474 U32 next_owner_mask_off = 0;
475
476 valid_base_perms = gSelectMgr->selectGetPerm(PERM_BASE,
477 &base_mask_on,
478 &base_mask_off);
479
480 valid_owner_perms = gSelectMgr->selectGetPerm(PERM_OWNER,
481 &owner_mask_on,
482 &owner_mask_off);
483
484 valid_group_perms = gSelectMgr->selectGetPerm(PERM_GROUP,
485 &group_mask_on,
486 &group_mask_off);
487
488 valid_everyone_perms = gSelectMgr->selectGetPerm(PERM_EVERYONE,
489 &everyone_mask_on,
490 &everyone_mask_off);
491
492 valid_next_perms = gSelectMgr->selectGetPerm(PERM_NEXT_OWNER,
493 &next_owner_mask_on,
494 &next_owner_mask_off);
495
496
497 if( gSavedSettings.getBOOL("DebugPermissions") )
498 {
499 char perm_string[10];
500 if (valid_base_perms)
501 {
502
503 strcpy(perm_string, "B: ");
504 mask_to_string(base_mask_on, perm_string+3);
505 childSetText("B:",perm_string);
506 childSetVisible("B:",true);
507
508 strcpy(perm_string, "O: ");
509 mask_to_string(owner_mask_on, perm_string+3);
510 childSetText("O:",perm_string);
511 childSetVisible("O:",true);
512
513 strcpy(perm_string, "G: ");
514 mask_to_string(group_mask_on, perm_string+3);
515 childSetText("G:",perm_string);
516 childSetVisible("G:",true);
517
518 strcpy(perm_string, "E: ");
519 mask_to_string(everyone_mask_on, perm_string+3);
520 childSetText("E:",perm_string);
521 childSetVisible("E:",true);
522
523 strcpy(perm_string, "N: ");
524 mask_to_string(next_owner_mask_on, perm_string+3);
525 childSetText("N:",perm_string);
526 childSetVisible("N:",true);
527 }
528 strcpy(perm_string, "F: ");
529 U32 flag_mask = 0x0;
530 if (objectp->permMove())
531 flag_mask |= PERM_MOVE;
532 if (objectp->permModify())
533 flag_mask |= PERM_MODIFY;
534 if (objectp->permCopy())
535 flag_mask |= PERM_COPY;
536 if (objectp->permTransfer())
537 flag_mask |= PERM_TRANSFER;
538 mask_to_string(flag_mask, perm_string+3);
539 childSetText("F:",perm_string);
540 childSetVisible("F:",true);
541 }
542 else
543 {
544 childSetVisible("B:",false);
545 childSetVisible("O:",false);
546 childSetVisible("G:",false);
547 childSetVisible("E:",false);
548 childSetVisible("N:",false);
549 childSetVisible("F:",false);
550 }
551
552 bool has_change_perm_ability = false;
553 bool has_change_sale_ability = false;
554
555 if(valid_base_perms
556 && (self_owned
557 || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_MANIPULATE))))
558 {
559 has_change_perm_ability = true;
560 }
561 if(valid_base_perms
562 && (self_owned
563 || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_SET_SALE))))
564 {
565 has_change_sale_ability = true;
566 }
567
568 if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
569 {
570 // XUI:translate
571 // ...must select root to choose permissions
572 childSetValue("perm_modify", "Must select entire object to set permissions.");
573 }
574
575 if (has_change_perm_ability)
576 {
577 childSetEnabled("checkbox share with group",true);
578 childSetEnabled("checkbox allow everyone move",owner_mask_on & PERM_MOVE);
579 childSetEnabled("checkbox allow everyone copy",owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
580 }
581 else
582 {
583 childSetEnabled("checkbox share with group", FALSE);
584 childSetEnabled("checkbox allow everyone move", FALSE);
585 childSetEnabled("checkbox allow everyone copy", FALSE);
586 }
587
588 if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
589 {
590 childSetEnabled("checkbox for sale", can_transfer || (!can_transfer && is_for_sale));
591 childSetEnabled("sale type",is_for_sale && can_transfer);
592
593 childSetEnabled("Next owner can:", TRUE);
594 childSetEnabled("checkbox next owner can modify",base_mask_on & PERM_MODIFY);
595 childSetEnabled("checkbox next owner can copy",base_mask_on & PERM_COPY);
596 childSetEnabled("checkbox next owner can transfer",next_owner_mask_on & PERM_COPY);
597 }
598 else
599 {
600 childSetEnabled("checkbox for sale",FALSE);
601 childSetEnabled("sale type",FALSE);
602
603 childSetEnabled("Next owner can:",FALSE);
604 childSetEnabled("checkbox next owner can modify",FALSE);
605 childSetEnabled("checkbox next owner can copy",FALSE);
606 childSetEnabled("checkbox next owner can transfer",FALSE);
607 }
608
609 if(valid_group_perms)
610 {
611 if((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
612 {
613 childSetValue("checkbox share with group",TRUE);
614 childSetTentative("checkbox share with group",FALSE);
615 childSetEnabled("button deed",gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned);
616 }
617 else if((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
618 {
619 childSetValue("checkbox share with group",FALSE);
620 childSetTentative("checkbox share with group",false);
621 childSetEnabled("button deed",false);
622 }
623 else
624 {
625 childSetValue("checkbox share with group",TRUE);
626 childSetTentative("checkbox share with group",true);
627 childSetEnabled("button deed",gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned);
628 }
629 }
630
631 if(valid_everyone_perms)
632 {
633 // Move
634 if(everyone_mask_on & PERM_MOVE)
635 {
636 childSetValue("checkbox allow everyone move",TRUE);
637 childSetTentative("checkbox allow everyone move",false);
638 }
639 else if(everyone_mask_off & PERM_MOVE)
640 {
641 childSetValue("checkbox allow everyone move",FALSE);
642 childSetTentative("checkbox allow everyone move",false);
643 }
644 else
645 {
646 childSetValue("checkbox allow everyone move",TRUE);
647 childSetTentative("checkbox allow everyone move",true);
648 }
649
650 // Copy == everyone can't copy
651 if(everyone_mask_on & PERM_COPY)
652 {
653 childSetValue("checkbox allow everyone copy",TRUE);
654 childSetTentative("checkbox allow everyone copy",!can_copy || !can_transfer);
655 }
656 else if(everyone_mask_off & PERM_COPY)
657 {
658 childSetValue("checkbox allow everyone copy",FALSE);
659 childSetTentative("checkbox allow everyone copy",false);
660 }
661 else
662 {
663 childSetValue("checkbox allow everyone copy",TRUE);
664 childSetTentative("checkbox allow everyone copy",true);
665 }
666 }
667
668 if(valid_next_perms)
669 {
670 // Modify == next owner canot modify
671 if(next_owner_mask_on & PERM_MODIFY)
672 {
673 childSetValue("checkbox next owner can modify",TRUE);
674 childSetTentative("checkbox next owner can modify",false);
675 }
676 else if(next_owner_mask_off & PERM_MODIFY)
677 {
678 childSetValue("checkbox next owner can modify",FALSE);
679 childSetTentative("checkbox next owner can modify",false);
680 }
681 else
682 {
683 childSetValue("checkbox next owner can modify",TRUE);
684 childSetTentative("checkbox next owner can modify",true);
685 }
686
687 // Copy == next owner cannot copy
688 if(next_owner_mask_on & PERM_COPY)
689 {
690 childSetValue("checkbox next owner can copy",TRUE);
691 childSetTentative("checkbox next owner can copy",!can_copy);
692 }
693 else if(next_owner_mask_off & PERM_COPY)
694 {
695 childSetValue("checkbox next owner can copy",FALSE);
696 childSetTentative("checkbox next owner can copy",FALSE);
697 }
698 else
699 {
700 childSetValue("checkbox next owner can copy",TRUE);
701 childSetTentative("checkbox next owner can copy",TRUE);
702 }
703
704 // Transfer == next owner cannot transfer
705 if(next_owner_mask_on & PERM_TRANSFER)
706 {
707 childSetValue("checkbox next owner can transfer",TRUE);
708 childSetTentative("checkbox next owner can transfer",!can_transfer);
709 }
710 else if(next_owner_mask_off & PERM_TRANSFER)
711 {
712 childSetValue("checkbox next owner can transfer",FALSE);
713 childSetTentative("checkbox next owner can transfer",FALSE);
714 }
715 else
716 {
717 childSetValue("checkbox next owner can transfer",TRUE);
718 childSetTentative("checkbox next owner can transfer",TRUE);
719 }
720 }
721
722 // reflect sale information
723 LLSaleInfo sale_info;
724 BOOL valid_sale_info = gSelectMgr->selectGetSaleInfo(sale_info);
725 LLSaleInfo::EForSale sale_type = sale_info.getSaleType();
726
727 LLRadioGroup* RadioSaleType = gUICtrlFactory->getRadioGroupByName(this,"sale type");
728 if(RadioSaleType && valid_sale_info)
729 {
730 RadioSaleType->setSelectedIndex((S32)sale_type - 1);
731 }
732
733 if (is_for_sale)
734 {
735 childSetValue("checkbox for sale",TRUE);
736 childSetTentative("checkbox for sale",!can_transfer || (!can_copy && sale_type == LLSaleInfo::FS_COPY));
737 }
738 else
739 {
740 childSetValue("checkbox for sale",FALSE);
741 childSetTentative("checkbox for sale",false);
742 }
743
744 // Click action (touch, sit, buy)
745 BOOL all_volume = gSelectMgr->selectionAllPCode( LL_PCODE_VOLUME );
746 U8 click_action = 0;
747 if (gSelectMgr->selectionGetClickAction(&click_action))
748 {
749 LLComboBox* ComboClickAction = gUICtrlFactory->getComboBoxByName(this,"clickaction");
750 if(ComboClickAction)
751 {
752 ComboClickAction->setCurrentByIndex((S32)click_action);
753 }
754 }
755 childSetEnabled("label click action",is_perm_modify && all_volume);
756 childSetEnabled("clickaction",is_perm_modify && all_volume);
757}
758
759
760// static
761void LLPanelPermissions::onClickClaim(void*)
762{
763 // try to claim ownership
764 gSelectMgr->sendOwner(gAgent.getID(), gAgent.getGroupID());
765}
766
767// static
768void LLPanelPermissions::onClickRelease(void*)
769{
770 // try to release ownership
771 gSelectMgr->sendOwner(LLUUID::null, LLUUID::null);
772}
773
774// static
775void LLPanelPermissions::onClickCreator(void *data)
776{
777 LLPanelPermissions *self = (LLPanelPermissions *)data;
778
779 LLFloaterAvatarInfo::showFromObject(self->mCreatorID);
780}
781
782// static
783void LLPanelPermissions::onClickOwner(void *data)
784{
785 LLPanelPermissions *self = (LLPanelPermissions *)data;
786
787 if (gSelectMgr->selectIsGroupOwned())
788 {
789 LLUUID group_id;
790 gSelectMgr->selectGetGroup(group_id);
791 LLFloaterGroupInfo::showFromUUID(group_id);
792 }
793 else
794 {
795 LLFloaterAvatarInfo::showFromObject(self->mOwnerID);
796 }
797}
798
799void LLPanelPermissions::onClickGroup(void* data)
800{
801 LLUUID owner_id;
802 LLString name;
803 BOOL owners_identical = gSelectMgr->selectGetOwner(owner_id, name);
804 if(owners_identical && (owner_id == gAgent.getID()))
805 {
806 LLFloaterGroups* fg;
807 fg = LLFloaterGroups::show(gAgent.getID(), LLFloaterGroups::CHOOSE_ONE);
808 fg->setOkCallback( cbGroupID, data );
809 }
810}
811
812// static
813void LLPanelPermissions::cbGroupID(LLUUID group_id, void* userdata)
814{
815 LLPanelPermissions* self = (LLPanelPermissions*)userdata;
816 if(self->mLabelGroupName)
817 {
818 self->mLabelGroupName->setNameID(group_id, TRUE);
819 }
820 gSelectMgr->sendGroup(group_id);
821}
822
823void callback_deed_to_group(S32 option, void*)
824{
825 if (0 == option)
826 {
827 LLUUID group_id;
828 BOOL groups_identical = gSelectMgr->selectGetGroup(group_id);
829 if(groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
830 {
831 gSelectMgr->sendOwner(LLUUID::null, group_id, FALSE);
832// gViewerStats->incStat(LLViewerStats::ST_RELEASE_COUNT);
833 }
834 }
835}
836
837void LLPanelPermissions::onClickDeedToGroup(void* data)
838{
839 gViewerWindow->alertXml( "DeedObjectToGroup",
840 callback_deed_to_group, NULL);
841}
842
843///----------------------------------------------------------------------------
844/// Permissions checkboxes
845///----------------------------------------------------------------------------
846
847// static
848void LLPanelPermissions::onCommitPerm(LLUICtrl *ctrl, void *data, U8 field, U32 perm)
849{
850 LLViewerObject* object = gSelectMgr->getFirstRootObject();
851 if(!object) return;
852
853 // Checkbox will have toggled itself
854 // LLPanelPermissions* self = (LLPanelPermissions*)data;
855 LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
856 BOOL new_state = check->get();
857
858 gSelectMgr->setObjectPermissions(field, new_state, perm);
859}
860
861// static
862void LLPanelPermissions::onCommitGroupShare(LLUICtrl *ctrl, void *data)
863{
864 onCommitPerm(ctrl, data, PERM_GROUP, PERM_MODIFY | PERM_MOVE | PERM_COPY);
865}
866
867// static
868void LLPanelPermissions::onCommitEveryoneMove(LLUICtrl *ctrl, void *data)
869{
870 onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_MOVE);
871}
872
873
874// static
875void LLPanelPermissions::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
876{
877 onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_COPY);
878}
879
880// static
881void LLPanelPermissions::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
882{
883 //llinfos << "LLPanelPermissions::onCommitNextOwnerModify" << llendl;
884 onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
885}
886
887// static
888void LLPanelPermissions::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
889{
890 //llinfos << "LLPanelPermissions::onCommitNextOwnerCopy" << llendl;
891 onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
892}
893
894// static
895void LLPanelPermissions::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
896{
897 //llinfos << "LLPanelPermissions::onCommitNextOwnerTransfer" << llendl;
898 onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
899}
900
901// static
902void LLPanelPermissions::onCommitName(LLUICtrl*, void* data)
903{
904 //llinfos << "LLPanelPermissions::onCommitName()" << llendl;
905 LLPanelPermissions* self = (LLPanelPermissions*)data;
906 LLLineEditor* tb = gUICtrlFactory->getLineEditorByName(self,"Object Name");
907 if(tb)
908 {
909 gSelectMgr->setObjectName(tb->getText());
910// gSelectMgr->setObjectName(self->mLabelObjectName->getText());
911 }
912}
913
914
915// static
916void LLPanelPermissions::onCommitDesc(LLUICtrl*, void* data)
917{
918 //llinfos << "LLPanelPermissions::onCommitDesc()" << llendl;
919 LLPanelPermissions* self = (LLPanelPermissions*)data;
920 LLLineEditor* le = gUICtrlFactory->getLineEditorByName(self,"Object Description");
921 if(le)
922 {
923 gSelectMgr->setObjectDescription(le->getText());
924 }
925}
926
927// static
928void LLPanelPermissions::onCommitSaleInfo(LLUICtrl*, void* data)
929{
930 LLPanelPermissions* self = (LLPanelPermissions*)data;
931 self->setAllSaleInfo();
932}
933
934// static
935void LLPanelPermissions::onCommitSaleType(LLUICtrl*, void* data)
936{
937 LLPanelPermissions* self = (LLPanelPermissions*)data;
938 self->setAllSaleInfo();
939}
940
941void LLPanelPermissions::setAllSaleInfo()
942{
943 llinfos << "LLPanelPermissions::setAllSaleInfo()" << llendl;
944 LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT;
945
946 LLCheckBoxCtrl* mCheckPurchase = gUICtrlFactory->getCheckBoxByName(this,"checkbox for sale");
947
948 if(mCheckPurchase && mCheckPurchase->get())
949 {
950 LLRadioGroup* RadioSaleType = gUICtrlFactory->getRadioGroupByName(this,"sale type");
951 if(RadioSaleType)
952 {
953 switch(RadioSaleType->getSelectedIndex())
954 {
955 case 0:
956 sale_type = LLSaleInfo::FS_ORIGINAL;
957 break;
958 case 1:
959 sale_type = LLSaleInfo::FS_COPY;
960 break;
961 case 2:
962 sale_type = LLSaleInfo::FS_CONTENTS;
963 break;
964 default:
965 sale_type = LLSaleInfo::FS_COPY;
966 break;
967 }
968 }
969 }
970 LLLineEditor* mEditPrice = gUICtrlFactory->getLineEditorByName(this,"EdCost");
971
972 S32 price = -1;
973 if(mEditPrice)
974 {
975 price = atoi(mEditPrice->getText().c_str());
976 }
977 // Invalid data - turn off the sale
978 if (price < 0)
979 {
980 sale_type = LLSaleInfo::FS_NOT;
981 price = 0;
982 }
983
984 LLSaleInfo sale_info(sale_type, price);
985 gSelectMgr->setObjectSaleInfo(sale_info);
986
987 // If turned off for-sale, make sure click-action buy is turned
988 // off as well
989 if (sale_type == LLSaleInfo::FS_NOT)
990 {
991 U8 click_action = 0;
992 gSelectMgr->selectionGetClickAction(&click_action);
993 if (click_action == CLICK_ACTION_BUY)
994 {
995 gSelectMgr->selectionSetClickAction(CLICK_ACTION_TOUCH);
996 }
997 }
998}
999
1000class LLSelectionPayable : public LLSelectedObjectFunctor
1001{
1002public:
1003 virtual bool apply(LLViewerObject* obj)
1004 {
1005 // can pay if you or your parent has money() event in script
1006 LLViewerObject* parent = (LLViewerObject*)obj->getParent();
1007 return (obj->flagTakesMoney()
1008 || (parent && parent->flagTakesMoney()));
1009 }
1010};
1011
1012// static
1013void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*)
1014{
1015 LLComboBox* box = (LLComboBox*)ctrl;
1016 if (!box) return;
1017
1018 U8 click_action = (U8)box->getCurrentIndex();
1019 if (click_action == CLICK_ACTION_BUY)
1020 {
1021 LLSaleInfo sale_info;
1022 gSelectMgr->selectGetSaleInfo(sale_info);
1023 if (!sale_info.isForSale())
1024 {
1025 gViewerWindow->alertXml("CantSetBuyObject");
1026
1027 // Set click action back to its old value
1028 U8 click_action = 0;
1029 gSelectMgr->selectionGetClickAction(&click_action);
1030 box->setCurrentByIndex((S32)click_action);
1031
1032 return;
1033 }
1034 }
1035 else if (click_action == CLICK_ACTION_PAY)
1036 {
1037 // Verify object has script with money() handler
1038 LLSelectionPayable payable;
1039 bool can_pay = gSelectMgr->applyToObjects(&payable);
1040 if (!can_pay)
1041 {
1042 // Warn, but do it anyway.
1043 gViewerWindow->alertXml("ClickActionNotPayable");
1044 }
1045 }
1046 gSelectMgr->selectionSetClickAction(click_action);
1047}