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