diff options
author | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
commit | 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch) | |
tree | bcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llpreviewnotecard.cpp | |
parent | Second Life viewer sources 1.13.3.2 (diff) | |
download | meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2 meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz |
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llpreviewnotecard.cpp | 81 |
1 files changed, 66 insertions, 15 deletions
diff --git a/linden/indra/newview/llpreviewnotecard.cpp b/linden/indra/newview/llpreviewnotecard.cpp index da8b9fc..fe5ade2 100644 --- a/linden/indra/newview/llpreviewnotecard.cpp +++ b/linden/indra/newview/llpreviewnotecard.cpp | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "llinventory.h" | 32 | #include "llinventory.h" |
33 | 33 | ||
34 | #include "llagent.h" | 34 | #include "llagent.h" |
35 | #include "llassetuploadresponders.h" | ||
35 | #include "llviewerwindow.h" | 36 | #include "llviewerwindow.h" |
36 | #include "llbutton.h" | 37 | #include "llbutton.h" |
37 | #include "llinventorymodel.h" | 38 | #include "llinventorymodel.h" |
@@ -110,8 +111,12 @@ LLPreviewNotecard::LLPreviewNotecard(const std::string& name, | |||
110 | } | 111 | } |
111 | } | 112 | } |
112 | 113 | ||
113 | reshape(curRect.getWidth(), curRect.getHeight(), TRUE); | 114 | // only assert shape if not hosted in a multifloater |
114 | setRect(curRect); | 115 | if (!getHost()) |
116 | { | ||
117 | reshape(curRect.getWidth(), curRect.getHeight(), TRUE); | ||
118 | setRect(curRect); | ||
119 | } | ||
115 | 120 | ||
116 | childSetVisible("lock", FALSE); | 121 | childSetVisible("lock", FALSE); |
117 | 122 | ||
@@ -142,6 +147,7 @@ BOOL LLPreviewNotecard::postBuild() | |||
142 | if (ed) | 147 | if (ed) |
143 | { | 148 | { |
144 | ed->setNotecardInfo(mNotecardItemID, mObjectID); | 149 | ed->setNotecardInfo(mNotecardItemID, mObjectID); |
150 | ed->makePristine(); | ||
145 | } | 151 | } |
146 | return TRUE; | 152 | return TRUE; |
147 | } | 153 | } |
@@ -234,6 +240,22 @@ const LLInventoryItem* LLPreviewNotecard::getDragItem() | |||
234 | return NULL; | 240 | return NULL; |
235 | } | 241 | } |
236 | 242 | ||
243 | bool LLPreviewNotecard::hasEmbeddedInventory() | ||
244 | { | ||
245 | LLViewerTextEditor* editor = NULL; | ||
246 | editor = LLViewerUICtrlFactory::getViewerTextEditorByName( | ||
247 | this, | ||
248 | "Notecard Editor"); | ||
249 | if (!editor) return false; | ||
250 | return editor->hasEmbeddedInventory(); | ||
251 | } | ||
252 | |||
253 | void LLPreviewNotecard::refreshFromInventory() | ||
254 | { | ||
255 | lldebugs << "LLPreviewNotecard::refreshFromInventory()" << llendl; | ||
256 | loadAsset(); | ||
257 | } | ||
258 | |||
237 | void LLPreviewNotecard::loadAsset() | 259 | void LLPreviewNotecard::loadAsset() |
238 | { | 260 | { |
239 | // request the asset. | 261 | // request the asset. |
@@ -337,7 +359,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, | |||
337 | S32 file_length = file.getSize(); | 359 | S32 file_length = file.getSize(); |
338 | 360 | ||
339 | char* buffer = new char[file_length+1]; | 361 | char* buffer = new char[file_length+1]; |
340 | file.read((U8*)buffer, file_length); | 362 | file.read((U8*)buffer, file_length); /*Flawfinder: ignore*/ |
341 | 363 | ||
342 | // put a EOS at the end | 364 | // put a EOS at the end |
343 | buffer[file_length] = 0; | 365 | buffer[file_length] = 0; |
@@ -363,7 +385,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, | |||
363 | LLInventoryItem* item = preview->getItem(); | 385 | LLInventoryItem* item = preview->getItem(); |
364 | BOOL modifiable = item && gAgent.allowOperation(PERM_MODIFY, | 386 | BOOL modifiable = item && gAgent.allowOperation(PERM_MODIFY, |
365 | item->getPermissions(), GP_OBJECT_MANIPULATE); | 387 | item->getPermissions(), GP_OBJECT_MANIPULATE); |
366 | previewEditor->setEnabled(modifiable); | 388 | preview->setEnabled(modifiable); |
367 | delete[] buffer; | 389 | delete[] buffer; |
368 | preview->mAssetStatus = PREVIEW_ASSET_LOADED; | 390 | preview->mAssetStatus = PREVIEW_ASSET_LOADED; |
369 | } | 391 | } |
@@ -468,14 +490,43 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem) | |||
468 | LLInventoryItem* item = getItem(); | 490 | LLInventoryItem* item = getItem(); |
469 | // save it out to database | 491 | // save it out to database |
470 | if (item) | 492 | if (item) |
471 | { | 493 | { |
472 | 494 | std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory"); | |
473 | LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID, | 495 | std::string task_url = gAgent.getRegion()->getCapability("UpdateNotecardTaskInventory"); |
474 | tid, copyitem); | 496 | if (mObjectUUID.isNull() && !agent_url.empty()) |
475 | gAssetStorage->storeAssetData(tid, LLAssetType::AT_NOTECARD, | 497 | { |
476 | &onSaveComplete, | 498 | // Saving into agent inventory |
477 | (void*)info, | 499 | mAssetStatus = PREVIEW_ASSET_LOADING; |
478 | FALSE); | 500 | setEnabled(FALSE); |
501 | LLSD body; | ||
502 | body["item_id"] = mItemUUID; | ||
503 | llinfos << "Saving notecard " << mItemUUID | ||
504 | << " into agent inventory via " << agent_url << llendl; | ||
505 | LLHTTPClient::post(agent_url, body, | ||
506 | new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); | ||
507 | } | ||
508 | else if (!mObjectUUID.isNull() && !task_url.empty()) | ||
509 | { | ||
510 | // Saving into task inventory | ||
511 | mAssetStatus = PREVIEW_ASSET_LOADING; | ||
512 | setEnabled(FALSE); | ||
513 | LLSD body; | ||
514 | body["task_id"] = mObjectUUID; | ||
515 | body["item_id"] = mItemUUID; | ||
516 | llinfos << "Saving notecard " << mItemUUID << " into task " | ||
517 | << mObjectUUID << " via " << task_url << llendl; | ||
518 | LLHTTPClient::post(task_url, body, | ||
519 | new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD)); | ||
520 | } | ||
521 | else if (gAssetStorage) | ||
522 | { | ||
523 | LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID, | ||
524 | tid, copyitem); | ||
525 | gAssetStorage->storeAssetData(tid, LLAssetType::AT_NOTECARD, | ||
526 | &onSaveComplete, | ||
527 | (void*)info, | ||
528 | FALSE); | ||
529 | } | ||
479 | } | 530 | } |
480 | } | 531 | } |
481 | return true; | 532 | return true; |
@@ -551,10 +602,10 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data | |||
551 | gViewerWindow->alertXml("SaveNotecardFailReason",args); | 602 | gViewerWindow->alertXml("SaveNotecardFailReason",args); |
552 | } | 603 | } |
553 | 604 | ||
554 | char uuid_string[UUID_STR_LENGTH]; | 605 | char uuid_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ |
555 | asset_uuid.toString(uuid_string); | 606 | asset_uuid.toString(uuid_string); |
556 | char filename[LL_MAX_PATH]; | 607 | char filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ |
557 | sprintf(filename, "%s.tmp", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); | 608 | snprintf(filename, LL_MAX_PATH, "%s.tmp", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /*Flawfinder: ignore*/ |
558 | LLFile::remove(filename); | 609 | LLFile::remove(filename); |
559 | delete info; | 610 | delete info; |
560 | } | 611 | } |