llfloaterscriptqueue.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. * @file llfloaterscriptqueue.h
  3. * @brief LLFloaterScriptQueue class header file
  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. #ifndef LL_LLFLOATERSCRIPTQUEUE_H
  33. #define LL_LLFLOATERSCRIPTQUEUE_H
  34. #include "llfloater.h"
  35. #include "llinventory.h"
  36. #include "llscrolllistctrl.h"
  37. #include "llviewerinventory.h"
  38. #include "llviewerobject.h"
  39. #include "llvoinventorylistener.h"
  40. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. // Class LLFloaterScriptQueue
  42. //
  43. // This class provides a mechanism of adding objects to a list that will go
  44. // through and execute action for the scripts on each object. The objects will
  45. // be accessed serially and the scripts may be manipulated in parallel. For
  46. // example, selecting two objects each with three scripts will result in the
  47. // first object having all three scripts manipulated.
  48. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. class LLFloaterScriptQueue : public LLFloater, public LLVOInventoryListener
  50. {
  51. protected:
  52. LOG_CLASS(LLFloaterScriptQueue);
  53. public:
  54. // Returns true if the queue has started, otherwise false.
  55. bool start();
  56. void logMessage(const std::string& message);
  57. // Finds an instance by Id. Returns NULL if it does not exist.
  58. static LLFloaterScriptQueue* findInstance(const LLUUID& id);
  59. protected:
  60. LLFloaterScriptQueue(const std::string& title, const std::string& verb);
  61. ~LLFloaterScriptQueue() override;
  62. bool postBuild() override;
  63. // This is the callback method for the viewer object currently being worked
  64. // on.
  65. void inventoryChanged(LLViewerObject* obj,
  66. LLInventoryObject::object_list_t* inv,
  67. S32, void*) override;
  68. void requestInventory(LLViewerObject* objectp);
  69. // This is called by inventoryChanged
  70. virtual void handleInventory(LLViewerObject* viewer_obj,
  71. LLInventoryObject::object_list_t* inv) = 0;
  72. static void onCloseBtn(void* user_data);
  73. // Returns true if this is done
  74. LL_INLINE bool isDone() const
  75. {
  76. return mCurrentObjectID.isNull() && mObjectIDs.size() == 0;
  77. }
  78. virtual bool startQueue();
  79. // Goes to the next object.
  80. bool nextObject();
  81. // Get this instances ID.
  82. LL_INLINE const LLUUID& getID() const { return mID; }
  83. protected:
  84. LLScrollListCtrl* mMessages;
  85. LLButton* mCloseBtn;
  86. std::string mVerb;
  87. LLUUID mID;
  88. uuid_vec_t mObjectIDs;
  89. LLUUID mCurrentObjectID;
  90. bool mDone;
  91. typedef fast_hmap<LLUUID, LLFloaterScriptQueue*> instances_map_t;
  92. static instances_map_t sInstances;
  93. };
  94. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. // Class LLFloaterCompileQueue
  96. //
  97. // This script queue recompiles each script in selection.
  98. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  99. struct LLCompileQueueData
  100. {
  101. LLUUID mQueueID;
  102. LLUUID mItemId;
  103. LLCompileQueueData(const LLUUID& q_id, const LLUUID& item_id)
  104. : mQueueID(q_id),
  105. mItemId(item_id)
  106. {
  107. }
  108. };
  109. class LLFloaterCompileQueue final : public LLFloaterScriptQueue
  110. {
  111. protected:
  112. LOG_CLASS(LLFloaterCompileQueue);
  113. public:
  114. // Use this method to create a compile queue. Once created, it
  115. // will be responsible for it's own destruction.
  116. static LLFloaterCompileQueue* create(bool mono);
  117. // Remove any object in mCurrentScripts with the matching uuid.
  118. void removeItemByItemID(const LLUUID& item_id);
  119. void experienceIdsReceived(const LLSD& content);
  120. bool hasExperience(const LLUUID& id) const;
  121. protected:
  122. LLFloaterCompileQueue();
  123. ~LLFloaterCompileQueue() override = default;
  124. // This is called by inventoryChanged
  125. void handleInventory(LLViewerObject* viewer_obj,
  126. LLInventoryObject::object_list_t* inv) override;
  127. bool startQueue() override;
  128. static void finishLSLUpload(LLUUID item_id, LLUUID task_id,
  129. LLUUID new_asset_id, LLSD response,
  130. std::string script_name, LLUUID queue_id);
  131. // This is the callback for when each script arrives
  132. static void scriptArrived(const LLUUID& asset_id, LLAssetType::EType type,
  133. void* user_data, S32 status, LLExtStat);
  134. static void requestAsset(struct LLScriptQueueData* datap,
  135. const LLSD& experience);
  136. static void processExperienceIdResults(LLSD result, LLUUID queue_id);
  137. protected:
  138. LLViewerInventoryItem::item_array_t mCurrentScripts;
  139. private:
  140. uuid_list_t mExperienceIds;
  141. bool mMono; // Compile to mono.
  142. };
  143. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144. // Class LLFloaterResetQueue
  145. //
  146. // This script queue resets each script in selection.
  147. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  148. class LLFloaterResetQueue final : public LLFloaterScriptQueue
  149. {
  150. public:
  151. // Use this method to create a reset queue. Once created, it
  152. // will be responsible for it's own destruction.
  153. static LLFloaterResetQueue* create();
  154. protected:
  155. LLFloaterResetQueue();
  156. ~LLFloaterResetQueue() override = default;
  157. // This is called by inventoryChanged
  158. void handleInventory(LLViewerObject* viewer_obj,
  159. LLInventoryObject::object_list_t* inv) override;
  160. };
  161. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  162. // Class LLFloaterRunQueue
  163. //
  164. // This script queue runs each script in selection.
  165. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  166. class LLFloaterRunQueue final : public LLFloaterScriptQueue
  167. {
  168. public:
  169. // Use this method to create a run queue. Once created, it
  170. // will be responsible for it's own destruction.
  171. static LLFloaterRunQueue* create();
  172. protected:
  173. LLFloaterRunQueue();
  174. ~LLFloaterRunQueue() override = default;
  175. // This is called by inventoryChanged
  176. void handleInventory(LLViewerObject* viewer_obj,
  177. LLInventoryObject::object_list_t* inv) override;
  178. };
  179. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  180. // Class LLFloaterStopQueue
  181. //
  182. // This script queue stops each script in selection.
  183. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  184. class LLFloaterStopQueue final : public LLFloaterScriptQueue
  185. {
  186. public:
  187. // Use this method to create a not run queue. Once created, it
  188. // will be responsible for it's own destruction.
  189. static LLFloaterStopQueue* create();
  190. protected:
  191. LLFloaterStopQueue();
  192. ~LLFloaterStopQueue() override = default;
  193. // This is called by inventoryChanged
  194. void handleInventory(LLViewerObject* viewer_obj,
  195. LLInventoryObject::object_list_t* inv) override;
  196. };
  197. #endif // LL_LLFLOATERSCRIPTQUEUE_H