llfloaterscriptqueue.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. /**
  2. * @file llfloaterscriptqueue.cpp
  3. * @brief LLFloaterScriptQueue class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-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. /**
  33. *
  34. * Implementation of the script queue which keeps an array of object
  35. * UUIDs and manipulates all of the scripts on each of them.
  36. *
  37. */
  38. #include "llviewerprecompiledheaders.h"
  39. #include <utility>
  40. #include "llfloaterscriptqueue.h"
  41. #include "llbutton.h"
  42. #include "lldir.h"
  43. #include "llexperiencecache.h"
  44. #include "llscrolllistctrl.h"
  45. #include "lluictrlfactory.h"
  46. #include "lluistring.h"
  47. #include "llagent.h"
  48. #include "llchat.h"
  49. #include "llfloaterchat.h"
  50. #include "llselectmgr.h"
  51. #include "llviewerassetupload.h"
  52. #include "llviewercontrol.h"
  53. #include "llviewerobjectlist.h"
  54. #include "llviewerregion.h"
  55. #include "llviewerstats.h"
  56. struct LLScriptQueueData
  57. {
  58. LLUUID mQueueID;
  59. LLUUID mTaskId;
  60. LLPointer<LLInventoryItem> mItem;
  61. LLHost mHost;
  62. LLUUID mExperienceId;
  63. std::string mExperiencename;
  64. LLScriptQueueData(const LLUUID& q_id, const LLUUID& task_id,
  65. LLInventoryItem* item, const LLHost& host)
  66. : mQueueID(q_id),
  67. mTaskId(task_id),
  68. mItem(new LLInventoryItem(item)),
  69. mHost(host)
  70. {
  71. }
  72. };
  73. // NOTE: minor specialization of LLScriptAssetUpload: it does not require a
  74. // buffer (and does not save a buffer to the cache) and it finds the compile
  75. // queue floater and displays a compiling message.
  76. class LLQueuedScriptAssetUpload final : public LLScriptAssetUpload
  77. {
  78. protected:
  79. LOG_CLASS(LLQueuedScriptAssetUpload);
  80. public:
  81. LLQueuedScriptAssetUpload(const LLUUID& task_id, const LLUUID& item_id,
  82. const LLUUID& asset_id, TargetType_t target_type,
  83. bool running, const std::string& script_name,
  84. const LLUUID& queue_id, const LLUUID& exp_id,
  85. task_uploaded_cb_t finish)
  86. : LLScriptAssetUpload(task_id, item_id, target_type, running, exp_id,
  87. // *TODO: provide a proper failed_cb_t callback.
  88. LLStringUtil::null, finish, failed_cb_t()),
  89. mScriptName(script_name),
  90. mQueueId(queue_id)
  91. {
  92. setAssetId(asset_id);
  93. }
  94. LLSD prepareUpload() override
  95. {
  96. // NOTE: the parent class (LLScriptAssetUpload) will attempt to save
  97. // the script buffer into to the cache. Since the resource is already
  98. // in the cache we do not want to do that. Just put a compiling message
  99. // in the window and move on.
  100. LLFloaterCompileQueue* queue;
  101. queue = (LLFloaterCompileQueue*)LLFloaterScriptQueue::findInstance(mQueueId);
  102. if (queue)
  103. {
  104. std::string message = queue->getString("compiling") + " ";
  105. queue->logMessage(message + mScriptName);
  106. }
  107. return LLSD().with("success", LLSD::Boolean(true));
  108. }
  109. private:
  110. void setScriptName(const std::string& name) { mScriptName = name; }
  111. private:
  112. LLUUID mQueueId;
  113. std::string mScriptName;
  114. };
  115. ///////////////////////////////////////////////////////////////////////////////
  116. // Class LLFloaterScriptQueue
  117. ///////////////////////////////////////////////////////////////////////////////
  118. //static
  119. LLFloaterScriptQueue::instances_map_t LLFloaterScriptQueue::sInstances;
  120. LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& title,
  121. const std::string& verb)
  122. : LLFloater("script queue"),
  123. mDone(false)
  124. {
  125. mID.generate();
  126. sInstances[mID] = this;
  127. LLUICtrlFactory::getInstance()->buildFloater(this,
  128. "floater_script_queue.xml");
  129. setTitle(getString(title));
  130. mVerb = getString(verb);
  131. }
  132. //virtual
  133. LLFloaterScriptQueue::~LLFloaterScriptQueue()
  134. {
  135. sInstances.erase(mID);
  136. }
  137. //virtual
  138. bool LLFloaterScriptQueue::postBuild()
  139. {
  140. mCloseBtn = getChild<LLButton>("close");
  141. mCloseBtn->setClickedCallback(onCloseBtn, this);
  142. mCloseBtn->setEnabled(false);
  143. mMessages = getChild<LLScrollListCtrl>("queue output");
  144. return true;
  145. }
  146. // Finds an instance by Id. Returns NULL if it does not exist.
  147. //static
  148. LLFloaterScriptQueue* LLFloaterScriptQueue::findInstance(const LLUUID& id)
  149. {
  150. instances_map_t::iterator it = sInstances.find(id);
  151. return it != sInstances.end() ? it->second : NULL;
  152. }
  153. void LLFloaterScriptQueue::logMessage(const std::string& message)
  154. {
  155. mMessages->addCommentText(message);
  156. }
  157. void LLFloaterScriptQueue::requestInventory(LLViewerObject* objectp)
  158. {
  159. if (objectp && !hasRegisteredListener(objectp))
  160. {
  161. registerVOInventoryListener(objectp, NULL);
  162. requestVOInventory(objectp);
  163. }
  164. }
  165. // This is the callback method for the viewer object currently being worked on.
  166. //virtual
  167. void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* objectp,
  168. LLInventoryObject::object_list_t* inv,
  169. S32, void*)
  170. {
  171. if (!objectp)
  172. {
  173. return;
  174. }
  175. llinfos << "Processing object " << objectp->getID() << llendl;
  176. removeVOInventoryListener(objectp);
  177. if (inv && objectp->getID() == mCurrentObjectID)
  178. {
  179. llinfos << "Processing object " << mCurrentObjectID << llendl;
  180. handleInventory(objectp, inv);
  181. }
  182. else
  183. {
  184. // No inventory for the current primitive: move to the next.
  185. llinfos << "No inventory for " << mCurrentObjectID << llendl;
  186. nextObject();
  187. }
  188. }
  189. //static
  190. void LLFloaterScriptQueue::onCloseBtn(void* user_data)
  191. {
  192. LLFloaterScriptQueue* self = (LLFloaterScriptQueue*)user_data;
  193. self->close();
  194. }
  195. bool LLFloaterScriptQueue::start()
  196. {
  197. // Note: we add all the selected objects, be them flagged as scripted or
  198. // not, because this info is received asynchronously from the server and
  199. // may not yet be known to the viewer, especially in child primitives. We
  200. // therefore need to retreive the inventory for each and every selected
  201. // primitive.
  202. LLObjectSelectionHandle object_selection = gSelectMgr.getSelection();
  203. for (LLObjectSelection::valid_iterator
  204. iter = object_selection->valid_begin(),
  205. end = object_selection->valid_end();
  206. iter != end; ++iter)
  207. {
  208. LLSelectNode* obj = *iter;
  209. if (!obj) continue; // Paranoia
  210. LLViewerObject* vobj = obj->getObject();
  211. if (!vobj || vobj->isDead())
  212. {
  213. // Object gone or soon gone !
  214. continue;
  215. }
  216. LLUUID id = vobj->getID();
  217. if (obj->mCreationDate == 0)
  218. {
  219. llwarns << "Object skipped due to missing information from the server. Id: "
  220. << id << llendl;
  221. }
  222. else if (vobj->permModify())
  223. {
  224. llinfos << "Adding object id: " << id << llendl;
  225. mObjectIDs.emplace_back(id);
  226. }
  227. }
  228. LLUIString starting = getString("starting");
  229. starting.setArg("[VERB]", mVerb);
  230. starting.setArg("[ITEMS]", llformat("%d", mObjectIDs.size()));
  231. logMessage(starting.getString());
  232. return startQueue();
  233. }
  234. bool LLFloaterScriptQueue::nextObject()
  235. {
  236. bool successful_start = false;
  237. do
  238. {
  239. mCurrentObjectID.setNull();
  240. S32 count = mObjectIDs.size();
  241. llinfos << count << " objects left to process." << llendl;
  242. if (count > 0)
  243. {
  244. mCurrentObjectID = mObjectIDs.back();
  245. mObjectIDs.pop_back();
  246. LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID);
  247. if (obj && !obj->isDead())
  248. {
  249. llinfos << "Requesting inventory for " << mCurrentObjectID
  250. << llendl;
  251. requestInventory(obj);
  252. successful_start = true;
  253. }
  254. else
  255. {
  256. llinfos << "Removed dead object id: " << mCurrentObjectID
  257. << llendl;
  258. mCurrentObjectID.setNull();
  259. }
  260. }
  261. llinfos << "Operation "
  262. << (successful_start ? "successful" : "unsuccessful")
  263. << llendl;
  264. }
  265. while (mObjectIDs.size() > 0 && !successful_start);
  266. if (isDone() && !mDone)
  267. {
  268. mDone = true;
  269. logMessage(getString("done"));
  270. mCloseBtn->setEnabled(true);
  271. }
  272. return successful_start;
  273. }
  274. //virtual
  275. bool LLFloaterScriptQueue::startQueue()
  276. {
  277. return nextObject();
  278. }
  279. ///////////////////////////////////////////////////////////////////////////////
  280. // Class LLFloaterCompileQueue
  281. ///////////////////////////////////////////////////////////////////////////////
  282. //static
  283. LLFloaterCompileQueue* LLFloaterCompileQueue::create(bool mono)
  284. {
  285. LLFloaterCompileQueue* self = new LLFloaterCompileQueue();
  286. self->mMono = mono;
  287. return self;
  288. }
  289. LLFloaterCompileQueue::LLFloaterCompileQueue()
  290. : LLFloaterScriptQueue("compile_title", "compile_verb")
  291. {
  292. }
  293. void LLFloaterCompileQueue::experienceIdsReceived(const LLSD& content)
  294. {
  295. for (LLSD::array_const_iterator it = content.beginArray(),
  296. end = content.endArray();
  297. it != end; ++it)
  298. {
  299. mExperienceIds.emplace(it->asUUID());
  300. }
  301. nextObject();
  302. }
  303. bool LLFloaterCompileQueue::hasExperience(const LLUUID& id) const
  304. {
  305. return mExperienceIds.count(id) != 0;
  306. }
  307. void LLFloaterCompileQueue::handleInventory(LLViewerObject* objectp,
  308. LLInventoryObject::object_list_t* inv)
  309. {
  310. if (!objectp || !inv) return;
  311. // Find all of the LSL, leaving off duplicates. We will remove all matching
  312. // asset UUIDs on compilation success.
  313. typedef std::multimap<LLUUID, LLPointer<LLInventoryItem> > uuid_item_map;
  314. uuid_item_map asset_item_map;
  315. LLInventoryObject::object_list_t::const_iterator it = inv->begin();
  316. LLInventoryObject::object_list_t::const_iterator end = inv->end();
  317. for ( ; it != end; ++it)
  318. {
  319. LLAssetType::EType type = (*it)->getType();
  320. if (type == LLAssetType::AT_LSL_TEXT ||
  321. type == LLAssetType::AT_SCRIPT) // Legacy scripts
  322. {
  323. LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
  324. // Check permissions before allowing the user to retrieve data.
  325. if (item->getPermissions().allowModifyBy(gAgentID, gAgent.getGroupID()) &&
  326. item->getPermissions().allowCopyBy(gAgentID, gAgent.getGroupID()))
  327. {
  328. LLPointer<LLViewerInventoryItem> script =
  329. new LLViewerInventoryItem(item);
  330. mCurrentScripts.emplace_back(std::move(script));
  331. asset_item_map.emplace(item->getAssetUUID(), item);
  332. }
  333. }
  334. }
  335. if (asset_item_map.empty())
  336. {
  337. // There is no script in this object. Move on.
  338. nextObject();
  339. }
  340. else
  341. {
  342. LLViewerRegion* regionp = objectp->getRegion();
  343. if (!regionp)
  344. {
  345. // No region associated with this object !... Move on.
  346. llwarns << "NULL region for object: " << objectp->getID()
  347. << ". Skipping." << llendl;
  348. nextObject();
  349. return;
  350. }
  351. const std::string& url = regionp->getCapability("GetMetadata");
  352. LLExperienceCache* expcache = LLExperienceCache::getInstance();
  353. // Request all of the assets.
  354. for (uuid_item_map::iterator iter = asset_item_map.begin(),
  355. end = asset_item_map.end();
  356. iter != end; ++iter)
  357. {
  358. LLInventoryItem* itemp = iter->second;
  359. LLScriptQueueData* datap =
  360. new LLScriptQueueData(getID(), objectp->getID(), itemp,
  361. regionp->getHost());
  362. if (!url.empty())
  363. {
  364. expcache->fetchAssociatedExperience(itemp->getParentUUID(),
  365. itemp->getUUID(), url,
  366. boost::bind(LLFloaterCompileQueue::requestAsset,
  367. datap, _1));
  368. }
  369. else
  370. {
  371. requestAsset(datap, LLSD());
  372. }
  373. }
  374. }
  375. }
  376. //static
  377. void LLFloaterCompileQueue::requestAsset(LLScriptQueueData* datap,
  378. const LLSD& experience)
  379. {
  380. if (!datap || !gAssetStoragep) return;
  381. LLFloaterCompileQueue* queue =
  382. (LLFloaterCompileQueue*)LLFloaterScriptQueue::findInstance(datap->mQueueID);
  383. if (!queue)
  384. {
  385. delete datap;
  386. return;
  387. }
  388. if (experience.has(LLExperienceCache::EXPERIENCE_ID))
  389. {
  390. datap->mExperienceId=experience[LLExperienceCache::EXPERIENCE_ID].asUUID();
  391. if (!queue->hasExperience(datap->mExperienceId))
  392. {
  393. LLUIString skipping = queue->getString("skipping");
  394. skipping.setArg("[SCRIPT]", datap->mItem->getName());
  395. skipping.setArg("[EXP]",
  396. experience[LLExperienceCache::NAME].asString());
  397. queue->logMessage(skipping.getString());
  398. queue->removeItemByItemID(datap->mItem->getUUID());
  399. delete datap;
  400. return;
  401. }
  402. }
  403. gAssetStoragep->getInvItemAsset(datap->mHost, gAgentID, gAgentSessionID,
  404. datap->mItem->getPermissions().getOwner(),
  405. datap->mTaskId, datap->mItem->getUUID(),
  406. datap->mItem->getAssetUUID(),
  407. datap->mItem->getType(),
  408. scriptArrived, (void*)datap);
  409. }
  410. //static
  411. void LLFloaterCompileQueue::finishLSLUpload(LLUUID item_id, LLUUID task_id,
  412. LLUUID new_asset_id, LLSD response,
  413. std::string script_name,
  414. LLUUID queue_id)
  415. {
  416. std::string message;
  417. LLFloaterCompileQueue* queue =
  418. (LLFloaterCompileQueue*)LLFloaterScriptQueue::findInstance(queue_id);
  419. if (queue)
  420. {
  421. // Bytecode save completed
  422. if (response["compiled"])
  423. {
  424. message = "Compilation of \"" + script_name + "\" succeeded.";
  425. queue->logMessage(message);
  426. llinfos << message << llendl;
  427. }
  428. else
  429. {
  430. LLSD compile_errors = response["errors"];
  431. for (LLSD::array_const_iterator line = compile_errors.beginArray(),
  432. endl = compile_errors.endArray();
  433. line != endl; ++line)
  434. {
  435. std::string str = line->asString();
  436. str.erase(std::remove(str.begin(), str.end(), '\n'),
  437. str.end());
  438. queue->logMessage(message);
  439. }
  440. llinfos << response["errors"] << llendl;
  441. }
  442. queue->removeItemByItemID(item_id);
  443. }
  444. }
  445. // This is the callback for when each script arrives
  446. //static
  447. void LLFloaterCompileQueue::scriptArrived(const LLUUID& asset_id,
  448. LLAssetType::EType type,
  449. void* user_data, S32 status,
  450. LLExtStat)
  451. {
  452. LLScriptQueueData* data = (LLScriptQueueData*)user_data;
  453. if (!data) return;
  454. std::string buffer;
  455. std::string script_name = data->mItem->getName();
  456. LLFloaterCompileQueue* queue =
  457. (LLFloaterCompileQueue*)LLFloaterScriptQueue::findInstance(data->mQueueID);
  458. if (queue && status == 0)
  459. {
  460. LLViewerObject* object = gObjectList.findObject(data->mTaskId);
  461. if (!object)
  462. {
  463. llwarns << "Object " << data->mTaskId
  464. << " is gone. Skipping script." << llendl;
  465. return;
  466. }
  467. LLViewerRegion* regionp = object->getRegion();
  468. if (!regionp)
  469. {
  470. llwarns << "NULL region for object: " << object->getID()
  471. << ". Skipping script." << llendl;
  472. return;
  473. }
  474. const std::string& url = regionp->getCapability("UpdateScriptTask");
  475. if (url.empty())
  476. {
  477. llwarns << "Missing UpdateScriptTask capability for region of object "
  478. << object->getID() << ". Skipping script." << llendl;
  479. return;
  480. }
  481. LLBufferedAssetUploadInfo::task_uploaded_cb_t proc =
  482. boost::bind(&LLFloaterCompileQueue::finishLSLUpload, _1, _2, _3,
  483. _4, script_name, queue->getID());
  484. LLResourceUploadInfo::ptr_t
  485. info(new LLQueuedScriptAssetUpload(data->mTaskId,
  486. data->mItem->getUUID(),
  487. asset_id,
  488. queue->mMono ? LLScriptAssetUpload::MONO
  489. : LLScriptAssetUpload::LSL2,
  490. true, script_name,
  491. queue->getID(),
  492. data->mExperienceId, proc));
  493. LLViewerAssetUpload::enqueueInventoryUpload(url, info);
  494. }
  495. else
  496. {
  497. gViewerStats.incStat(LLViewerStats::ST_DOWNLOAD_FAILED);
  498. if (status == LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE)
  499. {
  500. buffer = queue->getString("not_found") + " " + script_name;
  501. }
  502. else if (status == LL_ERR_INSUFFICIENT_PERMISSIONS)
  503. {
  504. buffer = queue->getString("bad_perm") + " " + script_name;
  505. }
  506. else
  507. {
  508. buffer = queue->getString("failure") + " " + script_name;
  509. }
  510. llwarns << "Problem downloading script: " << script_name << llendl;
  511. if (gSavedSettings.getBool("ScriptErrorsAsChat"))
  512. {
  513. LLChat chat(buffer);
  514. LLFloaterChat::addChat(chat);
  515. }
  516. if (queue)
  517. {
  518. queue->removeItemByItemID(data->mItem->getUUID());
  519. }
  520. }
  521. if (queue && buffer.size() > 0)
  522. {
  523. queue->logMessage(buffer);
  524. }
  525. delete data;
  526. }
  527. void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id)
  528. {
  529. for (size_t i = 0; i < mCurrentScripts.size(); )
  530. {
  531. if (mCurrentScripts[i]->getUUID() == asset_id)
  532. {
  533. vector_replace_with_last(mCurrentScripts,
  534. mCurrentScripts.begin() + i);
  535. }
  536. else
  537. {
  538. ++i;
  539. }
  540. }
  541. if (mCurrentScripts.empty())
  542. {
  543. nextObject();
  544. }
  545. }
  546. bool LLFloaterCompileQueue::startQueue()
  547. {
  548. const std::string& url =
  549. gAgent.getRegionCapability("GetCreatorExperiences");
  550. if (!url.empty())
  551. {
  552. LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t
  553. succ = boost::bind(&LLFloaterCompileQueue::processExperienceIdResults,
  554. _1, getID());
  555. LLCoreHttpUtil::HttpCoroutineAdapter::completionCallback_t
  556. fail = boost::bind(&LLFloaterCompileQueue::processExperienceIdResults,
  557. LLSD(), getID());
  558. LLCoreHttpUtil::HttpCoroutineAdapter::callbackHttpGet(url, succ, fail);
  559. return true;
  560. }
  561. return nextObject();
  562. }
  563. //static
  564. void LLFloaterCompileQueue::processExperienceIdResults(LLSD result,
  565. LLUUID queue_id)
  566. {
  567. LLFloaterCompileQueue* self =
  568. (LLFloaterCompileQueue*)LLFloaterScriptQueue::findInstance(queue_id);
  569. if (self)
  570. {
  571. self->experienceIdsReceived(result["experience_ids"]);
  572. }
  573. }
  574. ///////////////////////////////////////////////////////////////////////////////
  575. // Class LLFloaterResetQueue
  576. ///////////////////////////////////////////////////////////////////////////////
  577. //static
  578. LLFloaterResetQueue* LLFloaterResetQueue::create()
  579. {
  580. return new LLFloaterResetQueue();
  581. }
  582. LLFloaterResetQueue::LLFloaterResetQueue()
  583. : LLFloaterScriptQueue("reset_title", "reset_verb")
  584. {
  585. }
  586. void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj,
  587. LLInventoryObject::object_list_t* inv)
  588. {
  589. // find all of the lsl, leaving off duplicates. We'll remove all matching
  590. // asset uuids on compilation success.
  591. LLInventoryObject::object_list_t::const_iterator it = inv->begin();
  592. LLInventoryObject::object_list_t::const_iterator end = inv->end();
  593. for ( ; it != end; ++it)
  594. {
  595. if ((*it)->getType() == LLAssetType::AT_LSL_TEXT)
  596. {
  597. LLViewerObject* object = gObjectList.findObject(viewer_obj->getID());
  598. if (object)
  599. {
  600. LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
  601. logMessage(getString("resetting") + " " + item->getName());
  602. LLMessageSystem* msg = gMessageSystemp;
  603. msg->newMessageFast(_PREHASH_ScriptReset);
  604. msg->nextBlockFast(_PREHASH_AgentData);
  605. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  606. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  607. msg->nextBlockFast(_PREHASH_Script);
  608. msg->addUUIDFast(_PREHASH_ObjectID, viewer_obj->getID());
  609. msg->addUUIDFast(_PREHASH_ItemID, (*it)->getUUID());
  610. msg->sendReliable(object->getRegion()->getHost());
  611. }
  612. }
  613. }
  614. nextObject();
  615. }
  616. ///////////////////////////////////////////////////////////////////////////////
  617. // Class LLFloaterRunQueue
  618. ///////////////////////////////////////////////////////////////////////////////
  619. //static
  620. LLFloaterRunQueue* LLFloaterRunQueue::create()
  621. {
  622. return new LLFloaterRunQueue();
  623. }
  624. LLFloaterRunQueue::LLFloaterRunQueue()
  625. : LLFloaterScriptQueue("run_title", "run_verb")
  626. {
  627. }
  628. void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj,
  629. LLInventoryObject::object_list_t* inv)
  630. {
  631. // find all of the LSL, leaving off duplicates. We will remove all matching
  632. // asset uuids on compilation success.
  633. for (LLInventoryObject::object_list_t::const_iterator it = inv->begin(),
  634. end = inv->end();
  635. it != end; ++it)
  636. {
  637. if ((*it)->getType() == LLAssetType::AT_LSL_TEXT)
  638. {
  639. LLViewerObject* object = gObjectList.findObject(viewer_obj->getID());
  640. if (object)
  641. {
  642. LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
  643. logMessage(getString("running") + " " + item->getName());
  644. LLMessageSystem* msg = gMessageSystemp;
  645. msg->newMessageFast(_PREHASH_SetScriptRunning);
  646. msg->nextBlockFast(_PREHASH_AgentData);
  647. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  648. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  649. msg->nextBlockFast(_PREHASH_Script);
  650. msg->addUUIDFast(_PREHASH_ObjectID, viewer_obj->getID());
  651. msg->addUUIDFast(_PREHASH_ItemID, (*it)->getUUID());
  652. msg->addBoolFast(_PREHASH_Running, true);
  653. msg->sendReliable(object->getRegion()->getHost());
  654. }
  655. }
  656. }
  657. nextObject();
  658. }
  659. ///////////////////////////////////////////////////////////////////////////////
  660. // Class LLFloaterStopQueue
  661. ///////////////////////////////////////////////////////////////////////////////
  662. //static
  663. LLFloaterStopQueue* LLFloaterStopQueue::create()
  664. {
  665. return new LLFloaterStopQueue();
  666. }
  667. LLFloaterStopQueue::LLFloaterStopQueue()
  668. : LLFloaterScriptQueue("stop_title", "stop_verb")
  669. {
  670. }
  671. void LLFloaterStopQueue::handleInventory(LLViewerObject* viewer_obj,
  672. LLInventoryObject::object_list_t* inv)
  673. {
  674. // find all of the lsl, leaving off duplicates. We'll remove
  675. // all matching asset uuids on compilation success.
  676. LLInventoryObject::object_list_t::const_iterator it = inv->begin();
  677. LLInventoryObject::object_list_t::const_iterator end = inv->end();
  678. for ( ; it != end; ++it)
  679. {
  680. if ((*it)->getType() == LLAssetType::AT_LSL_TEXT)
  681. {
  682. LLViewerObject* object = gObjectList.findObject(viewer_obj->getID());
  683. if (object)
  684. {
  685. LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)*it);
  686. logMessage(getString("stopping") + " " + item->getName());
  687. LLMessageSystem* msg = gMessageSystemp;
  688. msg->newMessageFast(_PREHASH_SetScriptRunning);
  689. msg->nextBlockFast(_PREHASH_AgentData);
  690. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  691. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  692. msg->nextBlockFast(_PREHASH_Script);
  693. msg->addUUIDFast(_PREHASH_ObjectID, viewer_obj->getID());
  694. msg->addUUIDFast(_PREHASH_ItemID, (*it)->getUUID());
  695. msg->addBoolFast(_PREHASH_Running, false);
  696. msg->sendReliable(object->getRegion()->getHost());
  697. }
  698. }
  699. }
  700. nextObject();
  701. }