llcompilequeue.cpp

Go to the documentation of this file.
00001 
00040 #include "llviewerprecompiledheaders.h"
00041 
00042 #include "llcompilequeue.h"
00043 
00044 #include "llagent.h"
00045 #include "llchat.h"
00046 #include "llviewerwindow.h"
00047 #include "llcallbacklist.h"
00048 #include "llviewerobject.h"
00049 #include "llviewerobjectlist.h"
00050 #include "llviewerregion.h"
00051 #include "lscript_rt_interface.h"
00052 #include "llviewercontrol.h"
00053 #include "llviewerobject.h"
00054 #include "llviewerregion.h"
00055 #include "llresmgr.h"
00056 #include "llbutton.h"
00057 #include "lldir.h"
00058 #include "llfloaterchat.h"
00059 #include "llviewerstats.h"
00060 #include "llvieweruictrlfactory.h"
00061 
00065 
00066 // *TODO:Translate
00067 const char* COMPILE_QUEUE_TITLE = "Recompilation Progress";
00068 const char* COMPILE_START_STRING = "recompile";
00069 const char* RESET_QUEUE_TITLE = "Reset Progress";
00070 const char* RESET_START_STRING = "reset";
00071 const char* RUN_QUEUE_TITLE = "Set Running Progress";
00072 const char* RUN_START_STRING = "set running";
00073 const char* NOT_RUN_QUEUE_TITLE = "Set Not Running Progress";
00074 const char* NOT_RUN_START_STRING = "set not running";
00075 
00076 struct LLCompileQueueData
00077 {
00078         LLUUID mQueueID;
00079         LLUUID mOldAssetID;
00080         LLCompileQueueData(const LLUUID& q_id, const LLUUID& old_asset_id) :
00081                 mQueueID(q_id), mOldAssetID(old_asset_id) {}
00082 };
00083 
00084 struct LLScriptQueueData
00085 {
00086         LLUUID mQueueID;
00087         LLString mScriptName;
00088         LLScriptQueueData(const LLUUID& q_id, const char* name) :
00089                 mQueueID(q_id), mScriptName(name) {}
00090 };
00091 
00095 
00096 // static
00097 LLMap<LLUUID, LLFloaterScriptQueue*> LLFloaterScriptQueue::sInstances;
00098 
00099 
00100 // Default constructor
00101 LLFloaterScriptQueue::LLFloaterScriptQueue(const std::string& name,
00102                                                                                          const LLRect& rect,
00103                                                                                          const char* title,
00104                                                                                          const char* start_string) :
00105         LLFloater(name, rect, title,
00106                           RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT,
00107                           DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES)
00108 {
00109 
00110         gUICtrlFactory->buildFloater(this,"floater_script_queue.xml");
00111 
00112         childSetAction("close",onCloseBtn,this);
00113         childSetEnabled("close",FALSE);
00114 
00115         setTitle(title);
00116         
00117         if (!getHost())
00118         {
00119                 LLRect curRect = getRect();
00120                 translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
00121         }
00122         
00123         mStartString = start_string;
00124         mDone = FALSE;
00125         sInstances.addData(mID, this);
00126 }
00127 
00128 // Destroys the object
00129 LLFloaterScriptQueue::~LLFloaterScriptQueue()
00130 {
00131         sInstances.removeData(mID);
00132 }
00133 
00134 // find an instance by ID. Return NULL if it does not exist.
00135 // static
00136 LLFloaterScriptQueue* LLFloaterScriptQueue::findInstance(const LLUUID& id)
00137 {
00138         if(sInstances.checkData(id))
00139         {
00140                 return sInstances.getData(id);
00141         }
00142         return NULL;
00143 }
00144 
00145 
00146 // This is the callback method for the viewer object currently being
00147 // worked on.
00148 // NOT static, virtual!
00149 void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object,
00150                                                                                          InventoryObjectList* inv,
00151                                                                                          S32,
00152                                                                                          void* q_id)
00153 {
00154         llinfos << "LLFloaterScriptQueue::inventoryChanged() for  object "
00155                         << viewer_object->getID() << llendl;
00156 
00157         //Remove this listener from the object since its
00158         //listener callback is now being executed.
00159         
00160         //We remove the listener here because the function
00161         //removeVOInventoryListener removes the listener from a ViewerObject
00162         //which it internally stores.
00163         
00164         //If we call this further down in the function, calls to handleInventory
00165         //and nextObject may update the interally stored viewer object causing
00166         //the removal of the incorrect listener from an incorrect object.
00167         
00168         //Fixes SL-6119:Recompile scripts fails to complete
00169         removeVOInventoryListener();
00170 
00171         if (viewer_object && inv && (viewer_object->getID() == mCurrentObjectID) )
00172         {
00173                 handleInventory(viewer_object, inv);
00174         }
00175         else
00176         {
00177                 // something went wrong...
00178                 // note that we're not working on this one, and move onto the
00179                 // next object in the list.
00180                 llwarns << "No inventory for " << mCurrentObjectID
00181                                 << llendl;
00182                 nextObject();
00183         }
00184 }
00185 
00186 
00187 // static
00188 void LLFloaterScriptQueue::onCloseBtn(void* user_data)
00189 {
00190         LLFloaterScriptQueue* self = (LLFloaterScriptQueue*)user_data;
00191         self->close();
00192 }
00193 
00194 void LLFloaterScriptQueue::addObject(const LLUUID& id)
00195 {
00196         mObjectIDs.put(id);
00197 }
00198 
00199 BOOL LLFloaterScriptQueue::start()
00200 {
00201         //llinfos << "LLFloaterCompileQueue::start()" << llendl;
00202         char buffer[MAX_STRING];                                /*Flawfinder: ignore*/
00203         snprintf(buffer, sizeof(buffer), "Starting %s of %d items.", mStartString, mObjectIDs.count());                 /* Flawfinder: ignore */
00204         
00205         LLScrollListCtrl* list = LLUICtrlFactory::getScrollListByName(this, "queue output");
00206         list->addSimpleItem(buffer);
00207 
00208         return nextObject();
00209 }
00210 
00211 BOOL LLFloaterScriptQueue::isDone() const
00212 {
00213         return (mCurrentObjectID.isNull() && (mObjectIDs.count() == 0));
00214 }
00215 
00216 // go to the next object. If no objects left, it falls out silently
00217 // and waits to be killed by the window being closed.
00218 BOOL LLFloaterScriptQueue::nextObject()
00219 {
00220         S32 count;
00221         BOOL successful_start = FALSE;
00222         do
00223         {
00224                 count = mObjectIDs.count();
00225                 llinfos << "LLFloaterScriptQueue::nextObject() - " << count
00226                                 << " objects left to process." << llendl;
00227                 mCurrentObjectID.setNull();
00228                 if(count > 0)
00229                 {
00230                         successful_start = popNext();
00231                 }
00232                 llinfos << "LLFloaterScriptQueue::nextObject() "
00233                                 << (successful_start ? "successful" : "unsuccessful")
00234                                 << llendl; 
00235         } while((mObjectIDs.count() > 0) && !successful_start);
00236         if(isDone() && !mDone)
00237         {
00238                 
00239                 LLScrollListCtrl* list = LLUICtrlFactory::getScrollListByName(this, "queue output");
00240 
00241                 mDone = TRUE;
00242                 char buffer[MAX_STRING];                /*Flawfinder: ignore*/
00243                 snprintf(buffer, sizeof(buffer), "Done.");                              /* Flawfinder: ignore */
00244                 list->addSimpleItem(buffer);
00245                 childSetEnabled("close",TRUE);
00246         }
00247         return successful_start;
00248 }
00249 
00250 // returns true if the queue has started, otherwise false.  This
00251 // method pops the top object off of the queue.
00252 BOOL LLFloaterScriptQueue::popNext()
00253 {
00254         // get the first element off of the container, and attempt to get
00255         // the inventory.
00256         BOOL rv = FALSE;
00257         S32 count = mObjectIDs.count();
00258         if(mCurrentObjectID.isNull() && (count > 0))
00259         {
00260                 mCurrentObjectID = mObjectIDs.get(0);
00261                 llinfos << "LLFloaterScriptQueue::popNext() - mCurrentID: "
00262                                 << mCurrentObjectID << llendl;
00263                 mObjectIDs.remove(0);
00264                 LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID);
00265                 if(obj)
00266                 {
00267                         llinfos << "LLFloaterScriptQueue::popNext() requesting inv for "
00268                                         << mCurrentObjectID << llendl;
00269                         LLUUID* id = new LLUUID(mID);
00270                         registerVOInventoryListener(obj,id);
00271                         requestVOInventory();
00272                         rv = TRUE;
00273                 }
00274         }
00275         return rv;
00276 }
00277 
00278 
00282 
00283 // static
00284 LLFloaterCompileQueue* LLFloaterCompileQueue::create()
00285 {
00286         S32 left, top;
00287         gFloaterView->getNewFloaterPosition(&left, &top);
00288         LLRect rect = gSavedSettings.getRect("CompileOutputRect");
00289         rect.translate(left - rect.mLeft, top - rect.mTop);
00290         LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue",
00291                                                                                                                                  rect);
00292         new_queue->open();              /*Flawfinder: ignore*/ 
00293         return new_queue;
00294 }
00295 
00296 LLFloaterCompileQueue::LLFloaterCompileQueue(const std::string& name, const LLRect& rect)
00297 : LLFloaterScriptQueue(name, rect, COMPILE_QUEUE_TITLE, COMPILE_START_STRING)
00298 { }
00299 
00300 LLFloaterCompileQueue::~LLFloaterCompileQueue()
00301 { 
00302 }
00303 
00304 void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
00305                                                                                         InventoryObjectList* inv)
00306 {
00307         // find all of the lsl, leaving off duplicates. We'll remove
00308         // all matching asset uuids on compilation success.
00309 
00310         typedef std::map<LLUUID, LLPointer<LLInventoryItem> > uuid_item_map;
00311         uuid_item_map asset_item_map;
00312 
00313         InventoryObjectList::const_iterator it = inv->begin();
00314         InventoryObjectList::const_iterator end = inv->end();
00315         for ( ; it != end; ++it)
00316         {
00317                 if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
00318                 {
00319                         LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
00320                         // Check permissions before allowing the user to retrieve data.
00321                         if (item->getPermissions().allowModifyBy(gAgent.getID())  &&
00322                                 item->getPermissions().allowCopyBy(gAgent.getID()) )
00323                         {
00324                                 LLPointer<LLViewerInventoryItem> script = new LLViewerInventoryItem(item);
00325                                 mCurrentScripts.put(script);
00326 
00327                                 if (!asset_item_map.count(item->getAssetUUID()))
00328                                 {
00329                                         // No entry, put in an entry for this supposedly permissive script
00330                                         asset_item_map[item->getAssetUUID()] = item;
00331                                 }
00332                         }
00333                 }
00334         }
00335 
00336         if (asset_item_map.empty())
00337         {
00338                 // There are no scripts in this object.  move on.
00339                 nextObject();
00340         }
00341         else
00342         {
00343                 // request all of the assets.
00344                 uuid_item_map::iterator iter;
00345                 for(iter = asset_item_map.begin(); iter != asset_item_map.end(); iter++)
00346                 {
00347                         LLInventoryItem *itemp = iter->second;
00348                         LLScriptQueueData* datap = new LLScriptQueueData(getID(), itemp->getName().c_str());
00349 
00350                         //llinfos << "ITEM NAME 2: " << names.get(i) << llendl;
00351                         gAssetStorage->getInvItemAsset(viewer_object->getRegion()->getHost(),
00352                                 gAgent.getID(),
00353                                 gAgent.getSessionID(),
00354                                 itemp->getPermissions().getOwner(),
00355                                 viewer_object->getID(),
00356                                 itemp->getUUID(),
00357                                 itemp->getAssetUUID(),
00358                                 itemp->getType(),
00359                                 LLFloaterCompileQueue::scriptArrived,
00360                                 (void*)datap);
00361                 }
00362         }
00363 }
00364 
00365 
00366 // This is the callback for when each script arrives
00367 // static
00368 void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
00369                                                                                   LLAssetType::EType type,
00370                                                                                   void* user_data, S32 status, LLExtStat ext_status)
00371 {
00372         llinfos << "LLFloaterCompileQueue::scriptArrived()" << llendl;
00373         LLScriptQueueData* data = (LLScriptQueueData*)user_data;
00374         if(!data) return;
00375         LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*> 
00376                                 (LLFloaterScriptQueue::findInstance(data->mQueueID));
00377         char buffer[MAX_STRING];                /*Flawfinder: ignore*/  
00378         buffer[0] = '\0';
00379         if(queue && (0 == status))
00380         {
00381                 //llinfos << "ITEM NAME 3: " << data->mScriptName << llendl;
00382 
00383                 // Dump this into a file on the local disk so we can compile it.
00384                 char filename[LL_MAX_PATH] = "";                /*Flawfinder: ignore*/
00385                 LLVFile file(vfs, asset_id, type);
00386                 char uuid_str[UUID_STR_LENGTH];         /*Flawfinder: ignore*/
00387                 asset_id.toString(uuid_str);
00388                 snprintf(filename, sizeof(filename), "%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type));         /* Flawfinder: ignore */
00389 
00390                 FILE *fp = LLFile::fopen(filename, "wb");        /*Flawfinder: ignore*/
00391                 if (fp)
00392                 {
00393                         const S32 buf_size = 65536;
00394                         U8 copy_buf[buf_size];
00395                         while (file.read(copy_buf, buf_size))    /*Flawfinder: ignore*/
00396                         {
00397                                 if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1)
00398                                 {
00399                                         // return a bad file error if we can't write the whole thing
00400                                         status = LL_ERR_CANNOT_OPEN_FILE;
00401                                 }
00402                         }
00403 
00404                         fclose(fp);
00405                 }
00406 
00407                 // It's now in the file, now compile it.
00408                 snprintf(buffer, sizeof(buffer), "Downloaded, now compiling '%s'.", data->mScriptName.c_str());         /* Flawfinder: ignore */
00409                 queue->compile(filename, asset_id);
00410 
00411                 // Delete it after we're done compiling?
00412                 LLFile::remove(filename);
00413         }
00414         else
00415         {
00416                 if( gViewerStats )
00417                 {
00418                         gViewerStats->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
00419                 }
00420 
00421                 if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
00422                 {
00423                         LLChat chat("Script not found on server.");
00424                         LLFloaterChat::addChat(chat);
00425                         snprintf(buffer, sizeof(buffer), "Problem downloading %s.",     /* Flawfinder: ignore */
00426                                 data->mScriptName.c_str());
00427                 }
00428                 else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status)
00429                 {
00430                         LLChat chat("Insufficient permissions to download a script.");
00431                         LLFloaterChat::addChat(chat);
00432                         snprintf(buffer, sizeof(buffer), "Insufficient permissions for '%s'.",  /* Flawfinder: ignore */
00433                                 data->mScriptName.c_str());
00434                 }
00435                 else
00436                 {
00437                         snprintf(buffer, sizeof(buffer), "Unknown failure to download %s.",     /* Flawfinder: ignore */
00438                                 data->mScriptName.c_str());
00439                 }
00440 
00441                 llwarns << "Problem downloading script asset." << llendl;
00442                 if(queue) queue->removeItemByAssetID(asset_id);
00443         }
00444         if(queue) 
00445         {
00446                 LLScrollListCtrl* list = LLUICtrlFactory::getScrollListByName(queue, "queue output");
00447                 list->addSimpleItem(buffer);
00448         }
00449         delete data;
00450 }
00451 
00452 // static
00453 void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
00454 {
00455         llinfos << "LLFloaterCompileQueue::onSaveTextComplete()" << llendl;
00456         if (status)
00457         {
00458                 llwarns << "Unable to save text for script." << llendl;
00459                 LLString::format_map_t args;
00460                 args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status));
00461                 gViewerWindow->alertXml("CompileQueueSaveText", args);
00462         }
00463 }
00464 
00465 // static
00466 void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
00467 {
00468         llinfos << "LLFloaterCompileQueue::onSaveBytecodeComplete()" << llendl;
00469         LLCompileQueueData* data = (LLCompileQueueData*)user_data;
00470         LLFloaterCompileQueue* queue = static_cast<LLFloaterCompileQueue*> 
00471                                 (LLFloaterScriptQueue::findInstance(data->mQueueID));
00472         if(queue && (0 == status) && data)
00473         {
00474                 queue->updateAssetID(data->mOldAssetID, asset_id);
00475                 queue->saveItemByAssetID(asset_id);
00476                 queue->removeItemByAssetID(asset_id);
00477         }
00478         else
00479         {
00480                 llwarns << "Unable to save bytecode for script." << llendl;
00481                 LLStringBase<char>::format_map_t args;
00482                 args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status));
00483                 gViewerWindow->alertXml("CompileQueueSaveBytecode", args);
00484         }
00485         delete data;
00486         data = NULL;
00487 }
00488 
00489 // compile the file given and save it out.
00490 void LLFloaterCompileQueue::compile(const char* filename,
00491                                                                         const LLUUID& asset_id)
00492 {
00493         LLUUID new_asset_id;
00494         LLTransactionID tid;
00495         tid.generate();
00496         new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
00497         
00498         char uuid_string[UUID_STR_LENGTH];  /*Flawfinder: ignore*/
00499         new_asset_id.toString(uuid_string);
00500         char dst_filename[LL_MAX_PATH];  /*Flawfinder: ignore*/
00501         snprintf(dst_filename, sizeof(dst_filename), "%s.lso", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str());              /* Flawfinder: ignore */
00502         char err_filename[LL_MAX_PATH];  /*Flawfinder: ignore*/
00503         snprintf(err_filename, sizeof(err_filename), "%s.out", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str());              /* Flawfinder: ignore */
00504 
00505         gAssetStorage->storeAssetData(filename, tid,
00506                                                                   LLAssetType::AT_LSL_TEXT,
00507                                                                   &onSaveTextComplete, NULL, FALSE);
00508         if(!lscript_compile(filename, dst_filename, err_filename, gAgent.isGodlike()))
00509         {
00510                 llwarns << "compile failed" << llendl;
00511                 removeItemByAssetID(asset_id);
00512         }
00513         else
00514         {
00515                 llinfos << "compile successful." << llendl;
00516                 // Save the bytecode
00517                 LLCompileQueueData* data = new LLCompileQueueData(mID, asset_id);
00518                 gAssetStorage->storeAssetData(dst_filename, tid,
00519                                                                           LLAssetType::AT_LSL_BYTECODE,
00520                                                                           &onSaveBytecodeComplete,
00521                                                                           (void*)data, FALSE);
00522         }
00523 }
00524 
00525 void LLFloaterCompileQueue::removeItemByAssetID(const LLUUID& asset_id)
00526 {
00527         llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl;
00528         for(S32 i = 0; i < mCurrentScripts.count(); )
00529         {
00530                 if(asset_id == mCurrentScripts.get(i)->getAssetUUID())
00531                 {
00532                         mCurrentScripts.remove(i);
00533                 }
00534                 else
00535                 {
00536                         ++i;
00537                 }
00538         }
00539         if(mCurrentScripts.count() == 0)
00540         {
00541                 nextObject();
00542         }
00543 }
00544 
00545 void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id)
00546 {
00547         llinfos << "LLFloaterCompileQueue::saveItemByAssetID()" << llendl;
00548         LLViewerObject* viewer_object = gObjectList.findObject(mCurrentObjectID);
00549         if(viewer_object)
00550         {
00551                 S32 count = mCurrentScripts.count();
00552                 for(S32 i = 0; i < count; ++i)
00553                 {
00554                         if(asset_id == mCurrentScripts.get(i)->getAssetUUID())
00555                         {
00556                                 // *FIX: this auto-resets active to TRUE. That might
00557                                 // be a bad idea.
00558                                 viewer_object->saveScript(mCurrentScripts.get(i), TRUE, false);
00559                         }
00560                 }
00561         }
00562         else
00563         {
00564                 llwarns << "Unable to finish save!" << llendl;
00565         }
00566 }
00567 
00568 // find old_asst_id, and set the asset id to new_asset_id
00569 void LLFloaterCompileQueue::updateAssetID(const LLUUID& old_asset_id,
00570                                                                                   const LLUUID& new_asset_id)
00571 {
00572         S32 count = mCurrentScripts.count();
00573         for(S32 i = 0; i < count; ++i)
00574         {
00575                 if(old_asset_id == mCurrentScripts.get(i)->getAssetUUID())
00576                 {
00577                         mCurrentScripts.get(i)->setAssetUUID(new_asset_id);
00578                 }
00579         }
00580 }
00581 
00585 
00586 // static
00587 LLFloaterResetQueue* LLFloaterResetQueue::create()
00588 {
00589         S32 left, top;
00590         gFloaterView->getNewFloaterPosition(&left, &top);
00591         LLRect rect = gSavedSettings.getRect("CompileOutputRect");
00592         rect.translate(left - rect.mLeft, top - rect.mTop);
00593         LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue",
00594                                                                                                                                  rect);
00595         new_queue->open();       /*Flawfinder: ignore*/
00596         return new_queue;
00597 }
00598 
00599 LLFloaterResetQueue::LLFloaterResetQueue(const std::string& name, const LLRect& rect)
00600 : LLFloaterScriptQueue(name, rect, RESET_QUEUE_TITLE, RESET_START_STRING)
00601 { }
00602 
00603 LLFloaterResetQueue::~LLFloaterResetQueue()
00604 { 
00605 }
00606 
00607 void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj,
00608                                                                                   InventoryObjectList* inv)
00609 {
00610         // find all of the lsl, leaving off duplicates. We'll remove
00611         // all matching asset uuids on compilation success.
00612         LLDynamicArray<const char*> names;
00613         
00614         InventoryObjectList::const_iterator it = inv->begin();
00615         InventoryObjectList::const_iterator end = inv->end();
00616         for ( ; it != end; ++it)
00617         {
00618                 if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
00619                 {
00620                         LLViewerObject* object = gObjectList.findObject(viewer_obj->getID());
00621 
00622                         if (object)
00623                         {
00624                                 LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
00625                                 LLScrollListCtrl* list = LLUICtrlFactory::getScrollListByName(this, "queue output");
00626                                 char buffer[MAX_STRING];                 /*Flawfinder: ignore*/
00627                                 snprintf(buffer, sizeof(buffer), "Resetting '%s'.", item->getName().c_str());                   /* Flawfinder: ignore */
00628                                 list->addSimpleItem(buffer);
00629                                 LLMessageSystem* msg = gMessageSystem;
00630                                 msg->newMessageFast(_PREHASH_ScriptReset);
00631                                 msg->nextBlockFast(_PREHASH_AgentData);
00632                                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00633                                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00634                                 msg->nextBlockFast(_PREHASH_Script);
00635                                 msg->addUUIDFast(_PREHASH_ObjectID, viewer_obj->getID());
00636                                 msg->addUUIDFast(_PREHASH_ItemID, (*it)->getUUID());
00637                                 msg->sendReliable(object->getRegion()->getHost());
00638                         }
00639                 }
00640         }
00641 
00642         nextObject();   
00643 }
00644 
00648 
00649 // static
00650 LLFloaterRunQueue* LLFloaterRunQueue::create()
00651 {
00652         S32 left, top;
00653         gFloaterView->getNewFloaterPosition(&left, &top);
00654         LLRect rect = gSavedSettings.getRect("CompileOutputRect");
00655         rect.translate(left - rect.mLeft, top - rect.mTop);
00656         LLFloaterRunQueue* new_queue = new LLFloaterRunQueue("queue",
00657                                                                                                                                  rect);
00658         new_queue->open();               /*Flawfinder: ignore*/
00659         return new_queue;
00660 }
00661 
00662 LLFloaterRunQueue::LLFloaterRunQueue(const std::string& name, const LLRect& rect)
00663 : LLFloaterScriptQueue(name, rect, RUN_QUEUE_TITLE, RUN_START_STRING)
00664 { }
00665 
00666 LLFloaterRunQueue::~LLFloaterRunQueue()
00667 { 
00668 }
00669 
00670 void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj,
00671                                                                                   InventoryObjectList* inv)
00672 {
00673         // find all of the lsl, leaving off duplicates. We'll remove
00674         // all matching asset uuids on compilation success.
00675         LLDynamicArray<const char*> names;
00676         
00677         InventoryObjectList::const_iterator it = inv->begin();
00678         InventoryObjectList::const_iterator end = inv->end();
00679         for ( ; it != end; ++it)
00680         {
00681                 if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
00682                 {
00683                         LLViewerObject* object = gObjectList.findObject(viewer_obj->getID());
00684 
00685                         if (object)
00686                         {
00687                                 LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
00688                                 LLScrollListCtrl* list = LLUICtrlFactory::getScrollListByName(this, "queue output");
00689                                 char buffer[MAX_STRING];        /*Flawfinder: ignore*/
00690                                 snprintf(buffer, sizeof(buffer), "Running '%s'.", item->getName().c_str());                     /* Flawfinder: ignore */
00691                                 list->addSimpleItem(buffer);
00692 
00693                                 LLMessageSystem* msg = gMessageSystem;
00694                                 msg->newMessageFast(_PREHASH_SetScriptRunning);
00695                                 msg->nextBlockFast(_PREHASH_AgentData);
00696                                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00697                                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00698                                 msg->nextBlockFast(_PREHASH_Script);
00699                                 msg->addUUIDFast(_PREHASH_ObjectID, viewer_obj->getID());
00700                                 msg->addUUIDFast(_PREHASH_ItemID, (*it)->getUUID());
00701                                 msg->addBOOLFast(_PREHASH_Running, TRUE);
00702                                 msg->sendReliable(object->getRegion()->getHost());
00703                         }
00704                 }
00705         }
00706 
00707         nextObject();   
00708 }
00709 
00713 
00714 // static
00715 LLFloaterNotRunQueue* LLFloaterNotRunQueue::create()
00716 {
00717         S32 left, top;
00718         gFloaterView->getNewFloaterPosition(&left, &top);
00719         LLRect rect = gSavedSettings.getRect("CompileOutputRect");
00720         rect.translate(left - rect.mLeft, top - rect.mTop);
00721         LLFloaterNotRunQueue* new_queue = new LLFloaterNotRunQueue("queue",
00722                                                                                                                                  rect);
00723         new_queue->open();       /*Flawfinder: ignore*/
00724         return new_queue;
00725 }
00726 
00727 LLFloaterNotRunQueue::LLFloaterNotRunQueue(const std::string& name, const LLRect& rect)
00728 : LLFloaterScriptQueue(name, rect, NOT_RUN_QUEUE_TITLE, NOT_RUN_START_STRING)
00729 { }
00730 
00731 LLFloaterNotRunQueue::~LLFloaterNotRunQueue()
00732 { 
00733 }
00734 
00735 void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj,
00736                                                                                   InventoryObjectList* inv)
00737 {
00738         // find all of the lsl, leaving off duplicates. We'll remove
00739         // all matching asset uuids on compilation success.
00740         LLDynamicArray<const char*> names;
00741         
00742         InventoryObjectList::const_iterator it = inv->begin();
00743         InventoryObjectList::const_iterator end = inv->end();
00744         for ( ; it != end; ++it)
00745         {
00746                 if((*it)->getType() == LLAssetType::AT_LSL_TEXT)
00747                 {
00748                         LLViewerObject* object = gObjectList.findObject(viewer_obj->getID());
00749 
00750                         if (object)
00751                         {
00752                                 LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
00753                                 LLScrollListCtrl* list = LLUICtrlFactory::getScrollListByName(this, "queue output");
00754                                 char buffer[MAX_STRING];                 /*Flawfinder: ignore*/
00755                                 snprintf(buffer, sizeof(buffer), "Not running '%s'.", item->getName().c_str());         /* Flawfinder: ignore */
00756                                 list->addSimpleItem(buffer);
00757         
00758                                 LLMessageSystem* msg = gMessageSystem;
00759                                 msg->newMessageFast(_PREHASH_SetScriptRunning);
00760                                 msg->nextBlockFast(_PREHASH_AgentData);
00761                                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00762                                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00763                                 msg->nextBlockFast(_PREHASH_Script);
00764                                 msg->addUUIDFast(_PREHASH_ObjectID, viewer_obj->getID());
00765                                 msg->addUUIDFast(_PREHASH_ItemID, (*it)->getUUID());
00766                                 msg->addBOOLFast(_PREHASH_Running, FALSE);
00767                                 msg->sendReliable(object->getRegion()->getHost());
00768                         }
00769                 }
00770         }
00771 
00772         nextObject();   
00773 }
00774 

Generated on Thu Jul 1 06:08:22 2010 for Second Life Viewer by  doxygen 1.4.7