aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterbulkpermission.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llfloaterbulkpermission.cpp')
-rw-r--r--linden/indra/newview/llfloaterbulkpermission.cpp488
1 files changed, 134 insertions, 354 deletions
diff --git a/linden/indra/newview/llfloaterbulkpermission.cpp b/linden/indra/newview/llfloaterbulkpermission.cpp
index e66d1af..d4e1e98 100644
--- a/linden/indra/newview/llfloaterbulkpermission.cpp
+++ b/linden/indra/newview/llfloaterbulkpermission.cpp
@@ -1,10 +1,11 @@
1/** 1/**
2 * @file llfloaterbulkpermissions.cpp 2 * @file llfloaterbulkpermissions.cpp
3 * @author Michelle2 Zenovka
3 * @brief A floater which allows task inventory item's properties to be changed on mass. 4 * @brief A floater which allows task inventory item's properties to be changed on mass.
4 * 5 *
5 * $LicenseInfo:firstyear=2008&license=viewergpl$ 6 * $LicenseInfo:firstyear=2008&license=viewergpl$
6 * 7 *
7 * Copyright (c) 2008, Linden Research, Inc. 8 * Copyright (c) 2008-2009, Linden Research, Inc.
8 * 9 *
9 * Second Life Viewer Source Code 10 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -17,7 +18,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 18 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 19 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 20 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 21 * online at
22 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 23 *
22 * By copying, modifying or distributing this software, you acknowledge 24 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 25 * that you have read and understood your obligations described above,
@@ -29,20 +31,10 @@
29 * $/LicenseInfo$ 31 * $/LicenseInfo$
30 */ 32 */
31 33
32/* Allow multiple task inventory properties to be set in one go, by Michelle2 Zenovka */
33
34/* TODO
35
36 * Add in the option to select objects or task inventory
37s
38
39It would be nice to set the permissions on groups of prims as well as task inventory
40
41*/
42
43 34
44#include "llviewerprecompiledheaders.h" 35#include "llviewerprecompiledheaders.h"
45#include "llfloaterbulkpermission.h" 36#include "llfloaterbulkpermission.h"
37#include "llfloaterperms.h" // for utilities
46#include "llagent.h" 38#include "llagent.h"
47#include "llchat.h" 39#include "llchat.h"
48#include "llviewerwindow.h" 40#include "llviewerwindow.h"
@@ -60,192 +52,59 @@ It would be nice to set the permissions on groups of prims as well as task inven
60#include "llviewerstats.h" 52#include "llviewerstats.h"
61#include "lluictrlfactory.h" 53#include "lluictrlfactory.h"
62#include "llselectmgr.h" 54#include "llselectmgr.h"
63#include "llinventory.h"
64
65
66#include <algorithm>
67#include <functional>
68#include "llcachename.h"
69#include "lldbstrings.h"
70#include "llinventory.h"
71
72#include "llagent.h"
73#include "llbutton.h"
74#include "llcheckboxctrl.h"
75#include "llfloateravatarinfo.h"
76#include "llfloatergroupinfo.h"
77#include "llinventorymodel.h"
78#include "lllineeditor.h"
79#include "llradiogroup.h"
80#include "llresmgr.h"
81#include "roles_constants.h"
82#include "llselectmgr.h"
83#include "lltextbox.h"
84#include "lluiconstants.h"
85#include "llviewerinventory.h"
86#include "llviewerobjectlist.h"
87#include "llviewerregion.h"
88#include "llviewercontrol.h"
89
90#include "lluictrlfactory.h"
91
92
93const char* BULKPERM_QUEUE_TITLE = "Update Progress";
94const char* BULKPERM_START_STRING = "update";
95
96namespace
97{
98 struct BulkQueueObjects : public LLSelectedObjectFunctor
99 {
100 BOOL scripted;
101 BOOL modifiable;
102 LLFloaterBulkPermission* mQueue;
103 BulkQueueObjects(LLFloaterBulkPermission* q) : mQueue(q), scripted(FALSE), modifiable(FALSE) {}
104 virtual bool apply(LLViewerObject* obj)
105 {
106 scripted = obj->flagScripted();
107 modifiable = obj->permModify();
108
109 mQueue->addObject(obj->getID());
110 return false;
111
112 }
113 };
114}
115
116///----------------------------------------------------------------------------
117/// Class LLFloaterBulkPermission
118///----------------------------------------------------------------------------
119 55
120// static 56#include "roles_constants.h" // for GP_OBJECT_MANIPULATE
121LLMap<LLUUID, LLFloaterBulkPermission*> LLFloaterBulkPermission::sInstances;
122 57
123 58
124// Default constructor 59LLFloaterBulkPermission::LLFloaterBulkPermission(const LLSD& seed) : mDone(FALSE)
125LLFloaterBulkPermission::LLFloaterBulkPermission(const std::string& name,
126 const LLRect& rect,
127 const char* title,
128 const char* start_string) :
129 LLFloater(name, rect, title,
130 RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT,
131 DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES)
132{ 60{
133 61 mID.generate();
134 req_perm_mask=0; // This should match the default state the checkboxes are set to
135 recurse=false;
136
137 LLUICtrlFactory::getInstance()->buildFloater(this,"floater_bulk_perms.xml"); 62 LLUICtrlFactory::getInstance()->buildFloater(this,"floater_bulk_perms.xml");
138 63 childSetEnabled("next_owner_transfer", gSavedSettings.getBOOL("BulkChangeNextOwnerCopy"));
139 childSetAction("Apply...",onApplyBtn,this); 64 childSetAction("help", onHelpBtn, this);
140 childSetEnabled("Apply...",TRUE); 65 childSetAction("apply", onApplyBtn, this);
141 66 childSetAction("close", onCloseBtn, this);
142 childSetCommitCallback("Modify",&onCommitPermissions, this); 67 childSetAction("check_all", onCheckAll, this);
143 childSetCommitCallback("Trans",&onCommitPermissions, this); 68 childSetAction("check_none", onUncheckAll, this);
144 childSetCommitCallback("Copy",&onCommitPermissions, this); 69 childSetCommitCallback("next_owner_copy", &onCommitCopy, this);
145
146 //childSetCommitCallback("Recurse",&onRecurse, this);
147
148 childSetCommitCallback("Parent",&onParent, this);
149
150 childSetCommitCallback("objects",&InvSelection, this);
151 childSetCommitCallback("scripts",&InvSelection, this);
152 childSetCommitCallback("textures",&InvSelection, this);
153 childSetCommitCallback("sounds",&InvSelection, this);
154 childSetCommitCallback("animations",&InvSelection, this);
155 childSetCommitCallback("notecards",&InvSelection, this);
156 childSetCommitCallback("landmarks",&InvSelection, this);
157 childSetCommitCallback("bodyparts",&InvSelection, this);
158 childSetCommitCallback("clothing",&InvSelection, this);
159 childSetCommitCallback("gestures",&InvSelection, this);
160
161 //Set variable state to XUI default state consistancy
162 processObject=getChild<LLCheckBoxCtrl>("objects")->get();
163 processScript=getChild<LLCheckBoxCtrl>("scripts")->get();
164 processTexture=getChild<LLCheckBoxCtrl>("textures")->get();
165 processSound=getChild<LLCheckBoxCtrl>("sounds")->get();
166 processAnimation=getChild<LLCheckBoxCtrl>("animations")->get();
167 processNotecard=getChild<LLCheckBoxCtrl>("notecards")->get();
168 processGesture=getChild<LLCheckBoxCtrl>("gestures")->get();
169 processClothing=getChild<LLCheckBoxCtrl>("clothing")->get();
170 processBodypart=getChild<LLCheckBoxCtrl>("bodyparts")->get();
171 processLandmark=getChild<LLCheckBoxCtrl>("landmarks")->get();
172 parent=getChild<LLCheckBoxCtrl>("Parent")->get();
173
174
175 setTitle(title);
176
177 if (!getHost())
178 {
179 LLRect curRect = getRect();
180 translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
181 }
182
183 mStartString = start_string;
184 mDone = FALSE;
185 sInstances.addData(mID, this);
186
187} 70}
188 71
189void LLFloaterBulkPermission::doApply() 72void LLFloaterBulkPermission::doApply()
190{ 73{
191 // Its alive now do the nasty work that the ScriptQueue and friends try to do in the menu code 74 // Inspects a stream of selected object contents and adds modifiable ones to the given array.
192 // but first grab the user options 75 class ModifiableGatherer : public LLSelectedNodeFunctor
193
194 LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
195 list->deleteAllItems();
196
197 //Apply to selected objects if requested first
198
199 if(parent)
200 {
201 llinfos<< "Setting permission on parent items" << llendl;
202 LLSelectMgr::getInstance()->selectionSetObjectPermissions(PERM_NEXT_OWNER,true, req_perm_mask);
203 LLSelectMgr::getInstance()->selectionSetObjectPermissions(PERM_NEXT_OWNER,false, ~req_perm_mask); //How annoying need to set and unset
204 }
205
206
207 LLFloaterBulkPermission* q;
208 q=(LLFloaterBulkPermission*)this;
209
210 BulkQueueObjects func(q);
211 bool fail = LLSelectMgr::getInstance()->getSelection()->applyToObjects(&func);
212 if(fail)
213 { 76 {
214 if ( !func.modifiable ) 77 public:
215 { 78 ModifiableGatherer(LLDynamicArray<LLUUID>& q) : mQueue(q) {}
216 gViewerWindow->alertXml("NO MODIFY"); 79 virtual bool apply(LLSelectNode* node)
217 }
218 else
219 { 80 {
220 llwarns << "Bad logic. Are there actualy any items in that prim?" << llendl; 81 if( node->allowOperationOnNode(PERM_MODIFY, GP_OBJECT_MANIPULATE) )
82 {
83 mQueue.put(node->getObject()->getID());
84 }
85 return true;
221 } 86 }
87 private:
88 LLDynamicArray<LLUUID>& mQueue;
89 };
90 LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
91 list->deleteAllItems();
92 ModifiableGatherer gatherer(mObjectIDs);
93 LLSelectMgr::getInstance()->getSelection()->applyToNodes(&gatherer);
94 if(mObjectIDs.empty())
95 {
96 list->addCommentText(getString("nothing_to_modify_text"));
222 } 97 }
223 else 98 else
224 { 99 {
225 if (!q->start()) 100 mDone = FALSE;
101 if (!start())
226 { 102 {
227 llwarns << "Unexpected failure attepmting to set permissions." << llendl; 103 llwarns << "Unexpected bulk permission change failure." << llendl;
228 } 104 }
229 } 105 }
230} 106}
231 107
232// Destroys the object
233LLFloaterBulkPermission::~LLFloaterBulkPermission()
234{
235 sInstances.removeData(mID);
236}
237
238// find an instance by ID. Return NULL if it does not exist.
239// static
240LLFloaterBulkPermission* LLFloaterBulkPermission::findInstance(const LLUUID& id)
241{
242 if(sInstances.checkData(id))
243 {
244 return sInstances.getData(id);
245 }
246 return NULL;
247}
248
249 108
250// This is the callback method for the viewer object currently being 109// This is the callback method for the viewer object currently being
251// worked on. 110// worked on.
@@ -255,8 +114,7 @@ void LLFloaterBulkPermission::inventoryChanged(LLViewerObject* viewer_object,
255 S32, 114 S32,
256 void* q_id) 115 void* q_id)
257{ 116{
258 llinfos << "LLFloaterBulkPermission::inventoryChanged() for object " 117 //llinfos << "changed object: " << viewer_object->getID() << llendl;
259 << viewer_object->getID() << llendl;
260 118
261 //Remove this listener from the object since its 119 //Remove this listener from the object since its
262 //listener callback is now being executed. 120 //listener callback is now being executed.
@@ -281,116 +139,50 @@ void LLFloaterBulkPermission::inventoryChanged(LLViewerObject* viewer_object,
281 // something went wrong... 139 // something went wrong...
282 // note that we're not working on this one, and move onto the 140 // note that we're not working on this one, and move onto the
283 // next object in the list. 141 // next object in the list.
284 llwarns << "No inventory for " << mCurrentObjectID 142 llwarns << "No inventory for " << mCurrentObjectID << llendl;
285 << llendl;
286 nextObject(); 143 nextObject();
287 } 144 }
288} 145}
289 146
290void LLFloaterBulkPermission::onApplyBtn(void* user_data) 147void LLFloaterBulkPermission::onApplyBtn(void* user_data)
291{ 148{
292 LLFloaterBulkPermission* self = (LLFloaterBulkPermission*)user_data; 149 LLFloaterBulkPermission* self = static_cast<LLFloaterBulkPermission*>(user_data);
293 self->doApply(); 150 self->doApply();
294} 151}
295 152
296 153void LLFloaterBulkPermission::onHelpBtn(void* user_data)
297// static
298void LLFloaterBulkPermission::InvSelection(LLUICtrl* ctrl, void* data)
299{
300 LLFloaterBulkPermission* self = (LLFloaterBulkPermission*)data;
301
302 self->processObject=self->getChild<LLCheckBoxCtrl>("objects")->get();
303 self->processScript=self->getChild<LLCheckBoxCtrl>("scripts")->get();
304 self->processTexture=self->getChild<LLCheckBoxCtrl>("textures")->get();
305 self->processSound=self->getChild<LLCheckBoxCtrl>("sounds")->get();
306 self->processAnimation=self->getChild<LLCheckBoxCtrl>("animations")->get();
307 self->processNotecard=self->getChild<LLCheckBoxCtrl>("notecards")->get();
308 self->processGesture=self->getChild<LLCheckBoxCtrl>("gestures")->get();
309 self->processClothing=self->getChild<LLCheckBoxCtrl>("clothing")->get();
310 self->processBodypart=self->getChild<LLCheckBoxCtrl>("bodyparts")->get();
311 self->processLandmark=self->getChild<LLCheckBoxCtrl>("landmarks")->get();
312
313
314}
315
316// static
317void LLFloaterBulkPermission::onParent(LLUICtrl* ctrl, void* data)
318{ 154{
319 LLFloaterBulkPermission* self = (LLFloaterBulkPermission*)data; 155 LLNotifications::instance().add("HelpBulkPermission");
320 self->parent=self->getChild<LLCheckBoxCtrl>("Parent")->get();
321} 156}
322 157
323// static 158void LLFloaterBulkPermission::onCloseBtn(void* user_data)
324void LLFloaterBulkPermission::onRecurse(LLUICtrl* ctrl, void* data)
325{ 159{
326 LLFloaterBulkPermission* self = (LLFloaterBulkPermission*)data; 160 LLFloaterBulkPermission* self = static_cast<LLFloaterBulkPermission*>(user_data);
327 self->recurse=self->getChild<LLCheckBoxCtrl>("Recurse")->get(); 161 self->onClose(false);
328} 162}
329 163
330// static 164//static
331void LLFloaterBulkPermission::onCommitPermissions(LLUICtrl* ctrl, void* data) 165void LLFloaterBulkPermission::onCommitCopy(LLUICtrl* ctrl, void* data)
332{ 166{
333 LLFloaterBulkPermission* self = (LLFloaterBulkPermission*)data; 167 LLFloaterBulkPermission* self = static_cast<LLFloaterBulkPermission*>(data);
334 LLCheckBoxCtrl* CheckModify = self->getChild<LLCheckBoxCtrl>("Modify"); 168 // Implements fair use
335 LLCheckBoxCtrl* CheckCopy = self->getChild<LLCheckBoxCtrl>("Copy"); 169 BOOL copyable = gSavedSettings.getBOOL("BulkChangeNextOwnerCopy");
336 LLCheckBoxCtrl* CheckTrans = self->getChild<LLCheckBoxCtrl>("Trans"); 170 if(!copyable)
337
338 self->req_perm_mask=0;
339
340 if(CheckModify->get())
341 {
342 self->req_perm_mask|=PERM_MODIFY;
343 }
344 else
345 {
346 self->req_perm_mask&=~PERM_MODIFY;
347 }
348
349 if(CheckCopy->get())
350 {
351 self->req_perm_mask|=PERM_COPY;
352 }
353 else
354 {
355 self->req_perm_mask&=~PERM_COPY;
356 }
357
358 if(CheckTrans->get())
359 { 171 {
360 self->req_perm_mask|=PERM_TRANSFER; 172 gSavedSettings.setBOOL("BulkChangeNextOwnerTransfer", TRUE);
361 } 173 }
362 else 174 LLCheckBoxCtrl* xfer = self->getChild<LLCheckBoxCtrl>("next_owner_transfer");
363 { 175 xfer->setEnabled(copyable);
364 self->req_perm_mask&=~PERM_TRANSFER;
365 }
366
367
368}
369
370void LLFloaterBulkPermission::addObject(const LLUUID& id)
371{
372 mObjectIDs.put(id);
373} 176}
374 177
375BOOL LLFloaterBulkPermission::start() 178BOOL LLFloaterBulkPermission::start()
376{ 179{
377 llinfos << "LLFloaterBulkPermission::start()" << llendl; 180 // note: number of top-level objects to modify is mObjectIDs.count().
378 char buffer[MAX_STRING]; /*Flawfinder: ignore*/ 181 getChild<LLScrollListCtrl>("queue output")->addCommentText(getString("start_text"));
379 snprintf(buffer, sizeof(buffer), "Starting %s of %d items.", mStartString, mObjectIDs.count()); /* Flawfinder: ignore */
380
381 LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
382 list->addCommentText(buffer);
383
384 return nextObject(); 182 return nextObject();
385} 183}
386 184
387BOOL LLFloaterBulkPermission::isDone() const 185// Go to the next object and start if found. Returns false if no objects left, true otherwise.
388{
389 return (mCurrentObjectID.isNull() || (mObjectIDs.count() == 0));
390}
391
392// go to the next object. If no objects left, it falls out silently
393// and waits to be killed by the window being closed.
394BOOL LLFloaterBulkPermission::nextObject() 186BOOL LLFloaterBulkPermission::nextObject()
395{ 187{
396 S32 count; 188 S32 count;
@@ -398,60 +190,47 @@ BOOL LLFloaterBulkPermission::nextObject()
398 do 190 do
399 { 191 {
400 count = mObjectIDs.count(); 192 count = mObjectIDs.count();
401 llinfos << "LLFloaterBulkPermission::nextObject() - " << count 193 //llinfos << "Objects left to process = " << count << llendl;
402 << " objects left to process." << llendl;
403 mCurrentObjectID.setNull(); 194 mCurrentObjectID.setNull();
404 if(count > 0) 195 if(count > 0)
405 { 196 {
406 successful_start = popNext(); 197 successful_start = popNext();
198 //llinfos << (successful_start ? "successful" : "unsuccessful") << llendl;
407 } 199 }
408 llinfos << "LLFloaterBulkPermission::nextObject() "
409 << (successful_start ? "successful" : "unsuccessful")
410 << llendl;
411 } while((mObjectIDs.count() > 0) && !successful_start); 200 } while((mObjectIDs.count() > 0) && !successful_start);
412 201
413 if(isDone() && !mDone) 202 if(isDone() && !mDone)
414 { 203 {
415 204 getChild<LLScrollListCtrl>("queue output")->addCommentText(getString("done_text"));
416 LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
417 mDone = TRUE; 205 mDone = TRUE;
418 char buffer[MAX_STRING]; /*Flawfinder: ignore*/
419 snprintf(buffer, sizeof(buffer), "Done."); /* Flawfinder: ignore */
420 list->addCommentText(buffer);
421
422 } 206 }
423 return successful_start; 207 return successful_start;
424} 208}
425 209
426// returns true if the queue has started, otherwise false. This 210// Pop the top object off of the queue.
427// method pops the top object off of the queue. 211// Return TRUE if the queue has started, otherwise FALSE.
428BOOL LLFloaterBulkPermission::popNext() 212BOOL LLFloaterBulkPermission::popNext()
429{ 213{
430 // get the first element off of the container, and attempt to get 214 // get the head element from the container, and attempt to get its inventory.
431 // the inventory.
432 BOOL rv = FALSE; 215 BOOL rv = FALSE;
433 S32 count = mObjectIDs.count(); 216 S32 count = mObjectIDs.count();
434 if(mCurrentObjectID.isNull() && (count > 0)) 217 if(mCurrentObjectID.isNull() && (count > 0))
435 { 218 {
436 mCurrentObjectID = mObjectIDs.get(0); 219 mCurrentObjectID = mObjectIDs.get(0);
437 llinfos << "LLFloaterBulkPermission::popNext() - mCurrentID: " 220 //llinfos << "mCurrentID: " << mCurrentObjectID << llendl;
438 << mCurrentObjectID << llendl;
439 mObjectIDs.remove(0); 221 mObjectIDs.remove(0);
440 LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID); 222 LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID);
441 if(obj) 223 if(obj)
442 { 224 {
443 llinfos << "LLFloaterBulkPermission::popNext() requesting inv for " 225 //llinfos << "requesting inv for " << mCurrentObjectID << llendl;
444 << mCurrentObjectID << llendl;
445 LLUUID* id = new LLUUID(mID); 226 LLUUID* id = new LLUUID(mID);
446
447 registerVOInventoryListener(obj,id); 227 registerVOInventoryListener(obj,id);
448 requestVOInventory(); 228 requestVOInventory();
449 rv = TRUE; 229 rv = TRUE;
450 } 230 }
451 else 231 else
452 { 232 {
453 llinfos<<"LLFloaterBulkPermission::popNext() returned a NULL LLViewerObject" <<llendl; 233 llinfos<<"NULL LLViewerObject" <<llendl;
454 //Arrrg what do we do here?
455 } 234 }
456 } 235 }
457 236
@@ -459,47 +238,42 @@ BOOL LLFloaterBulkPermission::popNext()
459} 238}
460 239
461 240
462// static 241void LLFloaterBulkPermission::doCheckUncheckAll(BOOL check)
463LLFloaterBulkPermission* LLFloaterBulkPermission::create()
464{ 242{
465 S32 left, top; 243 gSavedSettings.setBOOL("BulkChangeIncludeAnimations", check);
466 gFloaterView->getNewFloaterPosition(&left, &top); 244 gSavedSettings.setBOOL("BulkChangeIncludeBodyParts" , check);
467 LLRect rect = gSavedSettings.getRect("CompileOutputRect"); 245 gSavedSettings.setBOOL("BulkChangeIncludeClothing" , check);
468 rect.translate(left - rect.mLeft, top - rect.mTop); 246 gSavedSettings.setBOOL("BulkChangeIncludeGestures" , check);
469 LLFloaterBulkPermission* new_queue = new LLFloaterBulkPermission("queue",rect,"Setting Bulk permissions","Results"); 247 gSavedSettings.setBOOL("BulkChangeIncludeLandmarks" , check);
470 new_queue->open(); /*Flawfinder: ignore*/ 248 gSavedSettings.setBOOL("BulkChangeIncludeNotecards" , check);
471 return new_queue; 249 gSavedSettings.setBOOL("BulkChangeIncludeObjects" , check);
250 gSavedSettings.setBOOL("BulkChangeIncludeScripts" , check);
251 gSavedSettings.setBOOL("BulkChangeIncludeSounds" , check);
252 gSavedSettings.setBOOL("BulkChangeIncludeTextures" , check);
472} 253}
473 254
474 255
475void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, InventoryObjectList* inv) 256void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, InventoryObjectList* inv)
476{ 257{
477 // find all of the lsl, leaving off duplicates. We'll remove
478 // all matching asset uuids on compilation success.
479
480 llinfos<<"handleInventory"<<llendl;
481
482 char buffer[MAX_STRING]; /*Flawfinder: ignore*/
483 LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output"); 258 LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
484 259
485 InventoryObjectList::const_iterator it = inv->begin(); 260 InventoryObjectList::const_iterator it = inv->begin();
486 InventoryObjectList::const_iterator end = inv->end(); 261 InventoryObjectList::const_iterator end = inv->end();
487 for ( ; it != end; ++it) 262 for ( ; it != end; ++it)
488 { 263 {
489 llinfos<<"Doing iterator of inventory"<<llendl; 264 LLAssetType::EType asstype = (*it)->getType();
490 265 if(
491 if( ( (*it)->getType() == LLAssetType::AT_LSL_TEXT && processScript) || 266 ( asstype == LLAssetType::AT_ANIMATION && gSavedSettings.getBOOL("BulkChangeIncludeAnimations")) ||
492 ( (*it)->getType() == LLAssetType::AT_TEXTURE && processTexture) || 267 ( asstype == LLAssetType::AT_BODYPART && gSavedSettings.getBOOL("BulkChangeIncludeBodyParts" )) ||
493 ( (*it)->getType() == LLAssetType::AT_SOUND && processSound) || 268 ( asstype == LLAssetType::AT_CLOTHING && gSavedSettings.getBOOL("BulkChangeIncludeClothing" )) ||
494 ( (*it)->getType() == LLAssetType::AT_LANDMARK && processLandmark) || 269 ( asstype == LLAssetType::AT_GESTURE && gSavedSettings.getBOOL("BulkChangeIncludeGestures" )) ||
495 ( (*it)->getType() == LLAssetType::AT_CLOTHING && processClothing) || 270 ( asstype == LLAssetType::AT_LANDMARK && gSavedSettings.getBOOL("BulkChangeIncludeLandmarks" )) ||
496 ( (*it)->getType() == LLAssetType::AT_OBJECT && processObject) || 271 ( asstype == LLAssetType::AT_NOTECARD && gSavedSettings.getBOOL("BulkChangeIncludeNotecards" )) ||
497 ( (*it)->getType() == LLAssetType::AT_NOTECARD && processNotecard) || 272 ( asstype == LLAssetType::AT_OBJECT && gSavedSettings.getBOOL("BulkChangeIncludeObjects" )) ||
498 ( (*it)->getType() == LLAssetType::AT_BODYPART && processBodypart) || 273 ( asstype == LLAssetType::AT_LSL_TEXT && gSavedSettings.getBOOL("BulkChangeIncludeScripts" )) ||
499 ( (*it)->getType() == LLAssetType::AT_ANIMATION && processAnimation) || 274 ( asstype == LLAssetType::AT_SOUND && gSavedSettings.getBOOL("BulkChangeIncludeSounds" )) ||
500 ( (*it)->getType() == LLAssetType::AT_GESTURE && processGesture)) 275 ( asstype == LLAssetType::AT_TEXTURE && gSavedSettings.getBOOL("BulkChangeIncludeTextures" )))
501 { 276 {
502
503 LLViewerObject* object = gObjectList.findObject(viewer_obj->getID()); 277 LLViewerObject* object = gObjectList.findObject(viewer_obj->getID());
504 278
505 if (object) 279 if (object)
@@ -513,43 +287,56 @@ void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, Invent
513 std::string invname; 287 std::string invname;
514 invname=item->getName().substr(0,item->getName().size() < 30 ? item->getName().size() : 30 ); 288 invname=item->getName().substr(0,item->getName().size() < 30 ? item->getName().size() : 30 );
515 289
516 // My attempt at checking valid permissions, CHECK ME 290 LLUIString status_text = getString("status_text");
517 // note its not actually bad to try to set permissions that are not allowed as the 291 status_text.setArg("[NAME]", invname.c_str());
518 // server will protect against this, but it will piss the user off if its wrong 292 // Check whether we appear to have the appropriate permissions to change permission on this item.
519 if( 293 // Although the server will disallow any forbidden changes, it is a good idea to guess correctly
520 (perm.getCreator()==gAgentID) || 294 // so that we can warn the user. The risk of getting this check wrong is therefore the possibility
521 (perm.getMaskOwner() & PERM_TRANSFER) && (perm.getMaskOwner() & PERM_MODIFY) || 295 // of incorrectly choosing to not attempt to make a valid change.
522 (gAgent.getGroupID()==perm.getGroup() && (perm.getMaskGroup() & PERM_TRANSFER) && (perm.getMaskGroup() & PERM_MODIFY)) 296 //
523 ){ 297 // Trouble is this is extremely difficult to do and even when we know the results
524 llinfos<<"Setting perms"<<llendl; 298 // it is difficult to design the best messaging. Therefore in this initial implementation
525 perm.setMaskNext(req_perm_mask); 299 // we'll always try to set the requested permissions and consider all cases successful
526 new_item->setPermissions(perm); 300 // and perhaps later try to implement a smarter, friendlier solution. -MG
527 updateInventory(object,new_item,TASK_INVENTORY_ITEM_KEY,FALSE); 301 if(true
528 snprintf(buffer, sizeof(buffer), "Setting perms on '%s' [OK]", invname.c_str()); /* Flawfinder: ignore */ 302 //gAgent.allowOperation(PERM_MODIFY, perm, GP_OBJECT_MANIPULATE) // for group and everyone masks
303 //|| something else // for next owner perms
304 )
305 {
306 perm.setMaskNext(LLFloaterPerms::getNextOwnerPerms("BulkChange"));
307 perm.setMaskEveryone(LLFloaterPerms::getEveryonePerms("BulkChange"));
308 perm.setMaskGroup(LLFloaterPerms::getGroupPerms("BulkChange"));
309 new_item->setPermissions(perm); // here's the beef
310 updateInventory(object,new_item,TASK_INVENTORY_ITEM_KEY,FALSE);
311 //status_text.setArg("[STATUS]", getString("status_ok_text"));
312 status_text.setArg("[STATUS]", "");
529 } 313 }
530 else 314 else
531 { 315 {
532 llinfos<<"NOT setting perms"<<llendl; 316 //status_text.setArg("[STATUS]", getString("status_bad_text"));
533 snprintf(buffer, sizeof(buffer), "Setting perms on '%s' [FAILED]", invname.c_str()); /* Flawfinder: ignore */ 317 status_text.setArg("[STATUS]", "");
534
535 } 318 }
536 319
537 list->addCommentText(buffer); 320 list->addCommentText(status_text.getString());
538 321
539 if(recurse && ( (*it)->getType() == LLAssetType::AT_OBJECT && processObject)) 322 //TODO if we are an object inside an object we should check a recuse flag and if set
540 { 323 //open the inventory of the object and recurse - Michelle2 Zenovka
541 //Add this object back to the queue to be processed as it has inventory 324
542 snprintf(buffer, sizeof(buffer), "Queueing object '%s' for open", invname.c_str()); 325 // if(recurse && ( (*it)->getType() == LLAssetType::AT_OBJECT && processObject))
543 llwarns << "Queueing object "<< invname.c_str() << " ID "<< (*it)->getUUID()<<llendl; 326 // {
544 mObjectIDs.put((*it)->getUUID()); 327 // I think we need to get the UUID of the object inside the inventory
545 // This will not YET work. as this is not a viewer object the unpack will fail 328 // call item->fetchFromServer();
546 } 329 // we need a call back to say item has arrived *sigh*
547 330 // we then need to do something like
331 // LLUUID* id = new LLUUID(mID);
332 // registerVOInventoryListener(obj,id);
333 // requestVOInventory();
334 // }
548 } 335 }
549 } 336 }
550 } 337 }
551 338
552 nextObject(); 339 nextObject();
553} 340}
554 341
555 342
@@ -557,18 +344,12 @@ void LLFloaterBulkPermission::handleInventory(LLViewerObject* viewer_obj, Invent
557// we could do this via LLViewerObject::updateInventory but that uses inventory call backs and buggers 344// we could do this via LLViewerObject::updateInventory but that uses inventory call backs and buggers
558// us up and we would have a dodgy item iterator 345// us up and we would have a dodgy item iterator
559 346
560void LLFloaterBulkPermission::updateInventory( 347void LLFloaterBulkPermission::updateInventory(LLViewerObject* object, LLViewerInventoryItem* item, U8 key, bool is_new)
561 LLViewerObject* object,
562 LLViewerInventoryItem* item,
563 U8 key,
564 bool is_new)
565{ 348{
566 LLMemType mt(LLMemType::MTYPE_OBJECT); 349 LLMemType mt(LLMemType::MTYPE_OBJECT);
567 350
568 351 // This slices the object into what we're concerned about on the viewer.
569 // This slices the object into what we're concerned about on the 352 // The simulator will take the permissions and transfer ownership.
570 // viewer. The simulator will take the permissions and transfer
571 // ownership.
572 LLPointer<LLViewerInventoryItem> task_item = 353 LLPointer<LLViewerInventoryItem> task_item =
573 new LLViewerInventoryItem(item->getUUID(), mID, item->getPermissions(), 354 new LLViewerInventoryItem(item->getUUID(), mID, item->getPermissions(),
574 item->getAssetUUID(), item->getType(), 355 item->getAssetUUID(), item->getType(),
@@ -589,6 +370,5 @@ void LLFloaterBulkPermission::updateInventory(
589 msg->nextBlockFast(_PREHASH_InventoryData); 370 msg->nextBlockFast(_PREHASH_InventoryData);
590 task_item->packMessage(msg); 371 task_item->packMessage(msg);
591 msg->sendReliable(object->getRegion()->getHost()); 372 msg->sendReliable(object->getRegion()->getHost());
592
593} 373}
594 374