aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/primbackup.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-09-27 21:08:27 -0500
committerJacek Antonelli2009-09-27 21:08:27 -0500
commit123cc9f638fe3617a12f24a543639d4ca3f72264 (patch)
tree905e58ed32a35258334597f991c37fef54c184cb /linden/indra/newview/primbackup.cpp
parentUpdated Imprudence version to "1.2.0 beta". (diff)
downloadmeta-impy-123cc9f638fe3617a12f24a543639d4ca3f72264.zip
meta-impy-123cc9f638fe3617a12f24a543639d4ca3f72264.tar.gz
meta-impy-123cc9f638fe3617a12f24a543639d4ca3f72264.tar.bz2
meta-impy-123cc9f638fe3617a12f24a543639d4ca3f72264.tar.xz
"Fixed and cleaned up the export permissions check."
Diffstat (limited to 'linden/indra/newview/primbackup.cpp')
-rw-r--r--linden/indra/newview/primbackup.cpp107
1 files changed, 54 insertions, 53 deletions
diff --git a/linden/indra/newview/primbackup.cpp b/linden/indra/newview/primbackup.cpp
index 78fd482..8dbf1df 100644
--- a/linden/indra/newview/primbackup.cpp
+++ b/linden/indra/newview/primbackup.cpp
@@ -350,54 +350,52 @@ void primbackup::pre_export_object()
350 gIdleCallbacks.addFunction(exportworker, NULL); 350 gIdleCallbacks.addFunction(exportworker, NULL);
351} 351}
352 352
353
354// static
355bool primbackup::check_perms( LLSelectNode* node )
356{
357 LLPermissions *perms = node->mPermissions;
358 return (gAgent.getID() == perms->getOwner() &&
359 gAgent.getID() == perms->getCreator() &&
360 (PERM_ITEM_UNRESTRICTED &
361 perms->getMaskOwner()) == PERM_ITEM_UNRESTRICTED);
362}
363
364
353void primbackup::exportworker(void *userdata) 365void primbackup::exportworker(void *userdata)
354{ 366{
355 primbackup::getInstance()->updateexportnumbers(); 367 primbackup::getInstance()->updateexportnumbers();
356 368
357 switch(primbackup::getInstance()->export_state) 369 switch(primbackup::getInstance()->export_state)
358 { 370 {
359 case EXPORT_INIT: 371 case EXPORT_INIT: {
372 primbackup::getInstance()->show();
373 LLSelectMgr::getInstance()->getSelection()->ref();
374
375 struct ff : public LLSelectedNodeFunctor
360 { 376 {
361 primbackup::getInstance()->show(); 377 virtual bool apply(LLSelectNode* node)
362 LLSelectMgr::getInstance()->getSelection()->ref();
363
364 struct ff : public LLSelectedNodeFunctor
365 {
366 virtual bool apply(LLSelectNode* node)
367 {
368 if(gAgent.getID()!=node->mPermissions->getOwner())
369 {
370 #ifdef LL_GRID_PERMISSIONS
371 return false;
372 #else
373 return true;
374 #endif
375 }
376 else if(581632==node->mPermissions->getMaskOwner() || 2147483647==node->mPermissions->getMaskOwner())
377 {
378 return true;
379 }
380 return false;
381 }
382 } func;
383
384 if(LLSelectMgr::getInstance()->getSelection()->applyToNodes(&func,false))
385 primbackup::getInstance()->export_state=EXPORT_STRUCTURE;
386 else
387 { 378 {
388 llwarns<<"Incorrect permission to export"<<llendl; 379 return primbackup::check_perms( node );
389 primbackup::getInstance()->export_state=EXPORT_DONE;
390 primbackup::getInstance()->close();
391 gIdleCallbacks.deleteFunction(exportworker);
392 LLSelectMgr::getInstance()->getSelection()->unref();
393
394 } 380 }
395 break; 381 } func;
396 }
397 382
383 if(LLSelectMgr::getInstance()->getSelection()->applyToNodes(&func,false))
384 {
385 primbackup::getInstance()->export_state=EXPORT_STRUCTURE;
386 }
387 else
388 {
389 llwarns << "Incorrect permission to export" << llendl;
390 primbackup::getInstance()->export_state=EXPORT_DONE;
391 primbackup::getInstance()->close();
392 gIdleCallbacks.deleteFunction(exportworker);
393 LLSelectMgr::getInstance()->getSelection()->unref();
394 }
398 break; 395 break;
399 case EXPORT_STRUCTURE: 396 }
400 { 397
398 case EXPORT_STRUCTURE: {
401 struct ff : public LLSelectedObjectFunctor 399 struct ff : public LLSelectedObjectFunctor
402 { 400 {
403 virtual bool apply(LLViewerObject* object) 401 virtual bool apply(LLViewerObject* object)
@@ -405,7 +403,7 @@ void primbackup::exportworker(void *userdata)
405 object->boostTexturePriority(TRUE); 403 object->boostTexturePriority(TRUE);
406 LLViewerObject::child_list_t children = object->getChildren(); 404 LLViewerObject::child_list_t children = object->getChildren();
407 children.push_front(object); //push root onto list 405 children.push_front(object); //push root onto list
408 LLSD prim_llsd=primbackup::getInstance()->prims_to_llsd(children); 406 LLSD prim_llsd=primbackup::getInstance()->prims_to_llsd(children);
409 LLSD stuff; 407 LLSD stuff;
410 stuff["root_position"] = object->getPosition().getValue(); 408 stuff["root_position"] = object->getPosition().getValue();
411 stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation()); 409 stuff["root_rotation"] = ll_sd_from_quaternion(object->getRotation());
@@ -421,7 +419,8 @@ void primbackup::exportworker(void *userdata)
421 419
422 break; 420 break;
423 } 421 }
424 case EXPORT_TEXTURES: 422
423 case EXPORT_TEXTURES: {
425 if(primbackup::getInstance()->m_nexttextureready==false) 424 if(primbackup::getInstance()->m_nexttextureready==false)
426 return; 425 return;
427 426
@@ -435,23 +434,25 @@ void primbackup::exportworker(void *userdata)
435 } 434 }
436 435
437 primbackup::getInstance()->export_next_texture(); 436 primbackup::getInstance()->export_next_texture();
438 break; 437 break;
438 }
439 439
440 case EXPORT_LLSD: 440 case EXPORT_LLSD: {
441 { 441 // Create a file stream and write to it
442 // Create a file stream and write to it 442 llofstream export_file(primbackup::getInstance()->file_name);
443 llofstream export_file(primbackup::getInstance()->file_name); 443 LLSDSerialize::toPrettyXML(primbackup::getInstance()->llsd, export_file);
444 LLSDSerialize::toPrettyXML(primbackup::getInstance()->llsd, export_file); 444 export_file.close();
445 export_file.close(); 445 primbackup::getInstance()->m_nexttextureready=true;
446 primbackup::getInstance()->m_nexttextureready=true; 446 primbackup::getInstance()->export_state=EXPORT_TEXTURES;
447 primbackup::getInstance()->export_state=EXPORT_TEXTURES;
448 }
449 break; 447 break;
450 case EXPORT_DONE: 448 }
451 llinfos<<"Backup complete"<<llendl 449
452 gIdleCallbacks.deleteFunction(exportworker); 450 case EXPORT_DONE: {
453 primbackup::getInstance()->close(); 451 llinfos << "Backup complete" << llendl;
452 gIdleCallbacks.deleteFunction(exportworker);
453 primbackup::getInstance()->close();
454 break; 454 break;
455 }
455 } 456 }
456} 457}
457 458