llinventorybridge.cpp 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337
  1. /**
  2. * @file llinventorybridge.cpp
  3. * @brief Implementation of the Inventory-Folder-View-Bridge classes.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * 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. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include <utility> // for std::pair<>
  34. #include "llinventorybridge.h"
  35. #include "llaudioengine.h"
  36. #include "llevent.h"
  37. #include "lliconctrl.h"
  38. #include "lllineeditor.h"
  39. #include "llmenugl.h"
  40. #include "llnotifications.h"
  41. #include "llradiogroup.h"
  42. #include "llscrollcontainer.h"
  43. #include "llspinctrl.h"
  44. #include "lltabcontainer.h"
  45. #include "lltextbox.h"
  46. #include "lltrans.h"
  47. #include "lluictrlfactory.h"
  48. #include "llagent.h"
  49. #include "llavataractions.h"
  50. #include "llagentwearables.h"
  51. #include "llappearancemgr.h"
  52. #include "llenvironment.h"
  53. #include "llfloaterchat.h"
  54. #include "llfloatercustomize.h"
  55. #include "hbfloatereditenvsettings.h"
  56. #include "llfloaterinventory.h"
  57. #include "llfloatermarketplace.h"
  58. #include "llfloateropenobject.h"
  59. #include "llfloaterproperties.h"
  60. #include "hbfloaterthumbnail.h"
  61. #include "llfloaterworldmap.h"
  62. #include "llgesturemgr.h"
  63. #include "llinventoryactions.h"
  64. #include "hbinventoryclipboard.h"
  65. #include "llinventoryicon.h"
  66. #include "llinventorymodelfetch.h"
  67. #include "lllandmarklist.h"
  68. #include "llmarketplacefunctions.h"
  69. #include "llpreviewtexture.h"
  70. //MK
  71. #include "mkrlinterface.h"
  72. //mk
  73. #include "llselectmgr.h"
  74. #include "lltooldraganddrop.h"
  75. #include "hbviewerautomation.h"
  76. #include "llviewercontrol.h"
  77. #include "llviewerfoldertype.h"
  78. #include "llviewerinventory.h"
  79. #include "llviewermenu.h" // For handle_object_edit()
  80. #include "llviewermessage.h" // For send_sound_trigger()
  81. #include "llviewerobjectlist.h"
  82. #include "llviewerparcelmgr.h"
  83. #if LL_RESTORE_TO_WORLD
  84. # include "llviewerregion.h"
  85. #endif
  86. #include "llviewertexturelist.h"
  87. #include "llviewerwindow.h"
  88. #include "llvoavatarself.h"
  89. #include "llwearablelist.h"
  90. using namespace LLOldEvents;
  91. // Helper functions
  92. static std::string safe_inv_type_lookup(LLInventoryType::EType inv_type)
  93. {
  94. std::string type = LLInventoryType::lookupHumanReadable(inv_type);
  95. if (!type.empty())
  96. {
  97. return type;
  98. }
  99. return "<" + LLTrans::getString("invalid") + ">";
  100. }
  101. #if LL_RESTORE_TO_WORLD
  102. static bool restore_to_world_callback(const LLSD& notification,
  103. const LLSD& response, LLItemBridge* self)
  104. {
  105. if (self && LLNotification::getSelectedOption(notification, response) == 0)
  106. {
  107. self->restoreToWorld();
  108. }
  109. return false;
  110. }
  111. #endif
  112. void set_menu_entries_state(LLMenuGL& menu,
  113. const std::vector<std::string>& entries_to_show,
  114. const std::vector<std::string>& disabled_entries)
  115. {
  116. const LLView::child_list_t* list = menu.getChildList();
  117. for (LLView::child_list_t::const_iterator it = list->begin(),
  118. end = list->end();
  119. it != end; ++it)
  120. {
  121. std::string name = (*it)->getName();
  122. // Descend into split menus:
  123. LLMenuItemBranchGL* branchp = dynamic_cast<LLMenuItemBranchGL*>(*it);
  124. if (branchp && name == "More")
  125. {
  126. set_menu_entries_state(*branchp->getBranch(), entries_to_show,
  127. disabled_entries);
  128. }
  129. bool found = false;
  130. for (S32 i = 0, count = entries_to_show.size(); i < count; ++i)
  131. {
  132. if (entries_to_show[i] == name)
  133. {
  134. found = true;
  135. break;
  136. }
  137. }
  138. if (found)
  139. {
  140. for (S32 i = 0, count = disabled_entries.size(); i < count; ++i)
  141. {
  142. if (disabled_entries[i] == name)
  143. {
  144. (*it)->setEnabled(false);
  145. break;
  146. }
  147. }
  148. }
  149. else
  150. {
  151. (*it)->setVisible(false);
  152. }
  153. }
  154. }
  155. //-----------------------------------------------------------------------------
  156. // Class LLInventoryWearObserver
  157. //
  158. // Observer for "copy and wear" operation to support knowing when the all of
  159. // the contents has been added to inventory.
  160. //-----------------------------------------------------------------------------
  161. class LLInventoryCopyAndWearObserver final : public LLInventoryObserver
  162. {
  163. public:
  164. LLInventoryCopyAndWearObserver(const LLUUID& cat_id, S32 count,
  165. bool folder_added = false)
  166. : mCatID(cat_id),
  167. mContentsCount(count),
  168. mFolderAdded(folder_added)
  169. {
  170. }
  171. void changed(U32 mask) override;
  172. protected:
  173. LLUUID mCatID;
  174. S32 mContentsCount;
  175. bool mFolderAdded;
  176. };
  177. void LLInventoryCopyAndWearObserver::changed(U32 mask)
  178. {
  179. if ((mask & LLInventoryObserver::ADD) != 0)
  180. {
  181. if (!mFolderAdded)
  182. {
  183. const uuid_list_t& changed_items = gInventory.getChangedIDs();
  184. for (uuid_list_t::const_iterator it = changed_items.begin(),
  185. end = changed_items.end();
  186. it != end; ++it)
  187. {
  188. if (*it == mCatID)
  189. {
  190. mFolderAdded = true;
  191. break;
  192. }
  193. }
  194. }
  195. if (mFolderAdded)
  196. {
  197. LLViewerInventoryCategory* category = gInventory.getCategory(mCatID);
  198. if (!category)
  199. {
  200. llwarns << "Couldn't find category: " << mCatID << llendl;
  201. }
  202. else if (category->getDescendentCount() == mContentsCount)
  203. {
  204. gInventory.removeObserver(this);
  205. gAppearanceMgr.wearInventoryCategory(category, false, true);
  206. delete this;
  207. }
  208. }
  209. }
  210. }
  211. typedef std::pair<LLUUID, LLUUID> two_uuids_t;
  212. typedef std::list<two_uuids_t> two_uuids_list_t;
  213. typedef std::pair<LLUUID, two_uuids_list_t> uuid_move_list_t;
  214. struct LLMoveInv
  215. {
  216. LLUUID mObjectID;
  217. LLUUID mCategoryID;
  218. two_uuids_list_t mMoveList;
  219. void (*mCallback)(S32, void*);
  220. void* mUserData;
  221. };
  222. static bool move_task_inventory_callback(const LLSD& notification,
  223. const LLSD& response,
  224. LLMoveInv* move_inv)
  225. {
  226. LLViewerObject* object = gObjectList.findObject(move_inv->mObjectID);
  227. S32 option = LLNotification::getSelectedOption(notification, response);
  228. if (object && move_inv && option == 0)
  229. {
  230. LLFloaterOpenObject::LLCatAndWear* cat_and_wear =
  231. (LLFloaterOpenObject::LLCatAndWear*)move_inv->mUserData;
  232. if (cat_and_wear && cat_and_wear->mWear
  233. #if 0
  234. && !cat_and_wear->mFolderResponded
  235. #endif
  236. )
  237. {
  238. LLInventoryObject::object_list_t inventory_objects;
  239. object->getInventoryContents(inventory_objects);
  240. // Subtract one for containing folder
  241. S32 contents_count = inventory_objects.size() - 1;
  242. LLInventoryCopyAndWearObserver* inv_observer =
  243. new LLInventoryCopyAndWearObserver(cat_and_wear->mCatID,
  244. contents_count,
  245. cat_and_wear->mFolderResponded);
  246. gInventory.addObserver(inv_observer);
  247. }
  248. for (two_uuids_list_t::iterator it = move_inv->mMoveList.begin(),
  249. end = move_inv->mMoveList.end();
  250. it != end; ++it)
  251. {
  252. object->moveInventory(it->first, it->second);
  253. }
  254. // Update the UI.
  255. dialog_refresh_all();
  256. }
  257. if (move_inv->mCallback)
  258. {
  259. move_inv->mCallback(option, move_inv->mUserData);
  260. }
  261. delete move_inv;
  262. return false;
  263. }
  264. static void warn_move_inventory(LLViewerObject* object, LLMoveInv* move_inv)
  265. {
  266. std::string dialog =
  267. object->flagScripted() ? "MoveInventoryFromScriptedObject"
  268. : "MoveInventoryFromObject";
  269. gNotifications.add(dialog, LLSD(), LLSD(),
  270. boost::bind(move_task_inventory_callback, _1, _2,
  271. move_inv));
  272. }
  273. // Move/copy all inventory items from the Contents folder of an in-world
  274. // object to the agent's inventory, inside a given category.
  275. bool move_inv_category_world_to_agent(const LLUUID& object_id,
  276. const LLUUID& category_id, bool drop,
  277. void (*callback)(S32, void*),
  278. void* user_data)
  279. {
  280. // Make sure the object exists. If we allowed dragging from anonymous
  281. // objects, it would be possible to bypass permissions.
  282. // content category has same ID as object itself
  283. LLViewerObject* object = gObjectList.findObject(object_id);
  284. if (!object)
  285. {
  286. llinfos << "Object not found for drop." << llendl;
  287. return false;
  288. }
  289. // This folder is coming from an object, as there is only one folder in an
  290. // object, the root, we need to collect the entire contents and handle them
  291. // as a group
  292. LLInventoryObject::object_list_t inventory_objects;
  293. object->getInventoryContents(inventory_objects);
  294. if (inventory_objects.empty())
  295. {
  296. llinfos << "Object contents not found for drop." << llendl;
  297. return false;
  298. }
  299. bool accept = true;
  300. bool is_move = false;
  301. // Coming from a task. Need to figure out if the person can move/copy this
  302. // item.
  303. LLInventoryObject::object_list_t::iterator it = inventory_objects.begin();
  304. LLInventoryObject::object_list_t::iterator end = inventory_objects.end();
  305. for ( ; it != end; ++it)
  306. {
  307. LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(it->get());
  308. if (!item)
  309. {
  310. llwarns << "Invalid inventory item for drop" << llendl;
  311. continue;
  312. }
  313. LLPermissions perm(item->getPermissions());
  314. if (perm.allowCopyBy(gAgentID, gAgent.getGroupID()) &&
  315. perm.allowTransferTo(gAgentID)) /* || gAgent.isGodlike()) */
  316. {
  317. accept = true;
  318. }
  319. else if (object->permYouOwner())
  320. {
  321. // If the object cannot be copied, but the object the inventory is
  322. // owned by the agent, then the item can be moved from the task to
  323. // agent inventory.
  324. is_move = accept = true;
  325. }
  326. else
  327. {
  328. accept = false;
  329. break;
  330. }
  331. }
  332. if (drop && accept)
  333. {
  334. it = inventory_objects.begin();
  335. LLMoveInv* move_inv = new LLMoveInv;
  336. move_inv->mObjectID = object_id;
  337. move_inv->mCategoryID = category_id;
  338. move_inv->mCallback = callback;
  339. move_inv->mUserData = user_data;
  340. for ( ; it != end; ++it)
  341. {
  342. move_inv->mMoveList.emplace_back(category_id, (*it)->getUUID());
  343. }
  344. if (is_move)
  345. {
  346. // Callback called from within here.
  347. warn_move_inventory(object, move_inv);
  348. }
  349. else
  350. {
  351. LLNotification::Params params("MoveInventoryFromObject");
  352. params.functor(boost::bind(move_task_inventory_callback,
  353. _1, _2, move_inv));
  354. gNotifications.forceResponse(params, 0);
  355. }
  356. }
  357. return accept;
  358. }
  359. ///////////////////////////////////////////////////////////////////////////////
  360. // LLInvFVBridge
  361. ///////////////////////////////////////////////////////////////////////////////
  362. //virtual
  363. const std::string& LLInvFVBridge::getName() const
  364. {
  365. LLInventoryObject* obj = getInventoryObject();
  366. return obj ? obj->getName() : LLStringUtil::null;
  367. }
  368. // Can it be destroyed (or moved to trash) ?
  369. //virtual
  370. bool LLInvFVBridge::isItemRemovable()
  371. {
  372. LLInventoryModel* modelp = mInventoryPanel->getModel();
  373. if (!modelp)
  374. {
  375. return false;
  376. }
  377. const LLViewerInventoryItem* itemp = modelp->getItem(mUUID);
  378. if (itemp && itemp->getIsLinkType())
  379. {
  380. return true;
  381. }
  382. return modelp->isObjectDescendentOf(mUUID, gInventory.getRootFolderID());
  383. }
  384. // Can it be moved to another folder ?
  385. //virtual
  386. bool LLInvFVBridge::isItemMovable()
  387. {
  388. bool can_move = false;
  389. LLInventoryModel* model = mInventoryPanel->getModel();
  390. if (model)
  391. {
  392. can_move = model->isObjectDescendentOf(mUUID,
  393. gInventory.getRootFolderID());
  394. }
  395. return can_move;
  396. }
  397. //virtual
  398. void LLInvFVBridge::showProperties()
  399. {
  400. LLFloaterProperties::show(mUUID, LLUUID::null, mInventoryPanel);
  401. }
  402. //virtual
  403. void LLInvFVBridge::removeBatch(std::vector<LLFolderViewEventListener*>& batch)
  404. {
  405. LLInventoryModel* model = mInventoryPanel->getModel();
  406. if (!model) return;
  407. // Deactivate gestures and close settings editors when moving them into the
  408. // Trash.
  409. S32 count = batch.size();
  410. for (S32 i = 0; i < count; ++i)
  411. {
  412. LLInvFVBridge* bridge = (LLInvFVBridge*)batch[i];
  413. if (!bridge) continue; // Paranoia
  414. if (bridge->isItemRemovable())
  415. {
  416. LLViewerInventoryItem* item = model->getItem(bridge->getUUID());
  417. if (item && item->getType() == LLAssetType::AT_GESTURE)
  418. {
  419. gGestureManager.deactivateGesture(item->getUUID());
  420. }
  421. }
  422. else if (!bridge->isMultiPreviewAllowed())
  423. {
  424. LLViewerInventoryItem* item = model->getItem(bridge->getUUID());
  425. if (item && item->getType() == LLAssetType::AT_SETTINGS)
  426. {
  427. HBFloaterEditEnvSettings::destroy(item->getUUID());
  428. }
  429. }
  430. }
  431. for (S32 i = 0; i < count; ++i)
  432. {
  433. LLInvFVBridge* bridge = (LLInvFVBridge*)batch[i];
  434. if (!bridge || !bridge->isItemRemovable()) continue;
  435. LLViewerInventoryCategory* cat = model->getCategory(bridge->getUUID());
  436. if (cat)
  437. {
  438. LLInventoryModel::cat_array_t descendent_categories;
  439. LLInventoryModel::item_array_t descendent_items;
  440. model->collectDescendents(cat->getUUID(), descendent_categories,
  441. descendent_items, false);
  442. for (S32 j = 0, count2 = descendent_items.size(); j < count2; ++j)
  443. {
  444. LLViewerInventoryItem* item = descendent_items[j];
  445. if (!item) continue; // Paranoia
  446. LLPreview::hide(item->getUUID());
  447. if (item->getType() == LLAssetType::AT_GESTURE)
  448. {
  449. gGestureManager.deactivateGesture(item->getUUID());
  450. }
  451. else if (item->getType() == LLAssetType::AT_SETTINGS)
  452. {
  453. HBFloaterEditEnvSettings::destroy(item->getUUID());
  454. }
  455. }
  456. }
  457. }
  458. removeBatchNoCheck(batch);
  459. }
  460. // This method moves a bunch of items and folders to the trash. As per design
  461. // guidelines for the inventory model, the message is built and the accounting
  462. // is performed first. Once done, we call LLInventoryModel::moveObject() to
  463. // move everything around.
  464. void LLInvFVBridge::removeBatchNoCheck(std::vector<LLFolderViewEventListener*>& batch)
  465. {
  466. LLInventoryModel* model = mInventoryPanel->getModel();
  467. LLMessageSystem* msg = gMessageSystemp;
  468. if (!model || !msg) return;
  469. const LLUUID& trash_id = model->getTrashID();
  470. uuid_vec_t move_ids;
  471. LLInventoryModel::update_map_t update;
  472. bool start_new_message = true;
  473. S32 count = batch.size();
  474. for (S32 i = 0; i < count; ++i)
  475. {
  476. LLInvFVBridge* bridge = (LLInvFVBridge*)batch[i];
  477. if (!bridge || !bridge->isItemRemovable())
  478. {
  479. continue;
  480. }
  481. LLViewerInventoryItem* item = model->getItem(bridge->getUUID());
  482. if (!item || item->getParentUUID() == trash_id)
  483. {
  484. continue;
  485. }
  486. move_ids.emplace_back(item->getUUID());
  487. --update[item->getParentUUID()];
  488. ++update[trash_id];
  489. if (start_new_message)
  490. {
  491. start_new_message = false;
  492. msg->newMessageFast(_PREHASH_MoveInventoryItem);
  493. msg->nextBlockFast(_PREHASH_AgentData);
  494. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  495. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  496. msg->addBoolFast(_PREHASH_Stamp, true);
  497. }
  498. msg->nextBlockFast(_PREHASH_InventoryData);
  499. msg->addUUIDFast(_PREHASH_ItemID, item->getUUID());
  500. msg->addUUIDFast(_PREHASH_FolderID, trash_id);
  501. msg->addString("NewName", NULL);
  502. if (msg->isSendFullFast(_PREHASH_InventoryData))
  503. {
  504. start_new_message = true;
  505. gAgent.sendReliableMessage();
  506. model->accountForUpdate(update);
  507. update.clear();
  508. // Move everything. Note: this does need to be done after each
  509. // message is sent to avoid loosing accounting sync with the
  510. // server ! HB
  511. for (U32 j = 0, items = move_ids.size(); j < items; ++j)
  512. {
  513. const LLUUID& item_id = move_ids[j];
  514. model->moveObject(item_id, trash_id);
  515. LLViewerInventoryItem* item = model->getItem(item_id);
  516. if (item)
  517. {
  518. model->updateItem(item);
  519. }
  520. }
  521. move_ids.clear();
  522. }
  523. }
  524. if (!start_new_message)
  525. {
  526. start_new_message = true;
  527. gAgent.sendReliableMessage();
  528. model->accountForUpdate(update);
  529. update.clear();
  530. // Move everything. Note: this does need to be done after each message
  531. // is sent to avoid loosing accounting sync with the server ! HB
  532. for (U32 j = 0, items = move_ids.size(); j < items; ++j)
  533. {
  534. const LLUUID& item_id = move_ids[j];
  535. model->moveObject(item_id, trash_id);
  536. LLViewerInventoryItem* item = model->getItem(item_id);
  537. if (item)
  538. {
  539. model->updateItem(item);
  540. }
  541. }
  542. move_ids.clear();
  543. }
  544. for (S32 i = 0; i < count; ++i)
  545. {
  546. LLInvFVBridge* bridge = (LLInvFVBridge*)batch[i];
  547. if (!bridge || !bridge->isItemRemovable())
  548. {
  549. continue;
  550. }
  551. LLViewerInventoryCategory* cat = model->getCategory(bridge->getUUID());
  552. if (!cat || cat->getParentUUID() == trash_id)
  553. {
  554. continue;
  555. }
  556. move_ids.emplace_back(cat->getUUID());
  557. --update[cat->getParentUUID()];
  558. ++update[trash_id];
  559. if (start_new_message)
  560. {
  561. start_new_message = false;
  562. msg->newMessageFast(_PREHASH_MoveInventoryFolder);
  563. msg->nextBlockFast(_PREHASH_AgentData);
  564. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  565. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  566. msg->addBool("Stamp", true);
  567. }
  568. msg->nextBlockFast(_PREHASH_InventoryData);
  569. msg->addUUIDFast(_PREHASH_FolderID, cat->getUUID());
  570. msg->addUUIDFast(_PREHASH_ParentID, trash_id);
  571. if (msg->isSendFullFast(_PREHASH_InventoryData) )
  572. {
  573. start_new_message = true;
  574. gAgent.sendReliableMessage();
  575. model->accountForUpdate(update);
  576. update.clear();
  577. // Move everything. Note: this does need to be done after each
  578. // message is sent to avoid loosing accounting sync with the
  579. // server ! HB
  580. for (U32 j = 0, items = move_ids.size(); j < items; ++j)
  581. {
  582. const LLUUID& item_id = move_ids[j];
  583. model->moveObject(item_id, trash_id);
  584. LLViewerInventoryItem* item = model->getItem(item_id);
  585. if (item)
  586. {
  587. model->updateItem(item);
  588. }
  589. }
  590. move_ids.clear();
  591. }
  592. }
  593. if (!start_new_message)
  594. {
  595. gAgent.sendReliableMessage();
  596. model->accountForUpdate(update);
  597. // Move everything. Note: this does need to be done after each message
  598. // is sent to avoid loosing accounting sync with the server ! HB
  599. for (U32 j = 0, items = move_ids.size(); j < items; ++j)
  600. {
  601. const LLUUID& item_id = move_ids[j];
  602. model->moveObject(item_id, trash_id);
  603. LLViewerInventoryItem* item = model->getItem(item_id);
  604. if (item)
  605. {
  606. model->updateItem(item);
  607. }
  608. }
  609. }
  610. // Notify inventory observers.
  611. model->notifyObservers();
  612. }
  613. //virtual
  614. bool LLInvFVBridge::isClipboardPasteable() const
  615. {
  616. LLInventoryModel* modelp = mInventoryPanel->getModel();
  617. if (!modelp)
  618. {
  619. modelp = &gInventory;
  620. }
  621. if (!isAgentInventory() || !HBInventoryClipboard::hasContents())
  622. {
  623. return false;
  624. }
  625. const LLUUID& agent_id = gAgentID;
  626. uuid_vec_t objects;
  627. HBInventoryClipboard::retrieve(objects);
  628. S32 count = objects.size();
  629. for (S32 i = 0; i < count; ++i)
  630. {
  631. const LLUUID& object_id = objects[i];
  632. const LLViewerInventoryCategory* catp = modelp->getCategory(object_id);
  633. if (catp)
  634. {
  635. if (catp->getPreferredType() != LLFolderType::FT_NONE)
  636. {
  637. // Do not allow to copy any special folder
  638. return false;
  639. }
  640. LLFolderBridge cat_br(mInventoryPanel, object_id);
  641. if (!cat_br.isItemCopyable())
  642. {
  643. return false;
  644. }
  645. }
  646. else
  647. {
  648. const LLViewerInventoryItem* itemp = modelp->getItem(object_id);
  649. if (!itemp || !itemp->getPermissions().allowCopyBy(agent_id))
  650. {
  651. return false;
  652. }
  653. }
  654. }
  655. //MK
  656. if (gRLenabled)
  657. {
  658. // Do not allow if either the destination folder or the source folder
  659. // is locked
  660. LLViewerInventoryCategory* catp = modelp->getCategory(mUUID);
  661. if (catp)
  662. {
  663. for (S32 i = objects.size() - 1; i >= 0; --i)
  664. {
  665. const LLUUID& obj_id = objects[i];
  666. if (gRLInterface.isFolderLocked(catp) ||
  667. gRLInterface.isFolderLocked(modelp->getCategory(modelp->getObject(obj_id)->getParentUUID())))
  668. {
  669. return false;
  670. }
  671. }
  672. HBInventoryClipboard::retrieveCuts(objects);
  673. count = objects.size();
  674. for (S32 i = objects.size() - 1; i >= 0; --i)
  675. {
  676. const LLUUID& obj_id = objects[i];
  677. if (gRLInterface.isFolderLocked(catp) ||
  678. gRLInterface.isFolderLocked(modelp->getCategory(modelp->getObject(obj_id)->getParentUUID())))
  679. {
  680. return false;
  681. }
  682. }
  683. }
  684. }
  685. //mk
  686. return true;
  687. }
  688. //virtual
  689. bool LLInvFVBridge::isClipboardPasteableAsLink() const
  690. {
  691. if (!HBInventoryClipboard::hasCopiedContents() ||
  692. !isAgentInventory())
  693. {
  694. return false;
  695. }
  696. const LLInventoryModel* model = mInventoryPanel->getModel();
  697. if (!model)
  698. {
  699. return false;
  700. }
  701. const LLUUID& root_id = gInventory.getRootFolderID();
  702. uuid_vec_t objects;
  703. HBInventoryClipboard::retrieve(objects);
  704. S32 count = objects.size();
  705. for (S32 i = 0; i < count; ++i)
  706. {
  707. const LLUUID& object_id = objects[i];
  708. if (!model->isObjectDescendentOf(object_id, root_id))
  709. {
  710. return false;
  711. }
  712. const LLViewerInventoryItem* item = model->getItem(object_id);
  713. if (item && !LLAssetType::lookupCanLink(item->getActualType()))
  714. {
  715. return false;
  716. }
  717. const LLViewerInventoryCategory* cat = model->getCategory(object_id);
  718. #if 0 // We do not support pasting folders as links (it is useless anyway...)
  719. if (cat && cat->isProtected())
  720. #else
  721. if (cat)
  722. #endif
  723. {
  724. return false;
  725. }
  726. }
  727. //MK
  728. if (gRLenabled)
  729. {
  730. // Do not allow if either the destination folder or the source folder
  731. // is locked
  732. LLViewerInventoryCategory* current_cat = model->getCategory(mUUID);
  733. if (current_cat)
  734. {
  735. for (S32 i = count - 1; i >= 0; --i)
  736. {
  737. const LLUUID& obj_id = objects[i];
  738. const LLUUID& parent_id =
  739. model->getObject(obj_id)->getParentUUID();
  740. if (gRLInterface.isFolderLocked(current_cat) ||
  741. gRLInterface.isFolderLocked(model->getCategory(parent_id)))
  742. {
  743. return false;
  744. }
  745. }
  746. }
  747. }
  748. //mk
  749. return true;
  750. }
  751. //virtual
  752. bool LLInvFVBridge::cutToClipboard() const
  753. {
  754. HBInventoryClipboard::addCut(mUUID);
  755. return true;
  756. }
  757. // Generic method for commonly-used entries
  758. void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
  759. std::vector<std::string>& items,
  760. std::vector<std::string>& disabled_items,
  761. U32 flags)
  762. {
  763. bool not_first_selected_item = (flags & FIRST_SELECTED_ITEM) == 0;
  764. bool agent_inventory = isAgentInventory();
  765. const LLInventoryObject* invobjp = getInventoryObject();
  766. if (invobjp)
  767. {
  768. bool need_separator = false;
  769. if (invobjp->getIsLinkType())
  770. {
  771. items.emplace_back("Find Original");
  772. if (isLinkedObjectMissing())
  773. {
  774. disabled_items.emplace_back("Find Original");
  775. }
  776. need_separator = true;
  777. }
  778. else
  779. {
  780. if (agent_inventory)
  781. {
  782. // Add thumbnail support, when using the AIS3 fetching. HB
  783. if (LLInventoryModelFetch::useAISFetching())
  784. {
  785. items.emplace_back("Thumbnail");
  786. }
  787. items.emplace_back("Rename");
  788. if (not_first_selected_item || !isItemRenameable())
  789. {
  790. disabled_items.emplace_back("Rename");
  791. }
  792. need_separator = true;
  793. }
  794. if (show_asset_id)
  795. {
  796. items.emplace_back("Copy Asset UUID");
  797. if (not_first_selected_item ||
  798. !(isItemPermissive() || gAgent.isGodlike()))
  799. {
  800. disabled_items.emplace_back("Copy Asset UUID");
  801. }
  802. need_separator = true;
  803. }
  804. }
  805. if (need_separator)
  806. {
  807. items.emplace_back("Copy Separator");
  808. }
  809. items.emplace_back("Copy");
  810. if (!isItemCopyable())
  811. {
  812. disabled_items.emplace_back("Copy");
  813. }
  814. }
  815. if (agent_inventory)
  816. {
  817. items.emplace_back("Cut");
  818. if (!isItemMovable())
  819. {
  820. disabled_items.emplace_back("Cut");
  821. }
  822. }
  823. if (!isInCOF() && agent_inventory)
  824. {
  825. items.emplace_back("Paste");
  826. if (not_first_selected_item || !isClipboardPasteable())
  827. {
  828. disabled_items.emplace_back("Paste");
  829. }
  830. if (!isInMarketplace())
  831. {
  832. items.emplace_back("Paste As Link");
  833. if (not_first_selected_item || !isClipboardPasteableAsLink())
  834. {
  835. disabled_items.emplace_back("Paste As Link");
  836. }
  837. }
  838. }
  839. if (agent_inventory)
  840. {
  841. uuid_vec_t selected_items;
  842. mInventoryPanel->getRootFolder()->getSelection(selected_items);
  843. if (movable_objects_with_same_parent(selected_items))
  844. {
  845. items.emplace_back("Move In New Folder");
  846. }
  847. // If this is the context menu for a folder and only one folder is
  848. // selected, and that folder got children, and it is not unique, then
  849. // add the option to extract all the children from that folder.
  850. if ((flags & ITEM_IN_MULTI_SELECTION) == 0 && hasChildren())
  851. {
  852. const LLViewerInventoryCategory* cat =
  853. invobjp->asViewerInventoryCategory();
  854. if (cat && !cat->isUnique())
  855. {
  856. items.emplace_back("Extract From Folder");
  857. }
  858. }
  859. items.emplace_back("Paste Separator");
  860. items.emplace_back("Delete");
  861. if (!isItemRemovable())
  862. {
  863. disabled_items.emplace_back("Delete");
  864. }
  865. }
  866. }
  867. //virtual
  868. void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  869. {
  870. std::vector<std::string> items;
  871. std::vector<std::string> disabled_items;
  872. if (isInTrash())
  873. {
  874. const LLInventoryObject* invobjp = getInventoryObject();
  875. if (invobjp && invobjp->getIsLinkType())
  876. {
  877. items.emplace_back("Find Original");
  878. if (isLinkedObjectMissing())
  879. {
  880. disabled_items.emplace_back("Find Original");
  881. }
  882. }
  883. items.emplace_back("Purge Item");
  884. if (!isItemRemovable())
  885. {
  886. disabled_items.emplace_back("Purge Item");
  887. }
  888. items.emplace_back("Restore Item");
  889. }
  890. else
  891. {
  892. items.emplace_back("Open");
  893. items.emplace_back("Properties");
  894. getClipboardEntries(true, items, disabled_items, flags);
  895. }
  896. set_menu_entries_state(menu, items, disabled_items);
  897. }
  898. //virtual
  899. bool LLInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const
  900. {
  901. const LLInventoryObject* invobjp = getInventoryObject();
  902. if (invobjp)
  903. {
  904. *type = LLAssetType::lookupDragAndDropType(invobjp->getActualType());
  905. if (*type == DAD_NONE)
  906. {
  907. return false;
  908. }
  909. const LLUUID& obj_id = invobjp->getUUID();
  910. *id = obj_id;
  911. if (*type == DAD_CATEGORY)
  912. {
  913. LLInventoryModelFetch::getInstance()->start(obj_id);
  914. }
  915. return true;
  916. }
  917. return false;
  918. }
  919. LLInventoryObject* LLInvFVBridge::getInventoryObject() const
  920. {
  921. LLInventoryObject* invobjp = NULL;
  922. LLInventoryModel* modelp = mInventoryPanel->getModel();
  923. if (modelp)
  924. {
  925. invobjp = (LLInventoryObject*)modelp->getObject(mUUID);
  926. }
  927. return invobjp;
  928. }
  929. bool LLInvFVBridge::isInTrash() const
  930. {
  931. LLInventoryModel* modelp = mInventoryPanel->getModel();
  932. return modelp && modelp->isInTrash(mUUID);
  933. }
  934. bool LLInvFVBridge::isInLostAndFound() const
  935. {
  936. LLInventoryModel* modelp = mInventoryPanel->getModel();
  937. return modelp &&
  938. modelp->isObjectDescendentOf(mUUID, modelp->getLostAndFoundID());
  939. }
  940. bool LLInvFVBridge::isInCOF() const
  941. {
  942. LLInventoryModel* modelp = mInventoryPanel->getModel();
  943. return modelp && modelp->isInCOF(mUUID);
  944. }
  945. bool LLInvFVBridge::isInMarketplace() const
  946. {
  947. LLInventoryModel* modelp = mInventoryPanel->getModel();
  948. return modelp && modelp->isInMarketPlace(mUUID);
  949. }
  950. bool LLInvFVBridge::isLinkedObjectInTrash() const
  951. {
  952. if (isInTrash())
  953. {
  954. return true;
  955. }
  956. const LLInventoryObject* invobjp = getInventoryObject();
  957. if (invobjp && invobjp->getIsLinkType())
  958. {
  959. LLInventoryModel* modelp = mInventoryPanel->getModel();
  960. return modelp && modelp->isInTrash(invobjp->getLinkedUUID());
  961. }
  962. return false;
  963. }
  964. bool LLInvFVBridge::isLinkedObjectMissing() const
  965. {
  966. const LLInventoryObject* invobjp = getInventoryObject();
  967. return !invobjp ||
  968. (invobjp->getIsLinkType() &&
  969. LLAssetType::lookupIsLinkType(invobjp->getType()));
  970. }
  971. bool LLInvFVBridge::isAgentInventory() const
  972. {
  973. LLInventoryModel* modelp = mInventoryPanel->getModel();
  974. if (!modelp)
  975. {
  976. return false;
  977. }
  978. if (gInventory.getRootFolderID() == mUUID)
  979. {
  980. return true;
  981. }
  982. return modelp->isObjectDescendentOf(mUUID, gInventory.getRootFolderID());
  983. }
  984. //static
  985. void LLInvFVBridge::changeItemParent(LLInventoryModel* modelp,
  986. LLViewerInventoryItem* vitemp,
  987. const LLUUID& new_parent_id,
  988. bool restamp)
  989. {
  990. if (modelp && vitemp && vitemp->getParentUUID() != new_parent_id)
  991. {
  992. //MK
  993. if (gRLenabled)
  994. {
  995. LLViewerInventoryCategory* cat_parentp =
  996. modelp->getCategory(vitemp->getParentUUID());
  997. LLViewerInventoryCategory* cat_new_parentp =
  998. modelp->getCategory(new_parent_id);
  999. // We can move this category if we are moving it from a non shared
  1000. // folder to another one, even if both folders are locked
  1001. if ((gRLInterface.isUnderRlvShare(cat_parentp) ||
  1002. gRLInterface.isUnderRlvShare(cat_new_parentp)) &&
  1003. (gRLInterface.isFolderLocked(cat_parentp) ||
  1004. gRLInterface.isFolderLocked(cat_new_parentp)))
  1005. {
  1006. return;
  1007. }
  1008. }
  1009. //mk
  1010. modelp->changeItemParent(vitemp, new_parent_id, restamp);
  1011. }
  1012. }
  1013. //static
  1014. void LLInvFVBridge::changeCategoryParent(LLInventoryModel* modelp,
  1015. LLViewerInventoryCategory* vcatp,
  1016. const LLUUID& new_parent_id,
  1017. bool restamp)
  1018. {
  1019. if (modelp && vcatp &&
  1020. !modelp->isObjectDescendentOf(new_parent_id, vcatp->getUUID()))
  1021. {
  1022. //MK
  1023. if (gRLenabled)
  1024. {
  1025. LLViewerInventoryCategory* cat_new_parentp =
  1026. modelp->getCategory(new_parent_id);
  1027. // We can move this category if we are moving it from a non shared
  1028. // folder to another one, even if both folders are locked
  1029. if ((gRLInterface.isUnderRlvShare(vcatp) ||
  1030. gRLInterface.isUnderRlvShare(cat_new_parentp)) &&
  1031. (gRLInterface.isFolderLocked(vcatp) ||
  1032. gRLInterface.isFolderLocked(cat_new_parentp)))
  1033. {
  1034. return;
  1035. }
  1036. }
  1037. //mk
  1038. modelp->changeCategoryParent(vcatp, new_parent_id, restamp);
  1039. }
  1040. }
  1041. //static
  1042. LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
  1043. LLAssetType::EType actual_asset_type,
  1044. LLInventoryType::EType inv_type,
  1045. LLInventoryPanel* panelp,
  1046. const LLUUID& uuid,
  1047. U32 flags)
  1048. {
  1049. static LLUUID last_uuid;
  1050. bool warn = false;
  1051. S32 sub_type = -1;
  1052. LLInvFVBridge* self = NULL;
  1053. switch (asset_type)
  1054. {
  1055. case LLAssetType::AT_TEXTURE:
  1056. if (inv_type != LLInventoryType::IT_TEXTURE &&
  1057. inv_type != LLInventoryType::IT_SNAPSHOT)
  1058. {
  1059. warn = true;
  1060. }
  1061. self = new LLTextureBridge(panelp, uuid, inv_type);
  1062. break;
  1063. case LLAssetType::AT_SOUND:
  1064. if (inv_type != LLInventoryType::IT_SOUND)
  1065. {
  1066. warn = true;
  1067. }
  1068. self = new LLSoundBridge(panelp, uuid);
  1069. break;
  1070. case LLAssetType::AT_LANDMARK:
  1071. if (inv_type != LLInventoryType::IT_LANDMARK)
  1072. {
  1073. warn = true;
  1074. }
  1075. self = new LLLandmarkBridge(panelp, uuid, flags);
  1076. break;
  1077. case LLAssetType::AT_CALLINGCARD:
  1078. if (inv_type != LLInventoryType::IT_CALLINGCARD)
  1079. {
  1080. warn = true;
  1081. }
  1082. self = new LLCallingCardBridge(panelp, uuid);
  1083. break;
  1084. case LLAssetType::AT_SCRIPT:
  1085. if (inv_type != LLInventoryType::IT_LSL)
  1086. {
  1087. warn = true;
  1088. }
  1089. self = new LLScriptBridge(panelp, uuid);
  1090. break;
  1091. case LLAssetType::AT_OBJECT:
  1092. if (inv_type != LLInventoryType::IT_OBJECT &&
  1093. inv_type != LLInventoryType::IT_ATTACHMENT)
  1094. {
  1095. warn = true;
  1096. }
  1097. self = new LLObjectBridge(panelp, uuid, inv_type, flags);
  1098. break;
  1099. case LLAssetType::AT_NOTECARD:
  1100. if (inv_type != LLInventoryType::IT_NOTECARD)
  1101. {
  1102. warn = true;
  1103. }
  1104. self = new LLNotecardBridge(panelp, uuid);
  1105. break;
  1106. case LLAssetType::AT_ANIMATION:
  1107. if (inv_type != LLInventoryType::IT_ANIMATION)
  1108. {
  1109. warn = true;
  1110. }
  1111. self = new LLAnimationBridge(panelp, uuid);
  1112. break;
  1113. case LLAssetType::AT_GESTURE:
  1114. if (inv_type != LLInventoryType::IT_GESTURE)
  1115. {
  1116. warn = true;
  1117. }
  1118. self = new LLGestureBridge(panelp, uuid);
  1119. break;
  1120. case LLAssetType::AT_LSL_TEXT:
  1121. if (inv_type != LLInventoryType::IT_LSL)
  1122. {
  1123. warn = true;
  1124. }
  1125. self = new LLLSLTextBridge(panelp, uuid);
  1126. break;
  1127. case LLAssetType::AT_CLOTHING:
  1128. case LLAssetType::AT_BODYPART:
  1129. sub_type = flags & LLInventoryItem::II_FLAGS_SUBTYPE_MASK;
  1130. if (inv_type != LLInventoryType::IT_WEARABLE)
  1131. {
  1132. warn = true;
  1133. }
  1134. self = new LLWearableBridge(panelp, uuid, asset_type, inv_type,
  1135. (LLWearableType::EType)sub_type);
  1136. break;
  1137. case LLAssetType::AT_CATEGORY:
  1138. if (actual_asset_type == LLAssetType::AT_LINK_FOLDER)
  1139. {
  1140. // Create a link folder handler instead.
  1141. self = new LLLinkFolderBridge(panelp, uuid);
  1142. break;
  1143. }
  1144. self = new LLFolderBridge(panelp, uuid);
  1145. break;
  1146. case LLAssetType::AT_LINK:
  1147. case LLAssetType::AT_LINK_FOLDER:
  1148. // Only should happen for broken links.
  1149. self = new LLLinkItemBridge(panelp, uuid);
  1150. break;
  1151. #if LL_MESH_ASSET_SUPPORT
  1152. case LLAssetType::AT_MESH:
  1153. if (inv_type != LLInventoryType::IT_MESH)
  1154. {
  1155. warn = true;
  1156. }
  1157. self = new LLMeshBridge(panelp, uuid);
  1158. break;
  1159. case LLAssetType::AT_GLTF:
  1160. case LLAssetType::AT_GLTF_BIN:
  1161. if (inv_type != LLInventoryType::IT_GLTF)
  1162. {
  1163. warn = true;
  1164. }
  1165. // Same no-op bridge as for a SLM mesh, for now. HB
  1166. self = new LLMeshBridge(panelp, uuid);
  1167. break;
  1168. #endif
  1169. case LLAssetType::AT_SETTINGS:
  1170. sub_type = flags & LLInventoryItem::II_FLAGS_SUBTYPE_MASK;
  1171. if (inv_type != LLInventoryType::IT_SETTINGS)
  1172. {
  1173. warn = true;
  1174. }
  1175. self = new LLSettingsBridge(panelp, uuid, sub_type);
  1176. break;
  1177. case LLAssetType::AT_MATERIAL:
  1178. if (inv_type != LLInventoryType::IT_MATERIAL)
  1179. {
  1180. warn = true;
  1181. }
  1182. self = new LLMaterialBridge(panelp, uuid);
  1183. break;
  1184. default:
  1185. llwarns_once << "Unhandled asset type: " << (S32)asset_type << llendl;
  1186. }
  1187. if (warn && uuid != last_uuid)
  1188. {
  1189. last_uuid = uuid;
  1190. llwarns << LLAssetType::lookup(asset_type)
  1191. << " asset has inventory type "
  1192. << safe_inv_type_lookup(inv_type)
  1193. << " on uuid " << uuid << llendl;
  1194. }
  1195. if (self)
  1196. {
  1197. self->mInvType = inv_type;
  1198. self->mSubType = sub_type;
  1199. }
  1200. return self;
  1201. }
  1202. void LLInvFVBridge::purgeItem(LLInventoryModel* modelp, const LLUUID& id)
  1203. {
  1204. LLInventoryObject* invobjp = modelp ? modelp->getObject(id) : NULL;
  1205. if (invobjp && id.notNull())
  1206. {
  1207. remove_inventory_object(id);
  1208. }
  1209. }
  1210. ///////////////////////////////////////////////////////////////////////////////
  1211. // LLItemBridge
  1212. ///////////////////////////////////////////////////////////////////////////////
  1213. //virtual
  1214. void LLItemBridge::performAction(LLFolderView* folderp,
  1215. LLInventoryModel* modelp,
  1216. const std::string& action)
  1217. {
  1218. if (action == "goto")
  1219. {
  1220. gotoItem(folderp);
  1221. }
  1222. else if (action == "open")
  1223. {
  1224. openItem();
  1225. }
  1226. else if (action == "properties")
  1227. {
  1228. showProperties();
  1229. }
  1230. else if (action == "purge")
  1231. {
  1232. purgeItem(modelp, mUUID);
  1233. }
  1234. #if LL_RESTORE_TO_WORLD
  1235. else if (action == "restoreToWorld")
  1236. {
  1237. gNotifications.add("ObjectRestoreToWorld", LLSD(), LLSD(),
  1238. boost::bind(restore_to_world_callback, _1, _2,
  1239. this));
  1240. }
  1241. #endif
  1242. else if (action == "restore")
  1243. {
  1244. restoreItem();
  1245. }
  1246. else if (action == "thumbnail")
  1247. {
  1248. HBFloaterThumbnail::showInstance(mUUID);
  1249. }
  1250. else if (action == "copy_uuid")
  1251. {
  1252. // Single item only
  1253. HBInventoryClipboard::storeAsset(modelp->getItem(mUUID));
  1254. }
  1255. else if (action == "paste_link")
  1256. {
  1257. // Single item only
  1258. LLViewerInventoryItem* vitemp = modelp->getItem(mUUID);
  1259. if (vitemp)
  1260. {
  1261. LLFolderViewItem* fvitemp =
  1262. folderp->getItemByID(vitemp->getParentUUID());
  1263. if (fvitemp)
  1264. {
  1265. fvitemp->getListener()->pasteLinkFromClipboard();
  1266. }
  1267. }
  1268. }
  1269. else if (action == "marketplace_edit_listing")
  1270. {
  1271. LLMarketplace::editListing(mUUID);
  1272. }
  1273. }
  1274. //virtual
  1275. void LLItemBridge::selectItem()
  1276. {
  1277. LLViewerInventoryItem* vitemp = getItem();
  1278. if (vitemp && !vitemp->isFinished())
  1279. {
  1280. vitemp->fetchFromServer();
  1281. }
  1282. }
  1283. //virtual
  1284. void LLItemBridge::restoreItem()
  1285. {
  1286. LLViewerInventoryItem* vitemp = getItem();
  1287. if (!vitemp)
  1288. {
  1289. return;
  1290. }
  1291. LLInventoryModel* modelp = mInventoryPanel->getModel();
  1292. const LLUUID& new_parent =
  1293. modelp->findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(vitemp->getType()));
  1294. // 'false' -> Do not restamp on restore.
  1295. changeItemParent(modelp, vitemp, new_parent, false);
  1296. }
  1297. #if LL_RESTORE_TO_WORLD
  1298. //virtual
  1299. void LLItemBridge::restoreToWorld()
  1300. {
  1301. if (!gAgent.getRegion()) return;
  1302. LLViewerInventoryItem* vitemp = getItem();
  1303. if (vitemp)
  1304. {
  1305. LLMessageSystem* msg = gMessageSystemp;
  1306. msg->newMessage("RezRestoreToWorld");
  1307. msg->nextBlockFast(_PREHASH_AgentData);
  1308. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  1309. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  1310. msg->nextBlockFast(_PREHASH_InventoryData);
  1311. vitemp->packMessage(msg);
  1312. msg->sendReliable(gAgent.getRegionHost());
  1313. }
  1314. // Similar functionality to the drag and drop rez logic
  1315. bool remove_from_inventory = false;
  1316. // Remove local inventory copy, sim will deal with permissions and removing
  1317. // the item from the actual inventory if its a no-copy etc
  1318. if (!vitemp->getPermissions().allowCopyBy(gAgentID))
  1319. {
  1320. remove_from_inventory = true;
  1321. }
  1322. // Check if it is in the trash (again similar to the normal rez logic).
  1323. if (gInventory.isInTrash(vitemp->getUUID()))
  1324. {
  1325. remove_from_inventory = true;
  1326. }
  1327. if (remove_from_inventory)
  1328. {
  1329. gInventory.deleteObject(itemp->getUUID());
  1330. gInventory.notifyObservers();
  1331. }
  1332. }
  1333. #endif
  1334. //virtual
  1335. void LLItemBridge::gotoItem(LLFolderView*)
  1336. {
  1337. LLInventoryObject* invobjp = getInventoryObject();
  1338. if (invobjp && invobjp->getIsLinkType())
  1339. {
  1340. LLFloaterInventory* floaterp = LLFloaterInventory::getActiveFloater();
  1341. if (floaterp)
  1342. {
  1343. floaterp->getPanel()->setSelection(invobjp->getLinkedUUID(),
  1344. TAKE_FOCUS_NO);
  1345. }
  1346. }
  1347. }
  1348. //virtual
  1349. LLUIImagePtr LLItemBridge::getIcon() const
  1350. {
  1351. return LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT);
  1352. }
  1353. //virtual
  1354. PermissionMask LLItemBridge::getPermissionMask() const
  1355. {
  1356. PermissionMask perm_mask = 0;
  1357. LLViewerInventoryItem* vitemp = getItem();
  1358. if (vitemp)
  1359. {
  1360. const LLPermissions& perms = vitemp->getPermissions();
  1361. if (perms.allowCopyBy(gAgentID))
  1362. {
  1363. perm_mask |= PERM_COPY;
  1364. }
  1365. if (perms.allowModifyBy(gAgentID))
  1366. {
  1367. perm_mask |= PERM_MODIFY;
  1368. }
  1369. if (perms.allowTransferBy(gAgentID))
  1370. {
  1371. perm_mask |= PERM_TRANSFER;
  1372. }
  1373. }
  1374. return perm_mask;
  1375. }
  1376. //virtual
  1377. const std::string& LLItemBridge::getDisplayName() const
  1378. {
  1379. if (mDisplayName.empty())
  1380. {
  1381. buildDisplayName(getItem(), mDisplayName);
  1382. }
  1383. return mDisplayName;
  1384. }
  1385. //virtual
  1386. void LLItemBridge::buildDisplayName(LLInventoryItem* itemp, std::string& name)
  1387. {
  1388. if (itemp)
  1389. {
  1390. name = itemp->getName();
  1391. }
  1392. else
  1393. {
  1394. name.clear();
  1395. }
  1396. }
  1397. //virtual
  1398. std::string LLItemBridge::getLabelSuffix() const
  1399. {
  1400. static const std::string link = " (" + LLTrans::getString("link") + ")";
  1401. static const std::string broken = " (" + LLTrans::getString("brokenlink") +
  1402. ")";
  1403. static const std::string nocopy = " (" + LLTrans::getString("nocopy") + ")";
  1404. static const std::string nomod = " (" + LLTrans::getString("nomod") + ")";
  1405. static const std::string noxfr = " (" + LLTrans::getString("noxfr") + ")";
  1406. std::string suffix;
  1407. LLViewerInventoryItem* vitemp = getItem();
  1408. if (vitemp)
  1409. {
  1410. if (LLAssetType::lookupIsLinkType(vitemp->getType()))
  1411. {
  1412. return broken;
  1413. }
  1414. if (vitemp->getIsLinkType())
  1415. {
  1416. return link;
  1417. }
  1418. // It is a bit confusing to list permissions for calling cards.
  1419. if (vitemp->getType() != LLAssetType::AT_CALLINGCARD)
  1420. {
  1421. const LLPermissions& perms = vitemp->getPermissions();
  1422. if (perms.getOwner() == gAgentID)
  1423. {
  1424. if (!perms.allowCopyBy(gAgentID))
  1425. {
  1426. suffix += nocopy;
  1427. }
  1428. if (!perms.allowModifyBy(gAgentID))
  1429. {
  1430. suffix += nomod;
  1431. }
  1432. if (!perms.allowTransferBy(gAgentID))
  1433. {
  1434. suffix += noxfr;
  1435. }
  1436. }
  1437. }
  1438. }
  1439. return suffix;
  1440. }
  1441. //virtual
  1442. time_t LLItemBridge::getCreationDate() const
  1443. {
  1444. LLViewerInventoryItem* vitemp = getItem();
  1445. return vitemp ? vitemp->getCreationDate() : 0;
  1446. }
  1447. //virtual
  1448. bool LLItemBridge::isItemRenameable() const
  1449. {
  1450. LLViewerInventoryItem* vitemp = getItem();
  1451. return vitemp && vitemp->getPermissions().allowModifyBy(gAgentID);
  1452. }
  1453. //virtual
  1454. bool LLItemBridge::renameItem(const std::string& new_name)
  1455. {
  1456. if (!isItemRenameable()) return false;
  1457. LLPreview::rename(mUUID, getPrefix() + new_name);
  1458. LLInventoryModel* model = mInventoryPanel->getModel();
  1459. if (!model) return false;
  1460. LLViewerInventoryItem* vitemp = getItem();
  1461. if (vitemp && vitemp->getName() != new_name)
  1462. {
  1463. LLSD updates;
  1464. updates["name"] = new_name;
  1465. update_inventory_item(vitemp->getUUID(), updates);
  1466. }
  1467. // Return false because we either notified observers (and therefore
  1468. // rebuilt) or we didn't update.
  1469. return false;
  1470. }
  1471. //virtual
  1472. bool LLItemBridge::removeItem()
  1473. {
  1474. if (!isItemRemovable())
  1475. {
  1476. return false;
  1477. }
  1478. LLInventoryModel* modelp = mInventoryPanel->getModel();
  1479. if (!modelp)
  1480. {
  1481. return false;
  1482. }
  1483. const LLUUID& trash_id = modelp->getTrashID();
  1484. LLViewerInventoryItem* vitemp = getItem();
  1485. // If item is not already in trash
  1486. if (vitemp && !modelp->isObjectDescendentOf(mUUID, trash_id))
  1487. {
  1488. // Move to trash, and restamp
  1489. changeItemParent(modelp, vitemp, trash_id, true);
  1490. // Delete was successful
  1491. return true;
  1492. }
  1493. // Tried to delete already item in trash (should purge ?)
  1494. return false;
  1495. }
  1496. //virtual
  1497. bool LLItemBridge::isItemCopyable() const
  1498. {
  1499. LLViewerInventoryItem* vitemp = getItem();
  1500. // All non-links can be copied (at least as a link), and non-broken links
  1501. // can get their linked object copied too (at least as a link as well).
  1502. return vitemp && (!vitemp->getIsLinkType() || !isLinkedObjectMissing());
  1503. }
  1504. //virtual
  1505. bool LLItemBridge::copyToClipboard() const
  1506. {
  1507. if (isItemCopyable())
  1508. {
  1509. LLViewerInventoryItem* vitemp = getItem();
  1510. if (!vitemp || (vitemp->getIsLinkType() && isLinkedObjectMissing()))
  1511. {
  1512. // No item (paranoia, should not happen), or broken link: abort !
  1513. return false;
  1514. }
  1515. HBInventoryClipboard::add(vitemp->getLinkedUUID());
  1516. return true;
  1517. }
  1518. return false;
  1519. }
  1520. //virtual
  1521. LLViewerInventoryItem* LLItemBridge::getItem() const
  1522. {
  1523. LLViewerInventoryItem* vitemp = NULL;
  1524. LLInventoryModel* modelp = mInventoryPanel->getModel();
  1525. if (modelp)
  1526. {
  1527. vitemp = modelp->getItem(mUUID);
  1528. }
  1529. return vitemp;
  1530. }
  1531. //virtual
  1532. const LLUUID& LLItemBridge::getThumbnailUUID() const
  1533. {
  1534. LLViewerInventoryItem* vitemp = NULL;
  1535. LLInventoryModel* modelp = mInventoryPanel->getModel();
  1536. if (modelp)
  1537. {
  1538. vitemp = modelp->getItem(mUUID);
  1539. }
  1540. return vitemp ? vitemp->getThumbnailUUID() : LLUUID::null;
  1541. }
  1542. //virtual
  1543. bool LLItemBridge::isItemPermissive() const
  1544. {
  1545. LLViewerInventoryItem* vitemp = getItem();
  1546. return vitemp && vitemp->getPermissions().unrestricted();
  1547. }
  1548. ///////////////////////////////////////////////////////////////////////////////
  1549. // LLFolderBridge
  1550. ///////////////////////////////////////////////////////////////////////////////
  1551. LLFolderBridge* LLFolderBridge::sSelf = NULL;
  1552. //virtual
  1553. LLFolderBridge::~LLFolderBridge()
  1554. {
  1555. if (sSelf == this)
  1556. {
  1557. sSelf = NULL;
  1558. }
  1559. }
  1560. // Can it be moved to another folder ?
  1561. //virtual
  1562. bool LLFolderBridge::isItemMovable()
  1563. {
  1564. bool can_move = false;
  1565. LLInventoryObject* obj = getInventoryObject();
  1566. if (obj)
  1567. {
  1568. LLViewerInventoryCategory* cat = (LLViewerInventoryCategory*)obj;
  1569. can_move = !cat->isProtected();
  1570. }
  1571. LLInventoryModel* model = mInventoryPanel->getModel();
  1572. if (model && can_move)
  1573. {
  1574. can_move = model->isObjectDescendentOf(mUUID,
  1575. model->getRootFolderID());
  1576. }
  1577. return can_move;
  1578. }
  1579. // Can it be destroyed (or moved to trash) ?
  1580. //virtual
  1581. bool LLFolderBridge::isItemRemovable()
  1582. {
  1583. const LLUUID& root_id = gInventory.getRootFolderID();
  1584. LLInventoryModel* modelp = mInventoryPanel->getModel();
  1585. if (!modelp || !modelp->isObjectDescendentOf(mUUID, root_id))
  1586. {
  1587. return false;
  1588. }
  1589. LLViewerInventoryCategory* catp = modelp->getCategory(mUUID);
  1590. if (!isAgentAvatarValid() || !catp || catp->isProtected())
  1591. {
  1592. return false;
  1593. }
  1594. if (isInMarketplace())
  1595. {
  1596. return LLMarketplaceData::getInstance()->isSLMDataFetched() &&
  1597. !LLMarketplace::isFolderActive(mUUID);
  1598. }
  1599. LLInventoryModel::cat_array_t child_cat;
  1600. LLInventoryModel::item_array_t child_items;
  1601. modelp->collectDescendents(mUUID, child_cat, child_items, false);
  1602. for (S32 i = 0, count = child_items.size(); i < count; ++i)
  1603. {
  1604. LLViewerInventoryItem* vitemp = child_items[i];
  1605. if (vitemp && !vitemp->getIsLinkType() &&
  1606. get_is_item_worn(vitemp->getUUID(), false))
  1607. {
  1608. return false;
  1609. }
  1610. }
  1611. return true;
  1612. }
  1613. //virtual
  1614. bool LLFolderBridge::isUpToDate() const
  1615. {
  1616. LLInventoryModel* modelp = mInventoryPanel->getModel();
  1617. if (!modelp) return false;
  1618. LLViewerInventoryCategory* vcatp = modelp->getCategory(mUUID);
  1619. return vcatp && !vcatp->isVersionUnknown();
  1620. }
  1621. //virtual
  1622. bool LLFolderBridge::isItemCopyable() const
  1623. {
  1624. if (getPreferredType() != LLFolderType::FT_NONE)
  1625. {
  1626. // Do not allow to copy any special folder
  1627. return false;
  1628. }
  1629. // Get the content of the folder
  1630. LLInventoryModel::cat_array_t* cat_array;
  1631. LLInventoryModel::item_array_t* item_array;
  1632. gInventory.getDirectDescendentsOf(mUUID, cat_array, item_array);
  1633. // Check the items
  1634. LLInventoryModel::item_array_t item_array_copy = *item_array;
  1635. for (LLInventoryModel::item_array_t::iterator
  1636. iter = item_array_copy.begin(), end = item_array_copy.end();
  1637. iter != end; ++iter)
  1638. {
  1639. LLViewerInventoryItem* vitemp = *iter;
  1640. if (vitemp) // Paranoia
  1641. {
  1642. LLItemBridge item_br(mInventoryPanel, vitemp->getUUID());
  1643. if (!item_br.isItemCopyable())
  1644. {
  1645. return false;
  1646. }
  1647. }
  1648. }
  1649. // Recurse through the sub-folders
  1650. LLInventoryModel::cat_array_t cat_array_copy = *cat_array;
  1651. for (LLInventoryModel::cat_array_t::iterator
  1652. iter = cat_array_copy.begin(), end = cat_array_copy.end();
  1653. iter != end; ++iter)
  1654. {
  1655. LLViewerInventoryCategory* cat = *iter;
  1656. if (cat) // Paranoia
  1657. {
  1658. LLFolderBridge cat_br(mInventoryPanel, cat->getUUID());
  1659. if (!cat_br.isItemCopyable())
  1660. {
  1661. return false;
  1662. }
  1663. }
  1664. }
  1665. return true;
  1666. }
  1667. //virtual
  1668. bool LLFolderBridge::copyToClipboard() const
  1669. {
  1670. if (isItemCopyable())
  1671. {
  1672. LLViewerInventoryCategory* cat = getCategory();
  1673. if (!cat || (cat->getIsLinkType() && isLinkedObjectMissing()))
  1674. {
  1675. // No category (paranoia, should not happen), or broken link
  1676. return false;
  1677. }
  1678. HBInventoryClipboard::add(cat->getLinkedUUID());
  1679. return true;
  1680. }
  1681. return false;
  1682. }
  1683. //virtual
  1684. bool LLFolderBridge::isClipboardPasteableAsLink() const
  1685. {
  1686. #if 0 // We do not support pasting folders as links (it is useless anyway...)
  1687. // Check normal paste-as-link permissions
  1688. if (!LLInvFVBridge::isClipboardPasteableAsLink())
  1689. {
  1690. return false;
  1691. }
  1692. LLInventoryModel* model = mInventoryPanel->getModel();
  1693. if (!model)
  1694. {
  1695. return false;
  1696. }
  1697. const LLViewerInventoryCategory* current_cat = getCategory();
  1698. if (current_cat)
  1699. {
  1700. const LLUUID& current_cat_id = current_cat->getUUID();
  1701. uuid_vec_t objects;
  1702. HBInventoryClipboard::retrieve(objects);
  1703. S32 count = objects.size();
  1704. for (S32 i = 0; i < count; ++i)
  1705. {
  1706. const LLUUID& obj_id = objects[i];
  1707. const LLViewerInventoryCategory* cat = model->getCategory(obj_id);
  1708. if (cat)
  1709. {
  1710. const LLUUID& cat_id = cat->getUUID();
  1711. // Don't allow recursive pasting
  1712. if (cat_id == current_cat_id ||
  1713. model->isObjectDescendentOf(current_cat_id, cat_id))
  1714. {
  1715. return false;
  1716. }
  1717. }
  1718. }
  1719. }
  1720. return true;
  1721. #else
  1722. // Check normal paste-as-link permissions
  1723. return LLInvFVBridge::isClipboardPasteableAsLink();
  1724. #endif
  1725. }
  1726. bool LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* catp,
  1727. bool drop,
  1728. std::string& tooltip_msg)
  1729. {
  1730. // This should never happen, but if an inventory item is incorrectly
  1731. // parented, the UI will get confused and pass in a NULL.
  1732. if (!catp)
  1733. {
  1734. return false;
  1735. }
  1736. LLInventoryModel* modelp = mInventoryPanel->getModel();
  1737. if (!modelp || !isAgentAvatarValid() || !isAgentInventory() || isInCOF())
  1738. {
  1739. return false;
  1740. }
  1741. const LLUUID& cat_id = catp->getUUID();
  1742. const LLUUID& from_folder_uuid = catp->getParentUUID();
  1743. if (mUUID == cat_id || // Not into self
  1744. mUUID == from_folder_uuid || // Nothing would change
  1745. modelp->isObjectDescendentOf(mUUID, cat_id)) // Avoid circularity
  1746. {
  1747. return false;
  1748. }
  1749. const LLUUID& market_id = LLMarketplace::getMPL();
  1750. bool move_is_into_market = modelp->isObjectDescendentOf(mUUID, market_id);
  1751. bool move_is_from_market = modelp->isObjectDescendentOf(cat_id, market_id);
  1752. bool move_is_into_trash = isInTrash();
  1753. bool accept = false;
  1754. LLInventoryModel::cat_array_t descendent_categories;
  1755. LLInventoryModel::item_array_t descendent_items;
  1756. // Check to make sure source is agent inventory, and is represented there.
  1757. LLToolDragAndDrop::ESource source = gToolDragAndDrop.getSource();
  1758. bool is_agent_inventory = modelp->getCategory(cat_id) != NULL &&
  1759. source == LLToolDragAndDrop::SOURCE_AGENT;
  1760. if (is_agent_inventory)
  1761. {
  1762. bool movable = !((LLViewerInventoryCategory*)catp)->isProtected();
  1763. if (movable &&
  1764. getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
  1765. {
  1766. // Cannot move a folder into a stock folder
  1767. movable = false;
  1768. }
  1769. // Is the destination the trash ?
  1770. if (movable && move_is_into_trash)
  1771. {
  1772. for (S32 i = 0, count = descendent_items.size(); i < count; ++i)
  1773. {
  1774. LLViewerInventoryItem* item = descendent_items[i];
  1775. if (!item || item->getIsLinkType())
  1776. {
  1777. // Inventory links can always be destroyed
  1778. continue;
  1779. }
  1780. if (get_is_item_worn(item->getUUID(), false))
  1781. {
  1782. // It is generally movable, but not into the trash !
  1783. movable = false;
  1784. break;
  1785. }
  1786. }
  1787. }
  1788. LLMarketplaceData* marketdata = LLMarketplaceData::getInstance();
  1789. if (movable && move_is_from_market &&
  1790. marketdata->getActivationState(cat_id))
  1791. {
  1792. movable = false;
  1793. if (!tooltip_msg.empty())
  1794. {
  1795. tooltip_msg += ' ';
  1796. }
  1797. tooltip_msg = LLTrans::getString("TooltipOutboxDragActive");
  1798. }
  1799. if (movable && move_is_into_market)
  1800. {
  1801. const LLViewerInventoryCategory* master_catp =
  1802. modelp->getFirstDescendantOf(market_id, mUUID);
  1803. LLViewerInventoryCategory* dest_catp = getCategory();
  1804. S32 bundle_size = 1;
  1805. if (!drop)
  1806. {
  1807. bundle_size = gToolDragAndDrop.getCargoCount();
  1808. }
  1809. std::string error_msg;
  1810. movable = LLMarketplace::canMoveFolderInto(master_catp,
  1811. dest_catp,
  1812. (LLViewerInventoryCategory*)catp,
  1813. error_msg,
  1814. bundle_size);
  1815. }
  1816. accept = movable;
  1817. if (accept && !drop && (move_is_from_market || move_is_into_market))
  1818. {
  1819. if (move_is_from_market)
  1820. {
  1821. if (marketdata->isInActiveFolder(cat_id) ||
  1822. marketdata->isListedAndActive(cat_id))
  1823. {
  1824. if (!tooltip_msg.empty())
  1825. {
  1826. tooltip_msg += ' ';
  1827. }
  1828. if (marketdata->isListed(cat_id) ||
  1829. marketdata->isVersionFolder(cat_id))
  1830. {
  1831. // Moving the active version folder or listing folder
  1832. // itself outside the Marketplace Listings would unlist
  1833. // the listing
  1834. tooltip_msg += LLTrans::getString("TipMerchantUnlist");
  1835. }
  1836. else
  1837. {
  1838. tooltip_msg += LLTrans::getString("TipMerchantActiveChange");
  1839. }
  1840. }
  1841. else if (marketdata->isVersionFolder(cat_id))
  1842. {
  1843. // Moving the version folder from its location would
  1844. // deactivate it.
  1845. if (!tooltip_msg.empty())
  1846. {
  1847. tooltip_msg += ' ';
  1848. }
  1849. tooltip_msg += LLTrans::getString("TipMerchantClearVersion");
  1850. }
  1851. else if (marketdata->isListed(cat_id))
  1852. {
  1853. // Moving a whole listing folder folder would result in
  1854. // archival of SLM data.
  1855. if (!tooltip_msg.empty())
  1856. {
  1857. tooltip_msg += ' ';
  1858. }
  1859. tooltip_msg += LLTrans::getString("TipListingDelete");
  1860. }
  1861. }
  1862. else // move_is_into_market
  1863. {
  1864. if (marketdata->isInActiveFolder(mUUID))
  1865. {
  1866. // Moving something in an active listed listing would
  1867. // modify it.
  1868. if (!tooltip_msg.empty())
  1869. {
  1870. tooltip_msg += ' ';
  1871. }
  1872. tooltip_msg += LLTrans::getString("TipMerchantActiveChange");
  1873. }
  1874. if (!move_is_from_market)
  1875. {
  1876. if (!tooltip_msg.empty())
  1877. {
  1878. tooltip_msg += ' ';
  1879. }
  1880. tooltip_msg += LLTrans::getString("TipMerchantMoveInventory");
  1881. }
  1882. }
  1883. }
  1884. if (accept && drop)
  1885. {
  1886. // Look for any gestures and deactivate them
  1887. if (move_is_into_trash)
  1888. {
  1889. for (S32 i = 0, count = descendent_items.size();
  1890. i < count; ++i)
  1891. {
  1892. LLViewerInventoryItem* itemp = descendent_items[i];
  1893. if (itemp && itemp->getType() == LLAssetType::AT_GESTURE &&
  1894. gGestureManager.isGestureActive(itemp->getUUID()))
  1895. {
  1896. gGestureManager.deactivateGesture(itemp->getUUID());
  1897. }
  1898. }
  1899. }
  1900. if (move_is_into_market)
  1901. {
  1902. LLMarketplace::moveFolderInto((LLViewerInventoryCategory*)catp,
  1903. mUUID);
  1904. }
  1905. else
  1906. {
  1907. // Reparent the folder and restamp children if it's moving
  1908. // into trash.
  1909. changeCategoryParent(modelp,
  1910. (LLViewerInventoryCategory*)catp,
  1911. mUUID, move_is_into_trash);
  1912. }
  1913. if (move_is_from_market)
  1914. {
  1915. LLMarketplace::updateMovedFrom(from_folder_uuid, cat_id);
  1916. }
  1917. }
  1918. }
  1919. else if (LLToolDragAndDrop::SOURCE_WORLD == source)
  1920. {
  1921. if (move_is_into_market)
  1922. {
  1923. accept = false;
  1924. }
  1925. else
  1926. {
  1927. // Content category has same ID as object itself
  1928. accept = move_inv_category_world_to_agent(cat_id, mUUID, drop);
  1929. }
  1930. }
  1931. if (accept && drop && move_is_into_trash)
  1932. {
  1933. modelp->checkTrashOverflow();
  1934. }
  1935. return accept;
  1936. }
  1937. bool LLFindWearables::operator()(LLInventoryCategory*, LLInventoryItem* itemp)
  1938. {
  1939. if (!itemp)
  1940. {
  1941. return false;
  1942. }
  1943. LLAssetType::EType t = itemp->getType();
  1944. return t == LLAssetType::AT_CLOTHING || t == LLAssetType::AT_BODYPART;
  1945. }
  1946. // Used by LLFolderBridge as callback for directory recursion.
  1947. class LLRightClickInventoryFetchObserver final
  1948. : public LLInventoryFetchObserver
  1949. {
  1950. public:
  1951. LLRightClickInventoryFetchObserver()
  1952. : mCopyItems(false)
  1953. {
  1954. }
  1955. LLRightClickInventoryFetchObserver(const LLUUID& cat_id, bool copy_items)
  1956. : mCatID(cat_id),
  1957. mCopyItems(copy_items)
  1958. {
  1959. }
  1960. void done() override
  1961. {
  1962. // We have downloaded all the items, so repaint the dialog
  1963. LLFolderBridge::staticFolderOptionsMenu();
  1964. gInventory.removeObserver(this);
  1965. delete this;
  1966. }
  1967. protected:
  1968. LLUUID mCatID;
  1969. bool mCopyItems;
  1970. };
  1971. // Used by LLFolderBridge as callback for directory recursion.
  1972. class LLRightClickInventoryFetchDescendentsObserver final
  1973. : public LLInventoryFetchDescendentsObserver
  1974. {
  1975. public:
  1976. LLRightClickInventoryFetchDescendentsObserver(bool copy_items)
  1977. : mCopyItems(copy_items)
  1978. {
  1979. }
  1980. ~LLRightClickInventoryFetchDescendentsObserver() override
  1981. {
  1982. }
  1983. void done() override;
  1984. protected:
  1985. bool mCopyItems;
  1986. };
  1987. //virtual
  1988. void LLRightClickInventoryFetchDescendentsObserver::done()
  1989. {
  1990. // Avoid passing a NULL-ref as mCompleteFolders.front() down to
  1991. // gInventory.collectDescendents()
  1992. if (mCompleteFolders.empty())
  1993. {
  1994. llwarns << "Empty mCompleteFolders" << llendl;
  1995. gInventory.removeObserver(this);
  1996. delete this;
  1997. return;
  1998. }
  1999. // What we do here is get the complete information on the items in the
  2000. // library, and set up an observer that will wait for that to happen.
  2001. LLInventoryModel::cat_array_t cat_array;
  2002. LLInventoryModel::item_array_t item_array;
  2003. gInventory.collectDescendents(mCompleteFolders.front(), cat_array,
  2004. item_array, LLInventoryModel::EXCLUDE_TRASH);
  2005. LLRightClickInventoryFetchObserver* outfit =
  2006. new LLRightClickInventoryFetchObserver(mCompleteFolders.front(),
  2007. mCopyItems);
  2008. uuid_vec_t ids;
  2009. for (S32 i = 0, count = item_array.size(); i < count; ++i)
  2010. {
  2011. ids.emplace_back(item_array[i]->getUUID());
  2012. }
  2013. // Clean up, and remove this as an observer since the call to the outfit
  2014. // could notify observers and throw us into an infinite loop.
  2015. gInventory.removeObserver(this);
  2016. delete this;
  2017. // Do the fetch
  2018. outfit->fetchItems(ids);
  2019. // Not interested in waiting and this will be right 99% of the time:
  2020. outfit->done();
  2021. }
  2022. //virtual
  2023. void LLFolderBridge::performAction(LLFolderView* folderp,
  2024. LLInventoryModel* modelp,
  2025. const std::string& action)
  2026. {
  2027. if (action == "open")
  2028. {
  2029. openItem();
  2030. }
  2031. else if (action == "paste_link")
  2032. {
  2033. pasteLinkFromClipboard();
  2034. }
  2035. else if (action == "properties")
  2036. {
  2037. showProperties();
  2038. }
  2039. else if (action == "thumbnail")
  2040. {
  2041. HBFloaterThumbnail::showInstance(mUUID);
  2042. }
  2043. else if (action == "replaceoutfit")
  2044. {
  2045. modifyOutfit(false, false);
  2046. }
  2047. else if (action == "addtooutfit")
  2048. {
  2049. modifyOutfit(true, false);
  2050. }
  2051. else if (action == "wearitems")
  2052. {
  2053. modifyOutfit(true, true);
  2054. }
  2055. else if (action == "removefromoutfit")
  2056. {
  2057. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2058. if (!modelp) return;
  2059. LLViewerInventoryCategory* catp = getCategory();
  2060. if (!catp) return;
  2061. //MK
  2062. if (gRLenabled && !gRLInterface.canDetachCategory(catp))
  2063. {
  2064. return;
  2065. }
  2066. //mk
  2067. gAppearanceMgr.removeInventoryCategoryFromAvatar(catp);
  2068. }
  2069. else if (action == "updatelinks")
  2070. {
  2071. gAppearanceMgr.updateClothingOrderingInfo(mUUID);
  2072. gNotifications.add("ReorderingWearablesLinks");
  2073. }
  2074. else if (action == "purge")
  2075. {
  2076. if (modelp->isCategoryComplete(mUUID))
  2077. {
  2078. purgeItem(modelp, mUUID);
  2079. }
  2080. else
  2081. {
  2082. llwarns << "Not purging the incompletely downloaded folder: "
  2083. << mUUID << llendl;
  2084. }
  2085. }
  2086. else if (action == "restore")
  2087. {
  2088. restoreItem();
  2089. }
  2090. else if (action == "marketplace_connect")
  2091. {
  2092. LLMarketplace::checkMerchantStatus();
  2093. }
  2094. else if (action == "marketplace_list")
  2095. {
  2096. LLMarketplace::listFolder(mUUID);
  2097. }
  2098. else if (action == "marketplace_unlist")
  2099. {
  2100. LLMarketplace::listFolder(mUUID, false);
  2101. }
  2102. else if (action == "marketplace_activate")
  2103. {
  2104. LLMarketplace::activateFolder(mUUID);
  2105. }
  2106. else if (action == "marketplace_deactivate")
  2107. {
  2108. LLMarketplace::activateFolder(mUUID, false);
  2109. }
  2110. else if (action == "marketplace_get_listing")
  2111. {
  2112. LLMarketplace::getListing(mUUID);
  2113. }
  2114. else if (action == "marketplace_create_listing")
  2115. {
  2116. LLMarketplace::createListing(mUUID);
  2117. }
  2118. else if (action == "marketplace_associate_listing")
  2119. {
  2120. LLFloaterAssociateListing::show(mUUID);
  2121. }
  2122. else if (action == "marketplace_disassociate_listing")
  2123. {
  2124. LLMarketplace::clearListing(mUUID);
  2125. }
  2126. else if (action == "marketplace_check_listing")
  2127. {
  2128. LLFloaterMarketplaceValidation::show(mUUID);
  2129. }
  2130. else if (action == "marketplace_edit_listing")
  2131. {
  2132. LLMarketplace::editListing(mUUID);
  2133. }
  2134. }
  2135. //virtual
  2136. void LLFolderBridge::openItem()
  2137. {
  2138. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2139. if (modelp)
  2140. {
  2141. modelp->fetchDescendentsOf(mUUID);
  2142. }
  2143. }
  2144. //virtual
  2145. bool LLFolderBridge::isItemRenameable() const
  2146. {
  2147. LLViewerInventoryCategory* vcatp = getCategory();
  2148. //MK
  2149. if (gRLenabled && gRLInterface.isUnderRlvShare(vcatp) &&
  2150. gRLInterface.isFolderLocked(vcatp))
  2151. {
  2152. return false;
  2153. }
  2154. //mk
  2155. return vcatp && vcatp->getOwnerID() == gAgentID &&
  2156. !LLFolderType::lookupIsProtectedType(vcatp->getPreferredType());
  2157. }
  2158. //virtual
  2159. void LLFolderBridge::restoreItem()
  2160. {
  2161. LLViewerInventoryCategory* vcatp = getCategory();
  2162. if (vcatp)
  2163. {
  2164. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2165. LLFolderType::EType type =
  2166. LLFolderType::assetTypeToFolderType(vcatp->getType());
  2167. const LLUUID& new_parent = modelp->findCategoryUUIDForType(type);
  2168. // false to avoid restamping children on restore
  2169. changeCategoryParent(modelp, vcatp, new_parent, false);
  2170. }
  2171. }
  2172. //virtual
  2173. LLFolderType::EType LLFolderBridge::getPreferredType() const
  2174. {
  2175. LLFolderType::EType preferred_type = LLFolderType::FT_NONE;
  2176. LLViewerInventoryCategory* vcatp = getCategory();
  2177. if (vcatp)
  2178. {
  2179. preferred_type = vcatp->getPreferredType();
  2180. }
  2181. return preferred_type;
  2182. }
  2183. // Icons for folders are based on the preferred type
  2184. //virtual
  2185. LLUIImagePtr LLFolderBridge::getIcon() const
  2186. {
  2187. LLFolderType::EType preferred_type = LLFolderType::FT_NONE;
  2188. LLViewerInventoryCategory* vcatp = getCategory();
  2189. if (vcatp)
  2190. {
  2191. preferred_type = vcatp->getPreferredType();
  2192. }
  2193. if (preferred_type == LLFolderType::FT_NONE &&
  2194. LLMarketplace::depthNesting(mUUID) == 2)
  2195. {
  2196. preferred_type = LLFolderType::FT_MARKETPLACE_VERSION;
  2197. }
  2198. return LLViewerFolderType::lookupIcon(preferred_type);
  2199. }
  2200. //virtual
  2201. std::string LLFolderBridge::getLabelSuffix() const
  2202. {
  2203. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2204. if (modelp)
  2205. {
  2206. const LLUUID& market_id = LLMarketplace::getMPL();
  2207. if (market_id.notNull())
  2208. {
  2209. if (mUUID == market_id)
  2210. {
  2211. return LLMarketplace::rootFolderLabelSuffix();
  2212. }
  2213. if (modelp->isObjectDescendentOf(mUUID, market_id))
  2214. {
  2215. return LLMarketplace::folderLabelSuffix(mUUID);
  2216. }
  2217. }
  2218. }
  2219. return LLStringUtil::null;
  2220. }
  2221. //virtual
  2222. const LLUUID& LLFolderBridge::getThumbnailUUID() const
  2223. {
  2224. LLViewerInventoryCategory* catp = getCategory();
  2225. return catp ? catp->getThumbnailUUID() : LLUUID::null;
  2226. }
  2227. //virtual
  2228. LLFontGL::StyleFlags LLFolderBridge::getLabelStyle() const
  2229. {
  2230. S32 font = LLFontGL::NORMAL;
  2231. if (isInMarketplace() && LLMarketplace::isFolderActive(mUUID))
  2232. {
  2233. font |= LLFontGL::BOLD;
  2234. }
  2235. return (LLFontGL::StyleFlags)font;
  2236. }
  2237. //virtual
  2238. bool LLFolderBridge::renameItem(const std::string& new_name)
  2239. {
  2240. if (!isItemRenameable()) return false;
  2241. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2242. if (!modelp) return false;
  2243. rename_category(modelp, mUUID, new_name);
  2244. // Return false because we either notified observers (and therefore
  2245. // rebuilt) or we did not update.
  2246. return false;
  2247. }
  2248. //virtual
  2249. bool LLFolderBridge::removeItem()
  2250. {
  2251. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2252. if (!modelp || !isItemRemovable())
  2253. {
  2254. return false;
  2255. }
  2256. // Move it to the trash
  2257. modelp->removeCategory(mUUID);
  2258. return true;
  2259. }
  2260. //virtual
  2261. void LLFolderBridge::pasteFromClipboard()
  2262. {
  2263. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2264. if (!modelp || !isClipboardPasteable() || isInTrash() || isInCOF())
  2265. {
  2266. return;
  2267. }
  2268. bool move_is_into_market = isInMarketplace();
  2269. bool is_cut = false; // Copy mode in force
  2270. uuid_vec_t objects;
  2271. // Retrieve copied objects, if any
  2272. HBInventoryClipboard::retrieve(objects);
  2273. S32 count = objects.size();
  2274. if (!count)
  2275. {
  2276. // Retrieve cut objects, then, if any...
  2277. HBInventoryClipboard::retrieveCuts(objects);
  2278. count = objects.size();
  2279. if (!count)
  2280. {
  2281. return; // nothing to do !
  2282. }
  2283. is_cut = true; // Cut mode in force
  2284. }
  2285. LLViewerInventoryCategory* dest_catp = getCategory();
  2286. if (move_is_into_market)
  2287. {
  2288. std::string error_msg;
  2289. const LLUUID& root_id = LLMarketplace::getMPL();
  2290. const LLViewerInventoryCategory* master_catp =
  2291. modelp->getFirstDescendantOf(root_id, mUUID);
  2292. for (S32 i = 0; i < count; ++i)
  2293. {
  2294. const LLUUID& object_id = objects[i];
  2295. LLViewerInventoryItem* itemp = modelp->getItem(object_id);
  2296. if (itemp &&
  2297. !LLMarketplace::canMoveItemInto(master_catp, dest_catp,
  2298. itemp, error_msg, count - i,
  2299. true))
  2300. {
  2301. break;
  2302. }
  2303. LLViewerInventoryCategory* catp = modelp->getCategory(object_id);
  2304. if (catp &&
  2305. !LLMarketplace::canMoveFolderInto(master_catp, dest_catp, catp,
  2306. error_msg, count - i, true))
  2307. {
  2308. break;
  2309. }
  2310. }
  2311. if (!error_msg.empty())
  2312. {
  2313. LLSD subs;
  2314. subs["[ERROR_CODE]"] = error_msg;
  2315. gNotifications.add("MerchantPasteFailed", subs);
  2316. return;
  2317. }
  2318. }
  2319. else
  2320. {
  2321. // Check that all items can be moved into that folder: for the
  2322. // moment, only stock folder mismatch is checked
  2323. bool dest_is_stock =
  2324. dest_catp->getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK;
  2325. for (S32 i = 0; i < count; ++i)
  2326. {
  2327. const LLUUID& object_id = objects[i];
  2328. LLViewerInventoryItem* itemp = modelp->getItem(object_id);
  2329. LLViewerInventoryCategory* catp = modelp->getCategory(object_id);
  2330. if ((catp && dest_is_stock) ||
  2331. (itemp && !dest_catp->acceptItem(itemp)))
  2332. {
  2333. LLSD subs;
  2334. subs["[ERROR_CODE]"] =
  2335. LLTrans::getString("TooltipOutboxMixedStock");
  2336. gNotifications.add("StockPasteFailed", subs);
  2337. return;
  2338. }
  2339. }
  2340. }
  2341. for (S32 i = 0; i < count; ++i)
  2342. {
  2343. const LLUUID& object_id = objects[i];
  2344. LLViewerInventoryCategory* catp = modelp->getCategory(object_id);
  2345. if (catp)
  2346. {
  2347. if (is_cut)
  2348. {
  2349. LLMarketplace::clearListing(object_id);
  2350. if (move_is_into_market)
  2351. {
  2352. LLMarketplace::moveFolderInto(catp, mUUID);
  2353. }
  2354. else if (mUUID != object_id &&
  2355. mUUID != catp->getParentUUID() &&
  2356. !modelp->isObjectDescendentOf(mUUID, object_id))
  2357. {
  2358. changeCategoryParent(modelp, catp, mUUID, false);
  2359. }
  2360. }
  2361. else if (move_is_into_market)
  2362. {
  2363. LLMarketplace::moveFolderInto(catp, mUUID, true);
  2364. }
  2365. else
  2366. {
  2367. copy_inventory_category(modelp, catp, mUUID);
  2368. }
  2369. continue;
  2370. }
  2371. LLViewerInventoryItem* itemp = modelp->getItem(object_id);
  2372. if (!itemp)
  2373. {
  2374. continue;
  2375. }
  2376. if (is_cut)
  2377. {
  2378. if (move_is_into_market)
  2379. {
  2380. if (!LLMarketplace::moveItemInto(itemp, mUUID))
  2381. {
  2382. // Stop pasting into the marketplace as soon as we get an
  2383. // error
  2384. break;
  2385. }
  2386. }
  2387. else if (mUUID != itemp->getParentUUID())
  2388. {
  2389. changeItemParent(modelp, itemp, mUUID, false);
  2390. }
  2391. }
  2392. else if (move_is_into_market)
  2393. {
  2394. if (!LLMarketplace::moveItemInto(itemp, mUUID, true))
  2395. {
  2396. // Stop pasting into the marketplace as soon as we get an error
  2397. break;
  2398. }
  2399. }
  2400. else
  2401. {
  2402. copy_inventory_item(itemp->getPermissions().getOwner(),
  2403. itemp->getUUID(), mUUID);
  2404. }
  2405. }
  2406. modelp->notifyObservers();
  2407. }
  2408. //virtual
  2409. void LLFolderBridge::pasteLinkFromClipboard()
  2410. {
  2411. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2412. if (!modelp || isInTrash() || isInCOF() || isInMarketplace())
  2413. {
  2414. return;
  2415. }
  2416. // This description should only show if the object cannot find its baseobj:
  2417. const std::string description = "Broken link";
  2418. uuid_vec_t objects;
  2419. HBInventoryClipboard::retrieve(objects);
  2420. for (uuid_vec_t::const_iterator iter = objects.begin(),
  2421. end = objects.end();
  2422. iter != end; ++iter)
  2423. {
  2424. const LLUUID& object_id = *iter;
  2425. if (LLViewerInventoryItem* vitemp = modelp->getItem(object_id))
  2426. {
  2427. link_inventory_item(vitemp->getLinkedUUID(), mUUID, description,
  2428. LLAssetType::AT_LINK);
  2429. }
  2430. }
  2431. }
  2432. //static
  2433. void LLFolderBridge::staticFolderOptionsMenu()
  2434. {
  2435. if (sSelf)
  2436. {
  2437. sSelf->folderOptionsMenu();
  2438. }
  2439. }
  2440. void LLFolderBridge::folderOptionsMenu(U32 flags)
  2441. {
  2442. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2443. if (!modelp) return;
  2444. if (mUUID == modelp->getLostAndFoundID())
  2445. {
  2446. // This is the lost+found folder.
  2447. mItems.emplace_back("Empty Lost And Found");
  2448. LLViewerInventoryCategory* laf = getCategory();
  2449. LLInventoryModel::cat_array_t* cat_array;
  2450. LLInventoryModel::item_array_t* item_array;
  2451. modelp->getDirectDescendentsOf(mUUID, cat_array, item_array);
  2452. // Enable "Empty Lost And Found" menu item only when there is something
  2453. // to act upon. Also do not enable menu if folder is not fully fetched.
  2454. if ((item_array->size() == 0 && cat_array->size() == 0) || !laf ||
  2455. laf->isVersionUnknown() || !modelp->isCategoryComplete(mUUID))
  2456. {
  2457. mDisabledItems.emplace_back("Empty Lost And Found");
  2458. }
  2459. }
  2460. else if (mUUID == modelp->getTrashID())
  2461. {
  2462. // This is the trash.
  2463. mItems.emplace_back("Empty Trash");
  2464. LLViewerInventoryCategory* trash = getCategory();
  2465. LLInventoryModel::cat_array_t* cat_array;
  2466. LLInventoryModel::item_array_t* item_array;
  2467. modelp->getDirectDescendentsOf(mUUID, cat_array, item_array);
  2468. // Enable "Empty Trash" menu item only when there is something to act
  2469. // upon. Also do not enable menu if folder is not fully fetched.
  2470. if ((item_array->size() == 0 && cat_array->size() == 0) || !trash ||
  2471. trash->isVersionUnknown() || !modelp->isCategoryComplete(mUUID))
  2472. {
  2473. mDisabledItems.emplace_back("Empty Trash");
  2474. }
  2475. }
  2476. else if (modelp->isInTrash(mUUID))
  2477. {
  2478. // This is a folder in the trash.
  2479. mItems.clear(); // clear any items that used to exist
  2480. const LLInventoryObject* obj = getInventoryObject();
  2481. if (obj && obj->getIsLinkType())
  2482. {
  2483. mItems.emplace_back("Find Original");
  2484. if (isLinkedObjectMissing())
  2485. {
  2486. mDisabledItems.emplace_back("Find Original");
  2487. }
  2488. }
  2489. mItems.emplace_back("Purge Item");
  2490. if (!isItemRemovable())
  2491. {
  2492. mDisabledItems.emplace_back("Purge Item");
  2493. }
  2494. mItems.emplace_back("Restore Item");
  2495. }
  2496. else if (isInMarketplace())
  2497. {
  2498. // Allow to use the clipboard actions
  2499. getClipboardEntries(false, mItems, mDisabledItems, flags);
  2500. if (isInMarketplace())
  2501. {
  2502. LLMarketplace::inventoryContextMenu(this, mUUID, flags, mItems,
  2503. mDisabledItems);
  2504. }
  2505. }
  2506. else
  2507. {
  2508. bool agent_inventory = isAgentInventory();
  2509. const LLUUID& cof_id = gAppearanceMgr.getCOF();
  2510. // Do not allow creating in library neither in COF
  2511. if (mUUID != cof_id)
  2512. {
  2513. if (agent_inventory)
  2514. {
  2515. mItems.emplace_back("New Folder");
  2516. mItems.emplace_back("New Script");
  2517. mItems.emplace_back("New Note");
  2518. mItems.emplace_back("New Gesture");
  2519. mItems.emplace_back("New Material");
  2520. if (!gAgent.hasInventoryMaterial())
  2521. {
  2522. mDisabledItems.emplace_back("New Material");
  2523. }
  2524. mItems.emplace_back("New Clothes");
  2525. mItems.emplace_back("New Body Parts");
  2526. if (mUUID ==
  2527. modelp->findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD))
  2528. {
  2529. mItems.emplace_back("New Calling Card");
  2530. }
  2531. mItems.emplace_back("New Settings");
  2532. if (!gAgent.hasInventorySettings())
  2533. {
  2534. mDisabledItems.emplace_back("New Settings");
  2535. }
  2536. mItems.emplace_back("Upload Prefs Separator");
  2537. mItems.emplace_back("Upload Prefs");
  2538. }
  2539. getClipboardEntries(false, mItems, mDisabledItems, flags);
  2540. }
  2541. else if (cof_id == mUUID && LLFolderType::getCanDeleteCOF())
  2542. {
  2543. // Allow to delete the COF when not in use
  2544. mItems.emplace_back("Delete");
  2545. }
  2546. if (!mCallingCards)
  2547. {
  2548. LLIsType is_callingcard(LLAssetType::AT_CALLINGCARD);
  2549. mCallingCards = checkFolderForContentsOfType(modelp,
  2550. is_callingcard);
  2551. }
  2552. if (mCallingCards)
  2553. {
  2554. mItems.emplace_back("Calling Card Separator");
  2555. mItems.emplace_back("Conference Chat Folder");
  2556. }
  2557. if (!mWearables)
  2558. {
  2559. LLFindWearables is_wearable;
  2560. LLIsType is_object(LLAssetType::AT_OBJECT);
  2561. LLIsType is_gesture(LLAssetType::AT_GESTURE);
  2562. mWearables = checkFolderForContentsOfType(modelp, is_wearable) ||
  2563. checkFolderForContentsOfType(modelp, is_object) ||
  2564. checkFolderForContentsOfType(modelp, is_gesture);
  2565. }
  2566. if (cof_id != mUUID && mWearables)
  2567. {
  2568. mItems.emplace_back("Folder Wearables Separator");
  2569. mItems.emplace_back("Add To Outfit");
  2570. mItems.emplace_back("Wear Items");
  2571. mItems.emplace_back("Replace Outfit");
  2572. if (agent_inventory)
  2573. {
  2574. mItems.emplace_back("Take Off Items");
  2575. mItems.emplace_back("Update Links");
  2576. }
  2577. //MK
  2578. if (gRLenabled)
  2579. {
  2580. if (gRLInterface.mContainsDetach &&
  2581. (!gSavedSettings.getBool("RestrainedLoveAllowWear") ||
  2582. gRLInterface.mContainsDefaultwear))
  2583. {
  2584. mDisabledItems.emplace_back("Add To Outfit");
  2585. mDisabledItems.emplace_back("Wear Items");
  2586. mDisabledItems.emplace_back("Replace Outfit");
  2587. if (agent_inventory)
  2588. {
  2589. mDisabledItems.emplace_back("Take Off Items");
  2590. }
  2591. }
  2592. else
  2593. {
  2594. LLViewerInventoryCategory* vcatp =
  2595. modelp->getCategory(mUUID);
  2596. if (vcatp && !gRLInterface.canAttachCategory(vcatp))
  2597. {
  2598. mDisabledItems.emplace_back("Add To Outfit");
  2599. mDisabledItems.emplace_back("Wear Items");
  2600. mDisabledItems.emplace_back("Replace Outfit");
  2601. }
  2602. if (vcatp && agent_inventory &&
  2603. !gRLInterface.canDetachCategory(vcatp))
  2604. {
  2605. mDisabledItems.emplace_back("Take Off Items");
  2606. }
  2607. }
  2608. }
  2609. //mk
  2610. }
  2611. }
  2612. set_menu_entries_state(*mMenu, mItems, mDisabledItems);
  2613. }
  2614. bool LLFolderBridge::checkFolderForContentsOfType(LLInventoryModel* modelp,
  2615. LLInventoryCollectFunctor& is_type)
  2616. {
  2617. LLInventoryModel::cat_array_t cat_array;
  2618. LLInventoryModel::item_array_t item_array;
  2619. modelp->collectDescendentsIf(mUUID, cat_array, item_array,
  2620. LLInventoryModel::EXCLUDE_TRASH, is_type);
  2621. return item_array.size() > 0;
  2622. }
  2623. //virtual
  2624. void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  2625. {
  2626. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2627. if (!modelp) return;
  2628. LLViewerInventoryCategory* vcatp = modelp->getCategory(mUUID);
  2629. if (!vcatp) return;
  2630. mItems.clear();
  2631. mDisabledItems.clear();
  2632. mCallingCards = mWearables = false;
  2633. mMenu = &menu;
  2634. folderOptionsMenu(flags);
  2635. sSelf = this;
  2636. LLRightClickInventoryFetchDescendentsObserver* observerp =
  2637. new LLRightClickInventoryFetchDescendentsObserver(false);
  2638. uuid_vec_t folders;
  2639. folders.emplace_back(vcatp->getUUID());
  2640. observerp->fetchDescendents(folders);
  2641. if (observerp->isFinished())
  2642. {
  2643. // Everything is already here.
  2644. observerp->done();
  2645. }
  2646. else
  2647. {
  2648. // It is all on its way: add an observer, and the inventory will call
  2649. // done for us when everything is here.
  2650. modelp->addObserver(observerp);
  2651. }
  2652. }
  2653. //virtual
  2654. bool LLFolderBridge::hasChildren() const
  2655. {
  2656. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2657. return modelp &&
  2658. modelp->categoryHasChildren(mUUID) != LLInventoryModel::CHILDREN_NO;
  2659. }
  2660. //virtual
  2661. bool LLFolderBridge::dragOrDrop(MASK mask, bool drop,
  2662. EDragAndDropType cargo_type,
  2663. void* cargo_data,
  2664. std::string& tooltip_msg)
  2665. {
  2666. if ((cargo_type == DAD_SETTINGS && !gAgent.hasInventorySettings()) ||
  2667. (cargo_type == DAD_MATERIAL && !gAgent.hasInventoryMaterial()))
  2668. {
  2669. return false;
  2670. }
  2671. bool accept = false;
  2672. switch (cargo_type)
  2673. {
  2674. case DAD_TEXTURE:
  2675. case DAD_SOUND:
  2676. case DAD_CALLINGCARD:
  2677. case DAD_LANDMARK:
  2678. case DAD_SCRIPT:
  2679. case DAD_OBJECT:
  2680. case DAD_NOTECARD:
  2681. case DAD_CLOTHING:
  2682. case DAD_BODYPART:
  2683. case DAD_ANIMATION:
  2684. case DAD_GESTURE:
  2685. #if LL_MESH_ASSET_SUPPORT
  2686. case DAD_MESH:
  2687. case DAD_GLTF:
  2688. case DAD_GLTF_BIN:
  2689. #endif
  2690. case DAD_SETTINGS:
  2691. case DAD_MATERIAL:
  2692. case DAD_LINK:
  2693. accept = dragItemIntoFolder((LLInventoryItem*)cargo_data, drop,
  2694. tooltip_msg);
  2695. break;
  2696. case DAD_CATEGORY:
  2697. accept = dragCategoryIntoFolder((LLInventoryCategory*)cargo_data,
  2698. drop, tooltip_msg);
  2699. break;
  2700. default:
  2701. break;
  2702. }
  2703. return accept;
  2704. }
  2705. LLViewerInventoryCategory* LLFolderBridge::getCategory() const
  2706. {
  2707. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2708. return modelp ? modelp->getCategory(mUUID) : NULL;
  2709. }
  2710. // Separate method so can be called by global menu as well as right-click menu
  2711. void LLFolderBridge::modifyOutfit(bool append, bool replace)
  2712. {
  2713. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2714. if (!modelp) return;
  2715. LLViewerInventoryCategory* vcatp = getCategory();
  2716. if (!vcatp) return;
  2717. //MK
  2718. if (gRLenabled && !gRLInterface.canAttachCategory(vcatp))
  2719. {
  2720. return;
  2721. }
  2722. //mk
  2723. if (isAgentInventory())
  2724. {
  2725. gAppearanceMgr.wearInventoryCategoryOnAvatar(vcatp, append, replace);
  2726. return;
  2727. }
  2728. // If in library, copy then add to/replace outfit
  2729. if (!append &&
  2730. //MK
  2731. (!gRLenabled || gRLInterface.canDetachCategory(vcatp)))
  2732. //mk
  2733. {
  2734. LLAgentWearables::userRemoveAllAttachments();
  2735. LLAgentWearables::userRemoveAllClothes();
  2736. }
  2737. LLPointer<LLInventoryCategory> catp =
  2738. new LLInventoryCategory(mUUID, LLUUID::null, LLFolderType::FT_CLOTHING,
  2739. "Quick appearance");
  2740. gAppearanceMgr.wearInventoryCategory(catp, true, !replace);
  2741. }
  2742. bool LLFolderBridge::dragItemIntoFolder(LLInventoryItem* itemp, bool drop,
  2743. std::string& tooltip_msg)
  2744. {
  2745. LLInventoryModel* modelp = mInventoryPanel->getModel();
  2746. if (!itemp || !modelp || !isAgentInventory() || !isAgentAvatarValid() ||
  2747. isInCOF())
  2748. {
  2749. return false;
  2750. }
  2751. const LLUUID& market_id = LLMarketplace::getMPL();
  2752. const LLUUID& from_folder_uuid = itemp->getParentUUID();
  2753. bool move_is_into_market = modelp->isObjectDescendentOf(mUUID, market_id);
  2754. bool move_is_from_market = modelp->isObjectDescendentOf(itemp->getUUID(),
  2755. market_id);
  2756. bool move_is_into_trash = isInTrash();
  2757. bool accept = false;
  2758. LLViewerObject* object = NULL;
  2759. LLToolDragAndDrop::ESource source = gToolDragAndDrop.getSource();
  2760. if (source == LLToolDragAndDrop::SOURCE_AGENT)
  2761. {
  2762. bool movable = true;
  2763. if (itemp->getActualType() == LLAssetType::AT_CATEGORY)
  2764. {
  2765. movable = !((LLViewerInventoryCategory*)itemp)->isProtected();
  2766. }
  2767. if (movable && move_is_into_trash)
  2768. {
  2769. movable = itemp->getIsLinkType() ||
  2770. !get_is_item_worn(itemp->getUUID(), false);
  2771. }
  2772. if (move_is_into_market && !move_is_from_market)
  2773. {
  2774. const LLViewerInventoryCategory* master_catp =
  2775. modelp->getFirstDescendantOf(market_id, mUUID);
  2776. S32 count = gToolDragAndDrop.getCargoCount() -
  2777. gToolDragAndDrop.getCargoIndex();
  2778. LLViewerInventoryCategory* dest_catp = getCategory();
  2779. accept = LLMarketplace::canMoveItemInto(master_catp, dest_catp,
  2780. (LLViewerInventoryItem*)itemp,
  2781. tooltip_msg, count);
  2782. }
  2783. else
  2784. {
  2785. accept = movable && mUUID != from_folder_uuid;
  2786. }
  2787. // Check that the folder can accept this item based on folder/item type
  2788. // compatibility (e.g. stock folder compatibility)
  2789. if (accept)
  2790. {
  2791. LLViewerInventoryCategory* dest_catp = getCategory();
  2792. accept = dest_catp->acceptItem(itemp);
  2793. }
  2794. if (accept && !drop && (move_is_into_market || move_is_from_market))
  2795. {
  2796. LLMarketplaceData* marketdata = LLMarketplaceData::getInstance();
  2797. if ((move_is_from_market &&
  2798. (marketdata->isInActiveFolder(itemp->getUUID()) ||
  2799. marketdata->isListedAndActive(itemp->getUUID()))) ||
  2800. (move_is_into_market && marketdata->isInActiveFolder(mUUID)))
  2801. {
  2802. if (!tooltip_msg.empty())
  2803. {
  2804. tooltip_msg += ' ';
  2805. }
  2806. tooltip_msg += LLTrans::getString("TipMerchantActiveChange");
  2807. }
  2808. if (move_is_into_market && !move_is_from_market)
  2809. {
  2810. if (!tooltip_msg.empty())
  2811. {
  2812. tooltip_msg += ' ';
  2813. }
  2814. tooltip_msg += LLTrans::getString("TipMerchantMoveInventory");
  2815. }
  2816. }
  2817. if (accept && drop)
  2818. {
  2819. if (move_is_into_trash &&
  2820. itemp->getType() == LLAssetType::AT_GESTURE &&
  2821. gGestureManager.isGestureActive(itemp->getUUID()))
  2822. {
  2823. gGestureManager.deactivateGesture(itemp->getUUID());
  2824. }
  2825. // If an item is being dragged between windows, unselect everything
  2826. // in the active window so that we don't follow the selection to
  2827. // its new location (which is very annoying).
  2828. if (LLFloaterInventory::getActiveFloater())
  2829. {
  2830. LLInventoryPanel* active_floater =
  2831. LLFloaterInventory::getActiveFloater()->getPanel();
  2832. if (active_floater && mInventoryPanel != active_floater)
  2833. {
  2834. active_floater->unSelectAll();
  2835. }
  2836. }
  2837. if (move_is_into_market)
  2838. {
  2839. LLMarketplace::moveItemInto((LLViewerInventoryItem*)itemp,
  2840. mUUID);
  2841. }
  2842. else
  2843. {
  2844. changeItemParent(modelp, (LLViewerInventoryItem*)itemp,
  2845. mUUID, move_is_into_trash);
  2846. }
  2847. #if 0
  2848. if (move_is_from_market)
  2849. {
  2850. LLMarketplace::updateMovedFrom(from_folder_uuid);
  2851. }
  2852. #endif
  2853. }
  2854. }
  2855. else if (source == LLToolDragAndDrop::SOURCE_WORLD)
  2856. {
  2857. // Make sure the object exists. If we allowed dragging from anonymous
  2858. // objects, it would be possible to bypass permissions.
  2859. object = gObjectList.findObject(itemp->getParentUUID());
  2860. if (!object)
  2861. {
  2862. llinfos << "Object not found for drop." << llendl;
  2863. return false;
  2864. }
  2865. // Coming from a task. Need to figure out if the person can move/copy
  2866. // this item.
  2867. LLPermissions perm(itemp->getPermissions());
  2868. bool is_move = false;
  2869. if (perm.allowCopyBy(gAgentID, gAgent.getGroupID()) &&
  2870. perm.allowTransferTo(gAgentID)) // || gAgent.isGodlike())
  2871. {
  2872. accept = true;
  2873. }
  2874. else if (object->permYouOwner())
  2875. {
  2876. // If the object cannot be copied, but the object the inventory is
  2877. // owned by the agent, then the item can be moved from the task to
  2878. // agent inventory.
  2879. is_move = accept = true;
  2880. }
  2881. if (move_is_into_market)
  2882. {
  2883. accept = false;
  2884. }
  2885. if (drop && accept)
  2886. {
  2887. LLMoveInv* move_inv = new LLMoveInv;
  2888. move_inv->mObjectID = itemp->getParentUUID();
  2889. move_inv->mMoveList.emplace_back(mUUID, itemp->getUUID());
  2890. move_inv->mCallback = NULL;
  2891. move_inv->mUserData = NULL;
  2892. if (is_move)
  2893. {
  2894. warn_move_inventory(object, move_inv);
  2895. }
  2896. else
  2897. {
  2898. LLNotification::Params params("MoveInventoryFromObject");
  2899. params.functor(boost::bind(move_task_inventory_callback,
  2900. _1, _2, move_inv));
  2901. gNotifications.forceResponse(params, 0);
  2902. }
  2903. }
  2904. }
  2905. else if (source == LLToolDragAndDrop::SOURCE_NOTECARD)
  2906. {
  2907. accept = !move_is_into_market;
  2908. if (accept && itemp->getActualType() == LLAssetType::AT_SETTINGS)
  2909. {
  2910. accept = gAgent.hasInventorySettings();
  2911. }
  2912. if (accept && drop)
  2913. {
  2914. copy_inventory_from_notecard(gToolDragAndDrop.getObjectID(),
  2915. gToolDragAndDrop.getSourceID(),
  2916. itemp);
  2917. }
  2918. }
  2919. else if (source == LLToolDragAndDrop::SOURCE_LIBRARY)
  2920. {
  2921. LLViewerInventoryItem* vitemp = (LLViewerInventoryItem*)itemp;
  2922. if (vitemp && vitemp->isFinished())
  2923. {
  2924. accept = !move_is_into_market;
  2925. if (accept && drop)
  2926. {
  2927. copy_inventory_item(itemp->getPermissions().getOwner(),
  2928. itemp->getUUID(), mUUID);
  2929. }
  2930. }
  2931. }
  2932. else
  2933. {
  2934. llwarns << "Unhandled drag source" << llendl;
  2935. }
  2936. if (accept && drop && move_is_into_trash)
  2937. {
  2938. modelp->checkTrashOverflow();
  2939. }
  2940. return accept;
  2941. }
  2942. ///////////////////////////////////////////////////////////////////////////////
  2943. // LLScriptBridge (DEPRECATED)
  2944. ///////////////////////////////////////////////////////////////////////////////
  2945. //virtual
  2946. LLUIImagePtr LLScriptBridge::getIcon() const
  2947. {
  2948. return LLInventoryIcon::getIcon(LLAssetType::AT_SCRIPT,
  2949. LLInventoryType::IT_LSL, 0, false);
  2950. }
  2951. ///////////////////////////////////////////////////////////////////////////////
  2952. // LLTextureBridge
  2953. ///////////////////////////////////////////////////////////////////////////////
  2954. //virtual
  2955. const std::string& LLTextureBridge::getPrefix()
  2956. {
  2957. static const std::string prefix = LLTrans::getString("Texture") + ": ";
  2958. return prefix;
  2959. }
  2960. //virtual
  2961. LLUIImagePtr LLTextureBridge::getIcon() const
  2962. {
  2963. return LLInventoryIcon::getIcon(LLAssetType::AT_TEXTURE, mInvType, 0,
  2964. false);
  2965. }
  2966. //virtual
  2967. void LLTextureBridge::openItem()
  2968. {
  2969. open_texture(mUUID, getPrefix() + getName());
  2970. }
  2971. ///////////////////////////////////////////////////////////////////////////////
  2972. // LLSoundBridge
  2973. ///////////////////////////////////////////////////////////////////////////////
  2974. //virtual
  2975. const std::string& LLSoundBridge::getPrefix()
  2976. {
  2977. static const std::string prefix = LLTrans::getString("Sound") + ": ";
  2978. return prefix;
  2979. }
  2980. //virtual
  2981. LLUIImagePtr LLSoundBridge::getIcon() const
  2982. {
  2983. return LLInventoryIcon::getIcon(LLAssetType::AT_SOUND,
  2984. LLInventoryType::IT_SOUND, 0, false);
  2985. }
  2986. //virtual
  2987. void LLSoundBridge::openItem()
  2988. {
  2989. open_sound(mUUID, getPrefix() + getName());
  2990. }
  2991. //virtual
  2992. void LLSoundBridge::previewItem()
  2993. {
  2994. LLViewerInventoryItem* item = getItem();
  2995. if (!item) return;
  2996. U32 action = gSavedSettings.getU32("DoubleClickInventorySoundAction");
  2997. if (action == 0)
  2998. {
  2999. open_sound(mUUID, getPrefix() + getName());
  3000. }
  3001. else if (action == 1 && gAudiop)
  3002. {
  3003. // Play the sound locally.
  3004. LLVector3d lpos_global = gAgent.getPositionGlobal();
  3005. gAudiop->triggerSound(item->getAssetUUID(), gAgentID, 1.0,
  3006. LLAudioEngine::AUDIO_TYPE_UI, lpos_global);
  3007. }
  3008. else if (action == 2)
  3009. {
  3010. // Play the sound in-world.
  3011. send_sound_trigger(item->getAssetUUID(), 1.0);
  3012. }
  3013. }
  3014. //virtual
  3015. void LLSoundBridge::performAction(LLFolderView* folderp,
  3016. LLInventoryModel* modelp,
  3017. const std::string& action)
  3018. {
  3019. if (action == "playworld")
  3020. {
  3021. LLViewerInventoryItem* vitemp = getItem();
  3022. if (vitemp)
  3023. {
  3024. send_sound_trigger(vitemp->getAssetUUID(), 1.0);
  3025. }
  3026. }
  3027. else if (action == "playlocal")
  3028. {
  3029. LLViewerInventoryItem* vitemp = getItem();
  3030. if (vitemp && gAudiop)
  3031. {
  3032. // Play the sound locally.
  3033. LLVector3d lpos_global = gAgent.getPositionGlobal();
  3034. gAudiop->triggerSound(vitemp->getAssetUUID(), gAgentID, 1.0,
  3035. LLAudioEngine::AUDIO_TYPE_UI, lpos_global);
  3036. }
  3037. }
  3038. else
  3039. {
  3040. LLItemBridge::performAction(folderp, modelp, action);
  3041. }
  3042. }
  3043. //virtual
  3044. void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  3045. {
  3046. std::vector<std::string> items;
  3047. std::vector<std::string> disabled_items;
  3048. if (isInTrash())
  3049. {
  3050. items.emplace_back("Purge Item");
  3051. items.emplace_back("Restore Item");
  3052. }
  3053. else
  3054. {
  3055. items.emplace_back("Sound Open");
  3056. items.emplace_back("Sound Play1");
  3057. items.emplace_back("Sound Play2");
  3058. items.emplace_back("Sound Separator");
  3059. items.emplace_back("Properties");
  3060. getClipboardEntries(true, items, disabled_items, flags);
  3061. }
  3062. set_menu_entries_state(menu, items, disabled_items);
  3063. }
  3064. ///////////////////////////////////////////////////////////////////////////////
  3065. // LLLandmarkBridge
  3066. ///////////////////////////////////////////////////////////////////////////////
  3067. //virtual
  3068. const std::string& LLLandmarkBridge::getPrefix()
  3069. {
  3070. static const std::string prefix = LLTrans::getString("Landmark") + ": ";
  3071. return prefix;
  3072. }
  3073. //virtual
  3074. LLUIImagePtr LLLandmarkBridge::getIcon() const
  3075. {
  3076. return LLInventoryIcon::getIcon(LLAssetType::AT_LANDMARK,
  3077. LLInventoryType::IT_LANDMARK, mVisited,
  3078. false);
  3079. }
  3080. //virtual
  3081. void LLLandmarkBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  3082. {
  3083. std::vector<std::string> items;
  3084. std::vector<std::string> disabled_items;
  3085. if (isInTrash())
  3086. {
  3087. items.emplace_back("Purge Item");
  3088. items.emplace_back("Restore Item");
  3089. }
  3090. else
  3091. {
  3092. items.emplace_back("Landmark Open");
  3093. items.emplace_back("Properties");
  3094. getClipboardEntries(true, items, disabled_items, flags);
  3095. }
  3096. items.emplace_back("Landmark Separator");
  3097. items.emplace_back("About Landmark");
  3098. items.emplace_back("Show on Map");
  3099. set_menu_entries_state(menu, items, disabled_items);
  3100. }
  3101. //virtual
  3102. void LLLandmarkBridge::performAction(LLFolderView* folderp,
  3103. LLInventoryModel* modelp,
  3104. const std::string& action)
  3105. {
  3106. if (action == "teleport")
  3107. {
  3108. LLViewerInventoryItem* vitemp = getItem();
  3109. if (vitemp)
  3110. {
  3111. gAgent.teleportViaLandmark(vitemp->getAssetUUID());
  3112. // We now automatically track the landmark you are teleporting to
  3113. // because you will probably arrive at a telehub instead.
  3114. if (gFloaterWorldMapp)
  3115. {
  3116. // remember this must be the item UUID, not the asset UUID
  3117. gFloaterWorldMapp->trackLandmark(vitemp->getUUID());
  3118. }
  3119. }
  3120. }
  3121. else if (action == "about")
  3122. {
  3123. LLViewerInventoryItem* vitemp = getItem();
  3124. if (vitemp)
  3125. {
  3126. std::string title = " " + getPrefix() + vitemp->getName();
  3127. open_landmark(vitemp, title);
  3128. }
  3129. }
  3130. else if (action == "show_on_map")
  3131. {
  3132. LLViewerInventoryItem* vitemp = getItem();
  3133. if (vitemp)
  3134. {
  3135. const LLUUID& asset_id = vitemp->getAssetUUID();
  3136. if (asset_id.isNull()) return; // Paranoia
  3137. LLLandmark* landmarkp =
  3138. gLandmarkList.getAsset(asset_id,
  3139. boost::bind(&LLLandmarkBridge::showOnMap,
  3140. this, _1));
  3141. if (landmarkp)
  3142. {
  3143. showOnMap(landmarkp);
  3144. }
  3145. }
  3146. }
  3147. else
  3148. {
  3149. LLItemBridge::performAction(folderp, modelp, action);
  3150. }
  3151. }
  3152. //virtual
  3153. void LLLandmarkBridge::openItem()
  3154. {
  3155. LLViewerInventoryItem* vitemp = getItem();
  3156. if (vitemp)
  3157. {
  3158. // Double-clicking a landmark immediately teleports, but warns you the
  3159. // first time.
  3160. LLSD payload;
  3161. payload["asset_id"] = vitemp->getAssetUUID();
  3162. payload["item_id"] = vitemp->getUUID();
  3163. gNotifications.add("TeleportFromLandmark", LLSD(), payload);
  3164. }
  3165. }
  3166. void LLLandmarkBridge::showOnMap(LLLandmark* landmarkp)
  3167. {
  3168. if (!landmarkp || !gFloaterWorldMapp)
  3169. {
  3170. return;
  3171. }
  3172. LLVector3d pos;
  3173. if (landmarkp->getGlobalPos(pos))
  3174. {
  3175. if (!pos.isExactlyZero())
  3176. {
  3177. gFloaterWorldMapp->trackLocation(pos);
  3178. LLFloaterWorldMap::show(NULL, true);
  3179. }
  3180. }
  3181. }
  3182. ///////////////////////////////////////////////////////////////////////////////
  3183. // LLCallingCardBridge
  3184. ///////////////////////////////////////////////////////////////////////////////
  3185. //virtual
  3186. void LLCallingCardObserver::changed(U32 mask)
  3187. {
  3188. mBridgep->refreshFolderViewItem();
  3189. }
  3190. //virtual
  3191. const std::string& LLCallingCardBridge::getPrefix()
  3192. {
  3193. static const std::string prefix = LLTrans::getString("Calling card") +
  3194. ": ";
  3195. return prefix;
  3196. }
  3197. LLCallingCardBridge::LLCallingCardBridge(LLInventoryPanel* inventory,
  3198. const LLUUID& uuid)
  3199. : LLItemBridge(inventory, uuid)
  3200. {
  3201. mObserver = new LLCallingCardObserver(this);
  3202. gAvatarTracker.addObserver(mObserver);
  3203. }
  3204. //virtual
  3205. LLCallingCardBridge::~LLCallingCardBridge()
  3206. {
  3207. gAvatarTracker.removeObserver(mObserver);
  3208. delete mObserver;
  3209. }
  3210. void LLCallingCardBridge::refreshFolderViewItem()
  3211. {
  3212. LLFolderViewItem* itemp =
  3213. mInventoryPanel->getRootFolder()->getItemByID(mUUID);
  3214. if (itemp)
  3215. {
  3216. itemp->refresh();
  3217. }
  3218. }
  3219. //virtual
  3220. void LLCallingCardBridge::performAction(LLFolderView* folderp,
  3221. LLInventoryModel* modelp,
  3222. const std::string& action)
  3223. {
  3224. if (action == "begin_im")
  3225. {
  3226. LLViewerInventoryItem* vitemp = getItem();
  3227. const LLUUID& id = vitemp ? vitemp->getCreatorUUID() : LLUUID::null;
  3228. if (id.notNull() && id != gAgentID)
  3229. {
  3230. LLAvatarActions::startIM(id);
  3231. }
  3232. }
  3233. else if (action == "lure")
  3234. {
  3235. LLViewerInventoryItem* vitemp = getItem();
  3236. const LLUUID& id = vitemp ? vitemp->getCreatorUUID() : LLUUID::null;
  3237. if (id.notNull() && id != gAgentID)
  3238. {
  3239. LLAvatarActions::offerTeleport(id);
  3240. }
  3241. }
  3242. else if (action == "request_teleport")
  3243. {
  3244. LLViewerInventoryItem* vitemp = getItem();
  3245. const LLUUID& id = vitemp ? vitemp->getCreatorUUID() : LLUUID::null;
  3246. if (id.notNull() && id != gAgentID)
  3247. {
  3248. LLAvatarActions::teleportRequest(id);
  3249. }
  3250. }
  3251. else
  3252. {
  3253. LLItemBridge::performAction(folderp, modelp, action);
  3254. }
  3255. }
  3256. //virtual
  3257. LLUIImagePtr LLCallingCardBridge::getIcon() const
  3258. {
  3259. bool online = false;
  3260. LLViewerInventoryItem* vitemp = getItem();
  3261. LLUUID id = get_calling_card_buddy_id(vitemp);
  3262. if (id.notNull())
  3263. {
  3264. online = gAvatarTracker.isBuddyOnline(id);
  3265. }
  3266. return LLInventoryIcon::getIcon(LLAssetType::AT_CALLINGCARD,
  3267. LLInventoryType::IT_CALLINGCARD,
  3268. online, false);
  3269. }
  3270. //virtual
  3271. std::string LLCallingCardBridge::getLabelSuffix() const
  3272. {
  3273. static const std::string online = " (" + LLTrans::getString("online") +
  3274. ")";
  3275. LLViewerInventoryItem* vitemp = getItem();
  3276. LLUUID id = get_calling_card_buddy_id(vitemp);
  3277. if (id.notNull() && gAvatarTracker.isBuddyOnline(id))
  3278. {
  3279. return LLItemBridge::getLabelSuffix() + online;
  3280. }
  3281. return LLItemBridge::getLabelSuffix();
  3282. }
  3283. //virtual
  3284. void LLCallingCardBridge::openItem()
  3285. {
  3286. open_callingcard((LLViewerInventoryItem*)getItem());
  3287. }
  3288. //virtual
  3289. void LLCallingCardBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  3290. {
  3291. std::vector<std::string> items;
  3292. std::vector<std::string> disabled_items;
  3293. if (isInTrash())
  3294. {
  3295. items.emplace_back("Purge Item");
  3296. items.emplace_back("Restore Item");
  3297. }
  3298. else
  3299. {
  3300. items.emplace_back("Open");
  3301. items.emplace_back("Properties");
  3302. getClipboardEntries(true, items, disabled_items, flags);
  3303. LLViewerInventoryItem* vitemp = getItem();
  3304. LLUUID buddy_id = get_calling_card_buddy_id(vitemp);
  3305. bool good_card = buddy_id.notNull();
  3306. bool user_online = false;
  3307. if (vitemp)
  3308. {
  3309. user_online = gAvatarTracker.isBuddyOnline(buddy_id);
  3310. }
  3311. items.emplace_back("Send Instant Message Separator");
  3312. items.emplace_back("Send Instant Message");
  3313. items.emplace_back("Offer Teleport...");
  3314. items.emplace_back("Request Teleport...");
  3315. items.emplace_back("Conference Chat");
  3316. if (!good_card)
  3317. {
  3318. disabled_items.emplace_back("Send Instant Message");
  3319. }
  3320. if (!good_card || !user_online)
  3321. {
  3322. disabled_items.emplace_back("Offer Teleport...");
  3323. disabled_items.emplace_back("Request Teleport...");
  3324. disabled_items.emplace_back("Conference Chat");
  3325. }
  3326. }
  3327. set_menu_entries_state(menu, items, disabled_items);
  3328. }
  3329. //virtual
  3330. bool LLCallingCardBridge::dragOrDrop(MASK mask, bool drop,
  3331. EDragAndDropType cargo_type,
  3332. void* cargo_data,
  3333. std::string& tooltip_msg)
  3334. {
  3335. LLViewerInventoryItem* vitemp = getItem();
  3336. if (vitemp && cargo_data)
  3337. {
  3338. if ((cargo_type == DAD_SETTINGS && !gAgent.hasInventorySettings()) ||
  3339. (cargo_type == DAD_MATERIAL && !gAgent.hasInventoryMaterial()))
  3340. {
  3341. return false;
  3342. }
  3343. // Check the type
  3344. switch (cargo_type)
  3345. {
  3346. case DAD_TEXTURE:
  3347. case DAD_SOUND:
  3348. case DAD_LANDMARK:
  3349. case DAD_SCRIPT:
  3350. case DAD_CLOTHING:
  3351. case DAD_OBJECT:
  3352. case DAD_NOTECARD:
  3353. case DAD_BODYPART:
  3354. case DAD_ANIMATION:
  3355. case DAD_GESTURE:
  3356. #if LL_MESH_ASSET_SUPPORT
  3357. case DAD_MESH:
  3358. case DAD_GLTF:
  3359. case DAD_GLTF_BIN:
  3360. #endif
  3361. case DAD_SETTINGS:
  3362. case DAD_MATERIAL:
  3363. {
  3364. LLInventoryItem* itemp = (LLInventoryItem*)cargo_data;
  3365. const LLPermissions& perm = itemp->getPermissions();
  3366. if (gInventory.getItem(itemp->getUUID()) &&
  3367. perm.allowTransferBy(gAgentID))
  3368. {
  3369. if (drop)
  3370. {
  3371. LLToolDragAndDrop::giveInventory(vitemp->getCreatorUUID(),
  3372. itemp);
  3373. }
  3374. return true;
  3375. }
  3376. else
  3377. {
  3378. // It is not in the user's inventory (it is probably in an
  3379. // object's contents), so disallow dragging it here. You
  3380. // cannot give something you do not yet have.
  3381. return false;
  3382. }
  3383. break;
  3384. }
  3385. case DAD_CATEGORY:
  3386. {
  3387. LLInventoryCategory* inv_cat = (LLInventoryCategory*)cargo_data;
  3388. if (gInventory.getCategory(inv_cat->getUUID()))
  3389. {
  3390. if (drop)
  3391. {
  3392. LLToolDragAndDrop::giveInventoryCategory(vitemp->getCreatorUUID(),
  3393. inv_cat);
  3394. }
  3395. return true;
  3396. }
  3397. else
  3398. {
  3399. // It is not in the user's inventory (it is probably in an
  3400. // object's contents), so disallow dragging it here. You
  3401. // cannot give something you do not yet have.
  3402. return false;
  3403. }
  3404. break;
  3405. }
  3406. default:
  3407. break;
  3408. }
  3409. }
  3410. return false;
  3411. }
  3412. ///////////////////////////////////////////////////////////////////////////////
  3413. // LLNotecardBridge
  3414. ///////////////////////////////////////////////////////////////////////////////
  3415. //virtual
  3416. const std::string& LLNotecardBridge::getPrefix()
  3417. {
  3418. static const std::string prefix = LLTrans::getString("Note") + ": ";
  3419. return prefix;
  3420. }
  3421. //virtual
  3422. LLUIImagePtr LLNotecardBridge::getIcon() const
  3423. {
  3424. return LLInventoryIcon::getIcon(LLAssetType::AT_NOTECARD,
  3425. LLInventoryType::IT_NOTECARD, 0, false);
  3426. }
  3427. //virtual
  3428. void LLNotecardBridge::openItem()
  3429. {
  3430. LLViewerInventoryItem* vitemp = getItem();
  3431. if (vitemp)
  3432. {
  3433. open_notecard(vitemp, getPrefix() + getName());
  3434. }
  3435. }
  3436. ///////////////////////////////////////////////////////////////////////////////
  3437. // LLGestureBridge
  3438. ///////////////////////////////////////////////////////////////////////////////
  3439. //virtual
  3440. const std::string& LLGestureBridge::getPrefix()
  3441. {
  3442. static const std::string prefix = LLTrans::getString("Gesture") + ": ";
  3443. return prefix;
  3444. }
  3445. //virtual
  3446. LLUIImagePtr LLGestureBridge::getIcon() const
  3447. {
  3448. return LLInventoryIcon::getIcon(LLAssetType::AT_GESTURE,
  3449. LLInventoryType::IT_GESTURE, 0, false);
  3450. }
  3451. //virtual
  3452. LLFontGL::StyleFlags LLGestureBridge::getLabelStyle() const
  3453. {
  3454. S32 font = LLFontGL::NORMAL;
  3455. if (gGestureManager.isGestureActive(mUUID))
  3456. {
  3457. font |= LLFontGL::BOLD;
  3458. }
  3459. const LLViewerInventoryItem* vitemp = getItem();
  3460. if (vitemp && vitemp->getIsLinkType())
  3461. {
  3462. font |= LLFontGL::ITALIC;
  3463. }
  3464. return (LLFontGL::StyleFlags)font;
  3465. }
  3466. //virtual
  3467. std::string LLGestureBridge::getLabelSuffix() const
  3468. {
  3469. static const std::string active = " (" + LLTrans::getString("active") +
  3470. ")";
  3471. if (gGestureManager.isGestureActive(mUUID))
  3472. {
  3473. return LLItemBridge::getLabelSuffix() + active;
  3474. }
  3475. return LLItemBridge::getLabelSuffix();
  3476. }
  3477. //virtual
  3478. void LLGestureBridge::performAction(LLFolderView* folderp,
  3479. LLInventoryModel* modelp,
  3480. const std::string& action)
  3481. {
  3482. if (action == "activate")
  3483. {
  3484. gGestureManager.activateGesture(mUUID);
  3485. LLViewerInventoryItem* vitemp = gInventory.getItem(mUUID);
  3486. if (!vitemp) return;
  3487. // Since we just changed the suffix to indicate (active)
  3488. // the server doesn't need to know, just the viewer.
  3489. gInventory.updateItem(vitemp);
  3490. gInventory.notifyObservers();
  3491. }
  3492. else if (action == "deactivate")
  3493. {
  3494. gGestureManager.deactivateGesture(mUUID);
  3495. LLViewerInventoryItem* vitemp = gInventory.getItem(mUUID);
  3496. if (!vitemp) return;
  3497. // Since we just changed the suffix to indicate (active)
  3498. // the server doesn't need to know, just the viewer.
  3499. gInventory.updateItem(vitemp);
  3500. gInventory.notifyObservers();
  3501. }
  3502. else
  3503. {
  3504. LLItemBridge::performAction(folderp, modelp, action);
  3505. }
  3506. }
  3507. //virtual
  3508. void LLGestureBridge::openItem()
  3509. {
  3510. open_gesture(mUUID, getPrefix() + getName());
  3511. }
  3512. //virtual
  3513. bool LLGestureBridge::removeItem()
  3514. {
  3515. // Force close the preview window, if it exists
  3516. gGestureManager.deactivateGesture(mUUID);
  3517. return LLItemBridge::removeItem();
  3518. }
  3519. //virtual
  3520. void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  3521. {
  3522. std::vector<std::string> items;
  3523. std::vector<std::string> disabled_items;
  3524. if (isInTrash())
  3525. {
  3526. const LLInventoryObject* invobjp = getInventoryObject();
  3527. if (invobjp && invobjp->getIsLinkType())
  3528. {
  3529. items.emplace_back("Find Original");
  3530. if (isLinkedObjectMissing())
  3531. {
  3532. disabled_items.emplace_back("Find Original");
  3533. }
  3534. }
  3535. items.emplace_back("Purge Item");
  3536. if (!isItemRemovable())
  3537. {
  3538. disabled_items.emplace_back("Purge Item");
  3539. }
  3540. items.emplace_back("Restore Item");
  3541. }
  3542. else
  3543. {
  3544. items.emplace_back("Gesture Open");
  3545. items.emplace_back("Properties");
  3546. getClipboardEntries(true, items, disabled_items, flags);
  3547. if (!isInMarketplace())
  3548. {
  3549. items.emplace_back("Gesture Separator");
  3550. items.emplace_back("Activate");
  3551. items.emplace_back("Deactivate");
  3552. }
  3553. }
  3554. set_menu_entries_state(menu, items, disabled_items);
  3555. }
  3556. ///////////////////////////////////////////////////////////////////////////////
  3557. // LLAnimationBridge
  3558. ///////////////////////////////////////////////////////////////////////////////
  3559. //virtual
  3560. const std::string& LLAnimationBridge::getPrefix()
  3561. {
  3562. static const std::string prefix = LLTrans::getString("Animation") + ": ";
  3563. return prefix;
  3564. }
  3565. LLUIImagePtr LLAnimationBridge::getIcon() const
  3566. {
  3567. return LLInventoryIcon::getIcon(LLAssetType::AT_ANIMATION,
  3568. LLInventoryType::IT_ANIMATION, 0, false);
  3569. }
  3570. //virtual
  3571. void LLAnimationBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  3572. {
  3573. std::vector<std::string> items;
  3574. std::vector<std::string> disabled_items;
  3575. if (isInTrash())
  3576. {
  3577. items.emplace_back("Purge Item");
  3578. items.emplace_back("Restore Item");
  3579. }
  3580. else
  3581. {
  3582. items.emplace_back("Animation Open");
  3583. items.emplace_back("Animation Play");
  3584. items.emplace_back("Animation Audition");
  3585. items.emplace_back("Animation Separator");
  3586. items.emplace_back("Properties");
  3587. getClipboardEntries(true, items, disabled_items, flags);
  3588. }
  3589. set_menu_entries_state(menu, items, disabled_items);
  3590. }
  3591. //virtual
  3592. void LLAnimationBridge::performAction(LLFolderView* folderp,
  3593. LLInventoryModel* modelp,
  3594. const std::string& action)
  3595. {
  3596. if (action == "playworld" || action == "playlocal")
  3597. {
  3598. S32 activate = action == "playworld" ? 1 : 2;
  3599. open_animation(mUUID, getPrefix() + getName(), activate, LLUUID::null,
  3600. false);
  3601. }
  3602. else
  3603. {
  3604. LLItemBridge::performAction(folderp, modelp, action);
  3605. }
  3606. }
  3607. //virtual
  3608. void LLAnimationBridge::openItem()
  3609. {
  3610. open_animation(mUUID, getPrefix() + getName());
  3611. }
  3612. ///////////////////////////////////////////////////////////////////////////////
  3613. // LLObjectBridge
  3614. ///////////////////////////////////////////////////////////////////////////////
  3615. //virtual
  3616. const std::string& LLObjectBridge::getPrefix()
  3617. {
  3618. static const std::string prefix = LLTrans::getString("Object") + ": ";
  3619. return prefix;
  3620. }
  3621. //virtual
  3622. bool LLObjectBridge::isItemRemovable()
  3623. {
  3624. LLInventoryModel* modelp = mInventoryPanel->getModel();
  3625. if (!modelp)
  3626. {
  3627. return false;
  3628. }
  3629. const LLInventoryObject* invobjp = modelp->getItem(mUUID);
  3630. if (invobjp && invobjp->getIsLinkType())
  3631. {
  3632. return true;
  3633. }
  3634. if (!isAgentAvatarValid() || gAgentAvatarp->isWearingAttachment(mUUID))
  3635. {
  3636. return false;
  3637. }
  3638. return LLInvFVBridge::isItemRemovable();
  3639. }
  3640. //virtual
  3641. LLUIImagePtr LLObjectBridge::getIcon() const
  3642. {
  3643. return LLInventoryIcon::getIcon(LLAssetType::AT_OBJECT, mInvType,
  3644. mAttachPt, mIsMultiObject);
  3645. }
  3646. //virtual
  3647. void LLObjectBridge::performAction(LLFolderView* folderp,
  3648. LLInventoryModel* modelp,
  3649. const std::string& action)
  3650. {
  3651. if (action == "attach" || action == "attach_add")
  3652. {
  3653. bool replace = action == "attach"; // Replace if "Wear"ing.
  3654. LLUUID object_id = gInventory.getLinkedItemID(mUUID);
  3655. LLViewerInventoryItem* vitemp = gInventory.getItem(object_id);
  3656. if (vitemp &&
  3657. gInventory.isObjectDescendentOf(object_id,
  3658. gInventory.getRootFolderID()))
  3659. {
  3660. //MK
  3661. if (gRLenabled && gRLInterface.canAttach(vitemp))
  3662. {
  3663. LLViewerJointAttachment* attachmentp = NULL;
  3664. // If it is a no-mod item, the containing folder has priority
  3665. // to decide where to wear it
  3666. if (!vitemp->getPermissions().allowModifyBy(gAgentID))
  3667. {
  3668. attachmentp =
  3669. gRLInterface.findAttachmentPointFromParentName(vitemp);
  3670. if (attachmentp)
  3671. {
  3672. gAppearanceMgr.rezAttachment(vitemp, attachmentp,
  3673. replace);
  3674. }
  3675. else
  3676. {
  3677. // But the name itself could also have the information
  3678. // => check
  3679. attachmentp =
  3680. gRLInterface.findAttachmentPointFromName(vitemp->getName());
  3681. if (attachmentp)
  3682. {
  3683. gAppearanceMgr.rezAttachment(vitemp, attachmentp,
  3684. replace);
  3685. }
  3686. else if (!gRLInterface.mContainsDefaultwear &&
  3687. gSavedSettings.getBool("RestrainedLoveAllowWear"))
  3688. {
  3689. gAppearanceMgr.rezAttachment(vitemp, NULL, replace);
  3690. }
  3691. }
  3692. }
  3693. else
  3694. {
  3695. // This is a mod item, wear it according to its name
  3696. attachmentp =
  3697. gRLInterface.findAttachmentPointFromName(vitemp->getName());
  3698. if (attachmentp)
  3699. {
  3700. gAppearanceMgr.rezAttachment(vitemp, attachmentp,
  3701. replace);
  3702. }
  3703. else if (!gRLInterface.mContainsDefaultwear &&
  3704. gSavedSettings.getBool("RestrainedLoveAllowWear"))
  3705. {
  3706. gAppearanceMgr.rezAttachment(vitemp, NULL, replace);
  3707. }
  3708. }
  3709. }
  3710. else
  3711. //mk
  3712. {
  3713. gAppearanceMgr.rezAttachment(vitemp, NULL, replace);
  3714. }
  3715. }
  3716. else if (vitemp && vitemp->isFinished())
  3717. {
  3718. // Must be in the inventory library. Copy it to our inventory and
  3719. // put it on right away.
  3720. LLPointer<LLInventoryCallback> cb =
  3721. new LLRezAttachmentCallback(NULL, replace);
  3722. copy_inventory_item(vitemp->getPermissions().getOwner(),
  3723. vitemp->getUUID(), LLUUID::null,
  3724. LLStringUtil::null, cb);
  3725. }
  3726. else if (vitemp)
  3727. {
  3728. // *TODO: we should fetch the item details, and then do the
  3729. // operation above.
  3730. gNotifications.add("CannotWearInfoNotComplete");
  3731. }
  3732. gFocusMgr.setKeyboardFocus(NULL);
  3733. }
  3734. else if (action == "detach")
  3735. {
  3736. LLViewerInventoryItem* vitemp = gInventory.getItem(mUUID);
  3737. if (vitemp)
  3738. {
  3739. LLVOAvatarSelf::detachAttachmentIntoInventory(vitemp->getLinkedUUID());
  3740. }
  3741. }
  3742. else if (action == "edit" || action == "inspect")
  3743. {
  3744. LLViewerInventoryItem* vitemp = gInventory.getItem(mUUID);
  3745. if (vitemp && isAgentAvatarValid())
  3746. {
  3747. LLViewerObject* vobj =
  3748. gAgentAvatarp->getWornAttachment(vitemp->getLinkedUUID());
  3749. if (vobj)
  3750. {
  3751. gSelectMgr.deselectAll();
  3752. gSelectMgr.selectObjectAndFamily(vobj);
  3753. if (action == "edit")
  3754. {
  3755. handle_object_edit();
  3756. }
  3757. else
  3758. {
  3759. handle_object_inspect();
  3760. }
  3761. }
  3762. }
  3763. }
  3764. else
  3765. {
  3766. LLItemBridge::performAction(folderp, modelp, action);
  3767. }
  3768. }
  3769. //virtual
  3770. void LLObjectBridge::openItem()
  3771. {
  3772. if (isAgentAvatarValid() && !isInMarketplace())
  3773. {
  3774. if (gAgentAvatarp->isWearingAttachment(mUUID))
  3775. {
  3776. //MK
  3777. if (gRLenabled &&
  3778. !gRLInterface.canDetach(gAgentAvatarp->getWornAttachment(mUUID)))
  3779. {
  3780. return;
  3781. }
  3782. //mk
  3783. performAction(NULL, NULL, "detach");
  3784. }
  3785. else
  3786. {
  3787. performAction(NULL, NULL, "attach");
  3788. }
  3789. }
  3790. }
  3791. //virtual
  3792. LLFontGL::StyleFlags LLObjectBridge::getLabelStyle() const
  3793. {
  3794. S32 font = LLFontGL::NORMAL;
  3795. if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(mUUID))
  3796. {
  3797. font |= LLFontGL::BOLD;
  3798. }
  3799. const LLViewerInventoryItem* vitemp = getItem();
  3800. if (vitemp && vitemp->getIsLinkType())
  3801. {
  3802. font |= LLFontGL::ITALIC;
  3803. }
  3804. return (LLFontGL::StyleFlags)font;
  3805. }
  3806. //virtual
  3807. std::string LLObjectBridge::getLabelSuffix() const
  3808. {
  3809. static const std::string wornon = " (" + LLTrans::getString("wornon") +
  3810. " ";
  3811. std::string suffix = LLItemBridge::getLabelSuffix();
  3812. if (isAgentAvatarValid() && gAgentAvatarp->isWearingAttachment(mUUID))
  3813. {
  3814. suffix += wornon;
  3815. suffix += gAgentAvatarp->getAttachedPointName(mUUID, true) + ")";
  3816. }
  3817. return suffix;
  3818. }
  3819. //virtual
  3820. void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  3821. {
  3822. LLInventoryModel* model = mInventoryPanel->getModel();
  3823. if (!model)
  3824. {
  3825. return;
  3826. }
  3827. std::vector<std::string> items;
  3828. std::vector<std::string> disabled_items;
  3829. if (isInTrash())
  3830. {
  3831. items.emplace_back("Purge Item");
  3832. if (!isItemRemovable())
  3833. {
  3834. disabled_items.emplace_back("Purge Item");
  3835. }
  3836. items.emplace_back("Restore Item");
  3837. }
  3838. else
  3839. {
  3840. items.emplace_back("Properties");
  3841. #if LL_RESTORE_TO_WORLD
  3842. if (isInLostAndFound())
  3843. {
  3844. items.emplace_back("Restore to Last Position");
  3845. }
  3846. #endif
  3847. getClipboardEntries(true, items, disabled_items, flags);
  3848. LLViewerInventoryItem* vitemp = getItem();
  3849. if (vitemp && !isInMarketplace())
  3850. {
  3851. if (!isAgentAvatarValid())
  3852. {
  3853. return;
  3854. }
  3855. if (gAgentAvatarp->isWearingAttachment(mUUID))
  3856. {
  3857. items.emplace_back("Attach Separator");
  3858. items.emplace_back("Detach From Yourself");
  3859. items.emplace_back("Edit");
  3860. items.emplace_back("Inspect");
  3861. bool disable_edit = (flags & FIRST_SELECTED_ITEM) == 0;
  3862. bool disable_inspect = disable_edit;
  3863. //MK
  3864. if (gRLenabled)
  3865. {
  3866. if (gRLInterface.mContainsRez ||
  3867. gRLInterface.mContainsEdit)
  3868. {
  3869. disable_edit = true;
  3870. }
  3871. if (gRLInterface.mContainsShownames ||
  3872. gRLInterface.mContainsShownametags)
  3873. {
  3874. disable_inspect = true;
  3875. }
  3876. if (!gRLInterface.canDetach(gAgentAvatarp->getWornAttachment(mUUID)))
  3877. {
  3878. disabled_items.emplace_back("Detach From Yourself");
  3879. }
  3880. }
  3881. //mk
  3882. if (disable_edit)
  3883. {
  3884. disabled_items.emplace_back("Edit");
  3885. }
  3886. if (disable_inspect)
  3887. {
  3888. disabled_items.emplace_back("Inspect");
  3889. }
  3890. }
  3891. else if (isAgentInventory())
  3892. {
  3893. items.emplace_back("Attach Separator");
  3894. items.emplace_back("Object Wear");
  3895. items.emplace_back("Object Add");
  3896. if (!gAgentAvatarp->canAttachMoreObjects())
  3897. {
  3898. disabled_items.emplace_back("Object Add");
  3899. }
  3900. items.emplace_back("Attach To");
  3901. items.emplace_back("Attach To HUD");
  3902. //MK
  3903. if (gRLenabled && gRLInterface.mContainsDetach &&
  3904. (gRLInterface.mContainsDefaultwear ||
  3905. !gSavedSettings.getBool("RestrainedLoveAllowWear")) &&
  3906. !gRLInterface.findAttachmentPointFromName(vitemp->getName()) &&
  3907. !gRLInterface.findAttachmentPointFromParentName(vitemp))
  3908. {
  3909. disabled_items.emplace_back("Object Wear");
  3910. }
  3911. //mk
  3912. LLMenuGL* attach_menup = menu.getChildMenuByName("Attach To",
  3913. true);
  3914. LLMenuGL* attach_hud_menup =
  3915. menu.getChildMenuByName("Attach To HUD", true);
  3916. if (attach_menup && !attach_menup->getChildCount() &&
  3917. attach_hud_menup && !attach_hud_menup->getChildCount())
  3918. {
  3919. std::string name;
  3920. for (LLVOAvatar::attachment_map_t::iterator
  3921. iter = gAgentAvatarp->mAttachmentPoints.begin(),
  3922. end = gAgentAvatarp->mAttachmentPoints.end();
  3923. iter != end; ++iter)
  3924. {
  3925. LLViewerJointAttachment* attachmentp = iter->second;
  3926. if (!attachmentp) continue; // Paranoia
  3927. name = LLTrans::getString(attachmentp->getName());
  3928. LLMenuItemCallGL* entryp =
  3929. new LLMenuItemCallGL(name, NULL, NULL,
  3930. &attach_label,
  3931. (void*)attachmentp);
  3932. if (attachmentp->getIsHUDAttachment())
  3933. {
  3934. attach_hud_menup->append(entryp);
  3935. }
  3936. else
  3937. {
  3938. attach_menup->append(entryp);
  3939. }
  3940. LLSimpleListener* cb =
  3941. mInventoryPanel->getListenerByName("Inventory.AttachObject");
  3942. if (cb)
  3943. {
  3944. entryp->addListener(cb, "on_click", LLSD(name));
  3945. }
  3946. }
  3947. }
  3948. //MK
  3949. if (gRLenabled && !gRLInterface.canAttach(vitemp))
  3950. {
  3951. disabled_items.emplace_back("Object Wear");
  3952. disabled_items.emplace_back("Object Add");
  3953. disabled_items.emplace_back("Attach To");
  3954. disabled_items.emplace_back("Attach To HUD");
  3955. }
  3956. //mk
  3957. }
  3958. }
  3959. }
  3960. set_menu_entries_state(menu, items, disabled_items);
  3961. }
  3962. //virtual
  3963. bool LLObjectBridge::renameItem(const std::string& new_name)
  3964. {
  3965. if (!isItemRenameable())
  3966. {
  3967. return false;
  3968. }
  3969. LLPreview::rename(mUUID, getPrefix() + new_name);
  3970. LLInventoryModel* model = mInventoryPanel->getModel();
  3971. if (!model)
  3972. {
  3973. return false;
  3974. }
  3975. LLViewerInventoryItem* vitemp = getItem();
  3976. if (vitemp && vitemp->getName() != new_name)
  3977. {
  3978. LLPointer<LLViewerInventoryItem> new_vitemp;
  3979. new_vitemp = new LLViewerInventoryItem(vitemp);
  3980. new_vitemp->rename(new_name);
  3981. buildDisplayName(new_vitemp, mDisplayName);
  3982. new_vitemp->updateServer(false);
  3983. model->updateItem(new_vitemp);
  3984. model->notifyObservers();
  3985. if (isAgentAvatarValid())
  3986. {
  3987. LLViewerObject* obj;
  3988. obj = gAgentAvatarp->getWornAttachment(vitemp->getUUID());
  3989. if (obj)
  3990. {
  3991. gSelectMgr.deselectAll();
  3992. gSelectMgr.addAsIndividual(obj, SELECT_ALL_TES, false);
  3993. gSelectMgr.selectionSetObjectName(new_name);
  3994. gSelectMgr.deselectAll();
  3995. }
  3996. }
  3997. }
  3998. // Return false because we either notified observers (and therefore
  3999. // rebuilt) or we did not update.
  4000. return false;
  4001. }
  4002. ///////////////////////////////////////////////////////////////////////////////
  4003. // LLLSLTextBridge
  4004. ///////////////////////////////////////////////////////////////////////////////
  4005. //virtual
  4006. const std::string& LLLSLTextBridge::getPrefix()
  4007. {
  4008. static const std::string prefix = LLTrans::getString("Script") + ": ";
  4009. return prefix;
  4010. }
  4011. //virtual
  4012. LLUIImagePtr LLLSLTextBridge::getIcon() const
  4013. {
  4014. return LLInventoryIcon::getIcon(LLAssetType::AT_SCRIPT,
  4015. LLInventoryType::IT_LSL, 0, false);
  4016. }
  4017. //virtual
  4018. void LLLSLTextBridge::openItem()
  4019. {
  4020. open_script(mUUID, getPrefix() + getName());
  4021. }
  4022. ///////////////////////////////////////////////////////////////////////////////
  4023. // LLWearableBridge
  4024. ///////////////////////////////////////////////////////////////////////////////
  4025. //virtual
  4026. bool LLWearableBridge::renameItem(const std::string& new_name)
  4027. {
  4028. if (gAgentWearables.isWearingItem(mUUID))
  4029. {
  4030. gAgentWearables.setWearableName(mUUID, new_name);
  4031. }
  4032. return LLItemBridge::renameItem(new_name);
  4033. }
  4034. //virtual
  4035. bool LLWearableBridge::isItemRemovable()
  4036. {
  4037. LLInventoryModel* modelp = mInventoryPanel->getModel();
  4038. if (!modelp)
  4039. {
  4040. return false;
  4041. }
  4042. const LLViewerInventoryItem* vitemp = modelp->getItem(mUUID);
  4043. if (vitemp && vitemp->getIsLinkType())
  4044. {
  4045. return true;
  4046. }
  4047. if (gAgentWearables.isWearingItem(mUUID))
  4048. {
  4049. return false;
  4050. }
  4051. return LLInvFVBridge::isItemRemovable();
  4052. }
  4053. //virtual
  4054. LLFontGL::StyleFlags LLWearableBridge::getLabelStyle() const
  4055. {
  4056. S32 font = LLFontGL::NORMAL;
  4057. if (gAgentWearables.isWearingItem(mUUID))
  4058. {
  4059. font |= LLFontGL::BOLD;
  4060. }
  4061. const LLViewerInventoryItem* vitemp = getItem();
  4062. if (vitemp && vitemp->getIsLinkType())
  4063. {
  4064. font |= LLFontGL::ITALIC;
  4065. }
  4066. return (LLFontGL::StyleFlags)font;
  4067. }
  4068. std::string LLWearableBridge::getLabelSuffix() const
  4069. {
  4070. static const std::string worn = " (" + LLTrans::getString("worn") + ")";
  4071. if (gAgentWearables.isWearingItem(mUUID))
  4072. {
  4073. return LLItemBridge::getLabelSuffix() + worn;
  4074. }
  4075. return LLItemBridge::getLabelSuffix();
  4076. }
  4077. //virtual
  4078. LLUIImagePtr LLWearableBridge::getIcon() const
  4079. {
  4080. return LLInventoryIcon::getIcon(mAssetType, mInvType, mWearableType,
  4081. false);
  4082. }
  4083. //virtual
  4084. void LLWearableBridge::performAction(LLFolderView* folderp,
  4085. LLInventoryModel* modelp,
  4086. const std::string& action)
  4087. {
  4088. bool agent_inventory = isAgentInventory();
  4089. if (action == "wear")
  4090. {
  4091. if (agent_inventory)
  4092. {
  4093. wearOnAvatar();
  4094. }
  4095. }
  4096. else if (action == "wear_add")
  4097. {
  4098. if (agent_inventory)
  4099. {
  4100. wearOnAvatar(false);
  4101. }
  4102. }
  4103. else if (action == "edit")
  4104. {
  4105. if (agent_inventory)
  4106. {
  4107. editOnAvatar();
  4108. }
  4109. }
  4110. else if (action == "take_off")
  4111. {
  4112. if (isAgentAvatarValid() && gAgentWearables.isWearingItem(mUUID))
  4113. {
  4114. LLViewerInventoryItem* vitemp = getItem();
  4115. if (vitemp
  4116. //MK
  4117. && (!gRLenabled || gRLInterface.canUnwear(vitemp)))
  4118. //mk
  4119. {
  4120. LLWearableList* wlist = LLWearableList::getInstance();
  4121. wlist->getAsset(vitemp->getAssetUUID(), vitemp->getName(),
  4122. gAgentAvatarp, vitemp->getType(),
  4123. LLWearableBridge::onRemoveFromAvatarArrived,
  4124. new OnRemoveStruct(vitemp->getLinkedUUID()));
  4125. }
  4126. }
  4127. }
  4128. else
  4129. {
  4130. LLItemBridge::performAction(folderp, modelp, action);
  4131. }
  4132. }
  4133. //virtual
  4134. void LLWearableBridge::openItem()
  4135. {
  4136. if (isInTrash())
  4137. {
  4138. gNotifications.add("CannotWearTrash");
  4139. }
  4140. else if (gAgentWearables.isWearingItem(mUUID))
  4141. {
  4142. performAction(NULL, NULL, "take_off");
  4143. }
  4144. else if (isAgentInventory())
  4145. {
  4146. if (!isInMarketplace())
  4147. {
  4148. performAction(NULL, NULL, "wear");
  4149. }
  4150. }
  4151. else
  4152. {
  4153. // Must be in the inventory library. Copy it to our inventory and put
  4154. // it on right away.
  4155. LLViewerInventoryItem* vitemp = getItem();
  4156. if (vitemp && vitemp->isFinished())
  4157. {
  4158. LLPointer<LLInventoryCallback> cb = new LLWearOnAvatarCallback();
  4159. copy_inventory_item(vitemp->getPermissions().getOwner(),
  4160. vitemp->getUUID(), LLUUID::null,
  4161. LLStringUtil::null, cb);
  4162. }
  4163. else if (vitemp)
  4164. {
  4165. // *TODO: We should fetch the item details, and then do
  4166. // the operation above.
  4167. gNotifications.add("CannotWearInfoNotComplete");
  4168. }
  4169. }
  4170. }
  4171. //virtual
  4172. void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  4173. {
  4174. std::vector<std::string> items;
  4175. std::vector<std::string> disabled_items;
  4176. if (isInTrash())
  4177. {
  4178. items.emplace_back("Purge Item");
  4179. if (!isItemRemovable())
  4180. {
  4181. disabled_items.emplace_back("Purge Item");
  4182. }
  4183. items.emplace_back("Restore Item");
  4184. }
  4185. else if (isInMarketplace())
  4186. {
  4187. items.emplace_back("Properties");
  4188. getClipboardEntries(true, items, disabled_items, flags);
  4189. }
  4190. else
  4191. {
  4192. // FWIW, it looks like SUPPRESS_OPEN_ITEM is not set anywhere
  4193. bool no_open = ((flags & SUPPRESS_OPEN_ITEM) == SUPPRESS_OPEN_ITEM);
  4194. // If we have clothing, do not add "Open" as it is the same action as
  4195. // "Wear" SL-18976
  4196. LLViewerInventoryItem* vitemp = getItem();
  4197. if (!no_open && vitemp)
  4198. {
  4199. no_open = vitemp->getType() == LLAssetType::AT_CLOTHING ||
  4200. vitemp->getType() == LLAssetType::AT_BODYPART;
  4201. }
  4202. if (!no_open)
  4203. {
  4204. items.emplace_back("Open");
  4205. }
  4206. bool wearing = gAgentWearables.isWearingItem(mUUID);
  4207. bool agent_inventory = isAgentInventory();
  4208. // Allow to wear only non-library items in SSB-enabled sims
  4209. if (wearing || agent_inventory)
  4210. {
  4211. if (wearing)
  4212. {
  4213. items.emplace_back("Edit");
  4214. if (!agent_inventory || (flags & FIRST_SELECTED_ITEM) == 0)
  4215. {
  4216. disabled_items.emplace_back("Edit");
  4217. }
  4218. }
  4219. else
  4220. {
  4221. items.emplace_back("Wearable Wear");
  4222. //MK
  4223. if (gRLenabled && !gRLInterface.canWear(vitemp))
  4224. {
  4225. disabled_items.emplace_back("Wearable Wear");
  4226. }
  4227. //mk
  4228. }
  4229. if (vitemp && vitemp->getType() == LLAssetType::AT_CLOTHING)
  4230. {
  4231. if (wearing)
  4232. {
  4233. items.emplace_back("Take Off");
  4234. //MK
  4235. if (gRLenabled && !gRLInterface.canUnwear(vitemp))
  4236. {
  4237. disabled_items.emplace_back("Take Off");
  4238. }
  4239. //mk
  4240. }
  4241. else
  4242. {
  4243. items.emplace_back("Wearable Add");
  4244. //MK
  4245. if (gRLenabled && !gRLInterface.canWear(vitemp))
  4246. {
  4247. disabled_items.emplace_back("Wearable Add");
  4248. }
  4249. //mk
  4250. }
  4251. }
  4252. items.emplace_back("Wearable Separator");
  4253. }
  4254. items.emplace_back("Properties");
  4255. getClipboardEntries(true, items, disabled_items, flags);
  4256. }
  4257. set_menu_entries_state(menu, items, disabled_items);
  4258. }
  4259. // Called from menus
  4260. //static
  4261. bool LLWearableBridge::canWearOnAvatar(void* user_data)
  4262. {
  4263. LLWearableBridge* self = (LLWearableBridge*)user_data;
  4264. return self && self->isAgentInventory() &&
  4265. !gAgentWearables.isWearingItem(self->mUUID);
  4266. }
  4267. // Called from menus
  4268. //static
  4269. void LLWearableBridge::onWearOnAvatar(void* user_data)
  4270. {
  4271. LLWearableBridge* self = (LLWearableBridge*)user_data;
  4272. if (self)
  4273. {
  4274. self->wearOnAvatar();
  4275. }
  4276. }
  4277. void LLWearableBridge::wearOnAvatar(bool replace)
  4278. {
  4279. // Do not wear anything until initial wearables are loaded; could destroy
  4280. // clothing items.
  4281. if (!gAgentWearables.areWearablesLoaded())
  4282. {
  4283. gNotifications.add("CanNotChangeAppearanceUntilLoaded");
  4284. return;
  4285. }
  4286. LLViewerInventoryItem* vitemp = getItem();
  4287. if (vitemp)
  4288. {
  4289. gAppearanceMgr.wearItemOnAvatar(vitemp->getLinkedUUID(), replace);
  4290. }
  4291. }
  4292. //static
  4293. void LLWearableBridge::onWearOnAvatarArrived(LLViewerWearable* wearable,
  4294. void* userdata)
  4295. {
  4296. OnWearStruct* datap = (OnWearStruct*)userdata;
  4297. const LLUUID& item_id = datap->mUUID;
  4298. bool replace = datap->mReplace;
  4299. if (wearable)
  4300. {
  4301. LLViewerInventoryItem* vitemp = gInventory.getItem(item_id);
  4302. if (vitemp)
  4303. {
  4304. if (vitemp->getAssetUUID() == wearable->getAssetID())
  4305. {
  4306. //MK
  4307. bool old_restore = gRLInterface.mRestoringOutfit;
  4308. gRLInterface.mRestoringOutfit =
  4309. gAppearanceMgr.isRestoringInitialOutfit();
  4310. //mk
  4311. gAgentWearables.setWearableItem(vitemp, wearable, !replace);
  4312. //MK
  4313. gRLInterface.mRestoringOutfit = old_restore;
  4314. //mk
  4315. gInventory.notifyObservers();
  4316. }
  4317. else
  4318. {
  4319. llinfos << "By the time wearable asset arrived, its inv item already pointed to a different asset."
  4320. << llendl;
  4321. }
  4322. }
  4323. }
  4324. delete datap;
  4325. }
  4326. //static
  4327. bool LLWearableBridge::canEditOnAvatar(void* user_data)
  4328. {
  4329. LLWearableBridge* self = (LLWearableBridge*)user_data;
  4330. return self && gAgentWearables.isWearingItem(self->mUUID);
  4331. }
  4332. //static
  4333. void LLWearableBridge::onEditOnAvatar(void* user_data)
  4334. {
  4335. LLWearableBridge* self = (LLWearableBridge*)user_data;
  4336. if (self)
  4337. {
  4338. self->editOnAvatar();
  4339. }
  4340. }
  4341. // *TODO: implement v3's way and allow wear & edit
  4342. void LLWearableBridge::editOnAvatar()
  4343. {
  4344. const LLUUID& linked_id = gInventory.getLinkedItemID(mUUID);
  4345. LLViewerWearable* wearable =
  4346. gAgentWearables.getWearableFromItemID(linked_id);
  4347. if (wearable)
  4348. {
  4349. // Set the tab to the right wearable.
  4350. LLFloaterCustomize::setCurrentWearableType(wearable->getType());
  4351. if (gAgent.getCameraMode() != CAMERA_MODE_CUSTOMIZE_AVATAR)
  4352. {
  4353. // Start Avatar Customization
  4354. gAgent.changeCameraToCustomizeAvatar();
  4355. }
  4356. }
  4357. }
  4358. //static
  4359. bool LLWearableBridge::canRemoveFromAvatar(void* user_data)
  4360. {
  4361. LLWearableBridge* self = (LLWearableBridge*)user_data;
  4362. return self && self->mAssetType != LLAssetType::AT_BODYPART &&
  4363. gAgentWearables.isWearingItem(self->mUUID);
  4364. }
  4365. //static
  4366. void LLWearableBridge::onRemoveFromAvatar(void* user_data)
  4367. {
  4368. LLWearableBridge* self = (LLWearableBridge*)user_data;
  4369. if (self && isAgentAvatarValid() &&
  4370. gAgentWearables.isWearingItem(self->mUUID))
  4371. {
  4372. LLViewerInventoryItem* vitemp = self->getItem();
  4373. if (vitemp)
  4374. {
  4375. LLWearableList* wlist = LLWearableList::getInstance();
  4376. wlist->getAsset(vitemp->getAssetUUID(), vitemp->getName(),
  4377. gAgentAvatarp, vitemp->getType(),
  4378. onRemoveFromAvatarArrived,
  4379. new OnRemoveStruct(LLUUID(self->mUUID)));
  4380. }
  4381. }
  4382. }
  4383. //static
  4384. void LLWearableBridge::onRemoveFromAvatarArrived(LLViewerWearable* wearable,
  4385. void* userdata)
  4386. {
  4387. OnRemoveStruct* on_remove_struct = (OnRemoveStruct*)userdata;
  4388. if (!on_remove_struct) return; // Paranoia
  4389. const LLUUID& item_id =
  4390. gInventory.getLinkedItemID(on_remove_struct->mUUID);
  4391. if (wearable)
  4392. {
  4393. if (get_is_item_worn(item_id))
  4394. {
  4395. LLWearableType::EType type = wearable->getType();
  4396. U32 index;
  4397. if (gAgentWearables.getWearableIndex(wearable, index))
  4398. {
  4399. gAgentWearables.userRemoveWearable(type, index);
  4400. gInventory.notifyObservers();
  4401. }
  4402. }
  4403. }
  4404. delete on_remove_struct;
  4405. }
  4406. ///////////////////////////////////////////////////////////////////////////////
  4407. // LLLinkItemBridge
  4408. ///////////////////////////////////////////////////////////////////////////////
  4409. // For broken links
  4410. //virtual
  4411. const std::string& LLLinkItemBridge::getPrefix()
  4412. {
  4413. static const std::string prefix = LLTrans::getString("Link") + ": ";
  4414. return prefix;
  4415. }
  4416. //virtual
  4417. LLUIImagePtr LLLinkItemBridge::getIcon() const
  4418. {
  4419. if (LLViewerInventoryItem* vitemp = getItem())
  4420. {
  4421. // Low byte of inventory flags
  4422. U32 attachment_point = vitemp->getFlags() & 0xff;
  4423. bool is_multi = (LLInventoryItem::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS &
  4424. vitemp->getFlags()) != 0;
  4425. return LLInventoryIcon::getIcon(vitemp->getActualType(),
  4426. vitemp->getInventoryType(),
  4427. attachment_point, is_multi);
  4428. }
  4429. return LLInventoryIcon::getIcon(LLAssetType::AT_LINK,
  4430. LLInventoryType::IT_NONE, 0, false);
  4431. }
  4432. //virtual
  4433. void LLLinkItemBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  4434. {
  4435. std::vector<std::string> items;
  4436. std::vector<std::string> disabled_items;
  4437. items.emplace_back("Find Original");
  4438. disabled_items.emplace_back("Find Original");
  4439. if (isInTrash())
  4440. {
  4441. disabled_items.emplace_back("Find Original");
  4442. if (isLinkedObjectMissing())
  4443. {
  4444. disabled_items.emplace_back("Find Original");
  4445. }
  4446. items.emplace_back("Purge Item");
  4447. items.emplace_back("Restore Item");
  4448. }
  4449. else
  4450. {
  4451. items.emplace_back("Properties");
  4452. items.emplace_back("Find Original");
  4453. if (isLinkedObjectMissing())
  4454. {
  4455. disabled_items.emplace_back("Find Original");
  4456. }
  4457. items.emplace_back("Delete");
  4458. }
  4459. set_menu_entries_state(menu, items, disabled_items);
  4460. }
  4461. #if LL_MESH_ASSET_SUPPORT
  4462. ///////////////////////////////////////////////////////////////////////////////
  4463. // LLMeshBridge
  4464. ///////////////////////////////////////////////////////////////////////////////
  4465. //virtual
  4466. const std::string& LLMeshBridge::getPrefix()
  4467. {
  4468. static const std::string prefix = LLTrans::getString("Mesh") + ": ";
  4469. return prefix;
  4470. }
  4471. //virtual
  4472. LLUIImagePtr LLMeshBridge::getIcon() const
  4473. {
  4474. return LLInventoryIcon::getIcon(LLAssetType::AT_MESH,
  4475. LLInventoryType::IT_MESH, 0, false);
  4476. }
  4477. //virtual
  4478. void LLMeshBridge::openItem()
  4479. {
  4480. }
  4481. //virtual
  4482. void LLMeshBridge::previewItem()
  4483. {
  4484. }
  4485. //virtual
  4486. void LLMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  4487. {
  4488. std::vector<std::string> items;
  4489. std::vector<std::string> disabled_items;
  4490. if (isInTrash())
  4491. {
  4492. items.emplace_back("Purge Item");
  4493. items.emplace_back("Restore Item");
  4494. }
  4495. else
  4496. {
  4497. items.emplace_back("Properties");
  4498. getClipboardEntries(true, items, disabled_items, flags);
  4499. }
  4500. set_menu_entries_state(menu, items, disabled_items);
  4501. }
  4502. //virtual
  4503. void LLMeshBridge::performAction(LLFolderView* folderp,
  4504. LLInventoryModel* modelp,
  4505. const std::string& action)
  4506. {
  4507. LLItemBridge::performAction(folderp, modelp, action);
  4508. }
  4509. #endif
  4510. ///////////////////////////////////////////////////////////////////////////////
  4511. // LLSettingsBridge
  4512. ///////////////////////////////////////////////////////////////////////////////
  4513. //virtual
  4514. const std::string& LLSettingsBridge::getPrefix()
  4515. {
  4516. static const std::string prefix = LLTrans::getString("Settings") + ": ";
  4517. return prefix;
  4518. }
  4519. //virtual
  4520. LLUIImagePtr LLSettingsBridge::getIcon() const
  4521. {
  4522. return LLInventoryIcon::getIcon(LLAssetType::AT_SETTINGS,
  4523. LLInventoryType::IT_SETTINGS,
  4524. mSettingsType, false);
  4525. }
  4526. //virtual
  4527. LLFontGL::StyleFlags LLSettingsBridge::getLabelStyle() const
  4528. {
  4529. S32 font = LLFontGL::NORMAL;
  4530. #if 0 // *TODO: use bold font when settings active
  4531. if ()
  4532. {
  4533. font |= LLFontGL::BOLD;
  4534. }
  4535. #endif
  4536. const LLViewerInventoryItem* item = getItem();
  4537. if (item && item->getIsLinkType())
  4538. {
  4539. font |= LLFontGL::ITALIC;
  4540. }
  4541. return (LLFontGL::StyleFlags)font;
  4542. }
  4543. //virtual
  4544. void LLSettingsBridge::openItem()
  4545. {
  4546. LLViewerInventoryItem* item = getItem();
  4547. if (item && item->getPermissions().getOwner() == gAgentID)
  4548. {
  4549. HBFloaterEditEnvSettings* floaterp =
  4550. HBFloaterEditEnvSettings::show(mUUID);
  4551. if (floaterp)
  4552. {
  4553. floaterp->setEditContextInventory();
  4554. }
  4555. }
  4556. else
  4557. {
  4558. gNotifications.add("NoEditFromLibrary");
  4559. }
  4560. }
  4561. //virtual
  4562. void LLSettingsBridge::previewItem()
  4563. {
  4564. openItem();
  4565. }
  4566. //virtual
  4567. void LLSettingsBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  4568. {
  4569. std::vector<std::string> items;
  4570. std::vector<std::string> disabled_items;
  4571. if (isInTrash())
  4572. {
  4573. items.emplace_back("Purge Item");
  4574. items.emplace_back("Restore Item");
  4575. if (!gAgent.hasInventorySettings())
  4576. {
  4577. disabled_items.emplace_back("Restore Item");
  4578. }
  4579. }
  4580. else if (gAgent.hasInventorySettings())
  4581. {
  4582. items.emplace_back("Settings Open");
  4583. items.emplace_back("Properties");
  4584. getClipboardEntries(true, items, disabled_items, flags);
  4585. items.emplace_back("Setings Separator");
  4586. items.emplace_back("Apply Local");
  4587. items.emplace_back("Apply Parcel");
  4588. if (!LLEnvironment::canAgentUpdateParcelEnvironment())
  4589. {
  4590. disabled_items.emplace_back("Apply Parcel");
  4591. }
  4592. items.emplace_back("Apply Region");
  4593. if (!LLEnvironment::canAgentUpdateRegionEnvironment())
  4594. {
  4595. disabled_items.emplace_back("Apply Region");
  4596. }
  4597. }
  4598. else
  4599. {
  4600. items.emplace_back("Properties");
  4601. disabled_items.emplace_back("Properties");
  4602. items.emplace_back("Delete");
  4603. if (!isItemRemovable())
  4604. {
  4605. disabled_items.emplace_back("Delete");
  4606. }
  4607. }
  4608. set_menu_entries_state(menu, items, disabled_items);
  4609. }
  4610. //virtual
  4611. void LLSettingsBridge::performAction(LLFolderView* folderp,
  4612. LLInventoryModel* modelp,
  4613. const std::string& action)
  4614. {
  4615. if (action == "apply_settings_local")
  4616. {
  4617. LLViewerInventoryItem* item = getItem();
  4618. if (item)
  4619. {
  4620. LLUUID asset_id = item->getAssetUUID();
  4621. gEnvironment.setEnvironment(LLEnvironment::ENV_LOCAL, asset_id,
  4622. LLEnvironment::TRANSITION_INSTANT);
  4623. gEnvironment.setSelectedEnvironment(LLEnvironment::ENV_LOCAL,
  4624. LLEnvironment::TRANSITION_INSTANT);
  4625. if (gAutomationp)
  4626. {
  4627. LLSettingsType::EType type = item->getSettingsType();
  4628. const std::string& name = item->getName();
  4629. if (type == LLSettingsType::ST_SKY)
  4630. {
  4631. gAutomationp->onWindlightChange(name, "", "");
  4632. }
  4633. else if (type == LLSettingsType::ST_WATER)
  4634. {
  4635. gAutomationp->onWindlightChange("", name, "");
  4636. }
  4637. else if (type == LLSettingsType::ST_DAYCYCLE)
  4638. {
  4639. gAutomationp->onWindlightChange("", "", name);
  4640. }
  4641. }
  4642. }
  4643. }
  4644. else if (action == "apply_settings_parcel")
  4645. {
  4646. LLViewerInventoryItem* item = getItem();
  4647. if (!item) return;
  4648. LLUUID asset_id = item->getAssetUUID();
  4649. std::string name = item->getName();
  4650. LLParcel* parcelp = gViewerParcelMgr.getSelectedOrAgentParcel();
  4651. if (!parcelp)
  4652. {
  4653. llwarns << "Could not find any selected or agent parcel. Aborted."
  4654. << llendl;
  4655. return;
  4656. }
  4657. if (!LLEnvironment::canAgentUpdateParcelEnvironment(parcelp))
  4658. {
  4659. gNotifications.add("WLParcelApplyFail");
  4660. return;
  4661. }
  4662. S32 parcel_id = parcelp->getLocalID();
  4663. LL_DEBUGS("Environment") << "Applying environment settings asset Id "
  4664. << asset_id << " to parcel " << parcel_id
  4665. << LL_ENDL;
  4666. U32 flags = 0;
  4667. const LLPermissions& perms = item->getPermissions();
  4668. if (!perms.allowModifyBy(gAgentID))
  4669. {
  4670. flags |= LLSettingsBase::FLAG_NOMOD;
  4671. }
  4672. if (!perms.allowTransferBy(gAgentID))
  4673. {
  4674. flags |= LLSettingsBase::FLAG_NOTRANS;
  4675. }
  4676. gEnvironment.updateParcel(parcel_id, asset_id, name,
  4677. LLEnvironment::NO_TRACK, -1, -1, flags);
  4678. gEnvironment.setSharedEnvironment();
  4679. }
  4680. else if (action == "apply_settings_region")
  4681. {
  4682. LLViewerInventoryItem* item = getItem();
  4683. if (!item) return;
  4684. if (!LLEnvironment::canAgentUpdateRegionEnvironment())
  4685. {
  4686. LLSD args;
  4687. args["FAIL_REASON"] = LLTrans::getString("no_permission");
  4688. gNotifications.add("WLRegionApplyFail", args);
  4689. return;
  4690. }
  4691. U32 flags = 0;
  4692. const LLPermissions& perms = item->getPermissions();
  4693. if (!perms.allowModifyBy(gAgentID))
  4694. {
  4695. flags |= LLSettingsBase::FLAG_NOMOD;
  4696. }
  4697. if (!perms.allowTransferBy(gAgentID))
  4698. {
  4699. flags |= LLSettingsBase::FLAG_NOTRANS;
  4700. }
  4701. gEnvironment.updateRegion(item->getAssetUUID(), item->getName(),
  4702. LLEnvironment::NO_TRACK, -1, -1, flags);
  4703. }
  4704. else if (action == "open")
  4705. {
  4706. openItem();
  4707. }
  4708. else
  4709. {
  4710. LLItemBridge::performAction(folderp, modelp, action);
  4711. }
  4712. }
  4713. ///////////////////////////////////////////////////////////////////////////////
  4714. // LLMaterialBridge
  4715. ///////////////////////////////////////////////////////////////////////////////
  4716. //virtual
  4717. const std::string& LLMaterialBridge::getPrefix()
  4718. {
  4719. static const std::string prefix = LLTrans::getString("Material") + ": ";
  4720. return prefix;
  4721. }
  4722. //virtual
  4723. LLUIImagePtr LLMaterialBridge::getIcon() const
  4724. {
  4725. return LLInventoryIcon::getIcon(LLAssetType::AT_MATERIAL,
  4726. LLInventoryType::IT_MATERIAL, 0, false);
  4727. }
  4728. //virtual
  4729. void LLMaterialBridge::openItem()
  4730. {
  4731. open_material(mUUID, getName());
  4732. }
  4733. //virtual
  4734. void LLMaterialBridge::previewItem()
  4735. {
  4736. open_material(mUUID, getName());
  4737. }
  4738. //virtual
  4739. void LLMaterialBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  4740. {
  4741. std::vector<std::string> items;
  4742. std::vector<std::string> disabled_items;
  4743. if (isInTrash())
  4744. {
  4745. items.emplace_back("Purge Item");
  4746. items.emplace_back("Restore Item");
  4747. if (!gAgent.hasInventoryMaterial())
  4748. {
  4749. disabled_items.emplace_back("Restore Item");
  4750. }
  4751. }
  4752. else if (gAgent.hasInventoryMaterial())
  4753. {
  4754. items.emplace_back("Properties");
  4755. items.emplace_back("Edit");
  4756. bool disable_edit = (flags & FIRST_SELECTED_ITEM) == 0;
  4757. if (disable_edit)
  4758. {
  4759. disabled_items.emplace_back("Edit");
  4760. }
  4761. getClipboardEntries(true, items, disabled_items, flags);
  4762. }
  4763. else
  4764. {
  4765. items.emplace_back("Properties");
  4766. disabled_items.emplace_back("Properties");
  4767. items.emplace_back("Delete");
  4768. }
  4769. set_menu_entries_state(menu, items, disabled_items);
  4770. }
  4771. //virtual
  4772. void LLMaterialBridge::performAction(LLFolderView* folderp,
  4773. LLInventoryModel* modelp,
  4774. const std::string& action)
  4775. {
  4776. if (action == "edit")
  4777. {
  4778. openItem();
  4779. return;
  4780. }
  4781. LLItemBridge::performAction(folderp, modelp, action);
  4782. }
  4783. ///////////////////////////////////////////////////////////////////////////////
  4784. // LLLinkFolderBridge
  4785. ///////////////////////////////////////////////////////////////////////////////
  4786. //virtual
  4787. const std::string& LLLinkFolderBridge::getPrefix()
  4788. {
  4789. static const std::string prefix = LLTrans::getString("Link") + ": ";
  4790. return prefix;
  4791. }
  4792. //virtual
  4793. LLUIImagePtr LLLinkFolderBridge::getIcon() const
  4794. {
  4795. return LLUI::getUIImage("inv_link_folder.tga");
  4796. }
  4797. //virtual
  4798. void LLLinkFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
  4799. {
  4800. std::vector<std::string> items;
  4801. std::vector<std::string> disabled_items;
  4802. items.emplace_back("Find Original");
  4803. if (isLinkedObjectMissing())
  4804. {
  4805. disabled_items.emplace_back("Find Original");
  4806. }
  4807. if (isInTrash())
  4808. {
  4809. items.emplace_back("Purge Item");
  4810. items.emplace_back("Restore Item");
  4811. }
  4812. else
  4813. {
  4814. items.emplace_back("Delete");
  4815. }
  4816. set_menu_entries_state(menu, items, disabled_items);
  4817. }
  4818. //virtual
  4819. void LLLinkFolderBridge::performAction(LLFolderView* folderp,
  4820. LLInventoryModel* modelp,
  4821. const std::string& action)
  4822. {
  4823. if (action == "goto")
  4824. {
  4825. gotoItem(folderp);
  4826. return;
  4827. }
  4828. LLItemBridge::performAction(folderp, modelp, action);
  4829. }
  4830. //virtual
  4831. void LLLinkFolderBridge::gotoItem(LLFolderView* folderp)
  4832. {
  4833. const LLUUID& cat_uuid = getFolderID();
  4834. if (cat_uuid.notNull())
  4835. {
  4836. if (LLFolderViewItem* base_folderp = folderp->getItemByID(cat_uuid))
  4837. {
  4838. if (LLInventoryModel* modelp = mInventoryPanel->getModel())
  4839. {
  4840. modelp->fetchDescendentsOf(cat_uuid);
  4841. }
  4842. base_folderp->setOpen(true);
  4843. folderp->setSelectionFromRoot(base_folderp, true);
  4844. folderp->scrollToShowSelection();
  4845. }
  4846. }
  4847. }
  4848. const LLUUID& LLLinkFolderBridge::getFolderID() const
  4849. {
  4850. if (LLViewerInventoryItem* link_item = getItem())
  4851. {
  4852. const LLViewerInventoryCategory* cat = link_item->getLinkedCategory();
  4853. if (cat)
  4854. {
  4855. const LLUUID& cat_uuid = cat->getUUID();
  4856. return cat_uuid;
  4857. }
  4858. }
  4859. return LLUUID::null;
  4860. }