aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llassetuploadresponders.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llassetuploadresponders.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llassetuploadresponders.cpp132
1 files changed, 63 insertions, 69 deletions
diff --git a/linden/indra/newview/llassetuploadresponders.cpp b/linden/indra/newview/llassetuploadresponders.cpp
index 2691f71..2d40e94 100644
--- a/linden/indra/newview/llassetuploadresponders.cpp
+++ b/linden/indra/newview/llassetuploadresponders.cpp
@@ -34,6 +34,7 @@
34#include "llassetuploadresponders.h" 34#include "llassetuploadresponders.h"
35 35
36#include "llagent.h" 36#include "llagent.h"
37#include "llcompilequeue.h"
37#include "llfloaterbuycurrency.h" 38#include "llfloaterbuycurrency.h"
38#include "lleconomy.h" 39#include "lleconomy.h"
39#include "llfilepicker.h" 40#include "llfilepicker.h"
@@ -73,10 +74,12 @@ LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data,
73} 74}
74 75
75LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, 76LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data,
76 const std::string& file_name) 77 const std::string& file_name,
78 LLAssetType::EType asset_type)
77 : LLHTTPClient::Responder(), 79 : LLHTTPClient::Responder(),
78 mPostData(post_data), 80 mPostData(post_data),
79 mFileName(file_name) 81 mFileName(file_name),
82 mAssetType(asset_type)
80{ 83{
81} 84}
82 85
@@ -85,7 +88,7 @@ LLAssetUploadResponder::~LLAssetUploadResponder()
85 if (!mFileName.empty()) 88 if (!mFileName.empty())
86 { 89 {
87 // Delete temp file 90 // Delete temp file
88 LLFile::remove(mFileName.c_str()); 91 LLFile::remove(mFileName);
89 } 92 }
90} 93}
91 94
@@ -94,7 +97,7 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason)
94{ 97{
95 llinfos << "LLAssetUploadResponder::error " << statusNum 98 llinfos << "LLAssetUploadResponder::error " << statusNum
96 << " reason: " << reason << llendl; 99 << " reason: " << reason << llendl;
97 LLStringBase<char>::format_map_t args; 100 LLStringUtil::format_map_t args;
98 switch(statusNum) 101 switch(statusNum)
99 { 102 {
100 case 400: 103 case 400:
@@ -163,7 +166,7 @@ void LLAssetUploadResponder::uploadFailure(const LLSD& content)
163 } 166 }
164 else 167 else
165 { 168 {
166 LLStringBase<char>::format_map_t args; 169 LLStringUtil::format_map_t args;
167 args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); 170 args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName);
168 args["[REASON]"] = content["message"].asString(); 171 args["[REASON]"] = content["message"].asString();
169 gViewerWindow->alertXml("CannotUploadReason", args); 172 gViewerWindow->alertXml("CannotUploadReason", args);
@@ -181,8 +184,8 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data
181{ 184{
182} 185}
183 186
184LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name) 187LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name, LLAssetType::EType asset_type)
185: LLAssetUploadResponder(post_data, file_name) 188: LLAssetUploadResponder(post_data, file_name, asset_type)
186{ 189{
187} 190}
188 191
@@ -191,8 +194,8 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
191{ 194{
192 lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; 195 lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl;
193 196
194 LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString().c_str()); 197 LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString());
195 LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString().c_str()); 198 LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString());
196 199
197 // Update L$ and ownership credit information 200 // Update L$ and ownership credit information
198 // since it probably changed on the server 201 // since it probably changed on the server
@@ -208,7 +211,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
208 gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); 211 gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
209 gAgent.sendReliableMessage(); 212 gAgent.sendReliableMessage();
210 213
211 LLString::format_map_t args; 214 LLStringUtil::format_map_t args;
212 args["[AMOUNT]"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); 215 args["[AMOUNT]"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload());
213 LLNotifyBox::showXml("UploadPayment", args); 216 LLNotifyBox::showXml("UploadPayment", args);
214 } 217 }
@@ -275,27 +278,16 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
275 // *FIX: This is a pretty big hack. What this does is check the 278 // *FIX: This is a pretty big hack. What this does is check the
276 // file picker if there are any more pending uploads. If so, 279 // file picker if there are any more pending uploads. If so,
277 // upload that file. 280 // upload that file.
278 const char* next_file = LLFilePicker::instance().getNextFile(); 281 std::string next_file = LLFilePicker::instance().getNextFile();
279 if(next_file) 282 if(!next_file.empty())
280 { 283 {
281 const char* name = LLFilePicker::instance().getDirname(); 284 std::string name = gDirUtilp->getBaseFileName(next_file, true);
282
283 LLString asset_name = name;
284 LLString::replaceNonstandardASCII( asset_name, '?' );
285 LLString::replaceChar(asset_name, '|', '?');
286 LLString::stripNonprintable(asset_name);
287 LLString::trim(asset_name);
288 285
289 char* asset_name_str = (char*)asset_name.c_str(); 286 std::string asset_name = name;
290 char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists 287 LLStringUtil::replaceNonstandardASCII( asset_name, '?' );
291 if( !end_p ) 288 LLStringUtil::replaceChar(asset_name, '|', '?');
292 { 289 LLStringUtil::stripNonprintable(asset_name);
293 end_p = asset_name_str + strlen( asset_name_str ); /*Flawfinder: ignore*/ 290 LLStringUtil::trim(asset_name);
294 }
295
296 S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) );
297
298 asset_name = asset_name.substr( 0, len );
299 291
300 upload_new_resource(next_file, asset_name, asset_name, 292 upload_new_resource(next_file, asset_name, asset_name,
301 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); 293 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE);
@@ -311,8 +303,9 @@ LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& pos
311} 303}
312 304
313LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data, 305LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data,
314 const std::string& file_name) 306 const std::string& file_name,
315: LLAssetUploadResponder(post_data, file_name) 307 LLAssetType::EType asset_type)
308: LLAssetUploadResponder(post_data, file_name, asset_type)
316{ 309{
317} 310}
318 311
@@ -420,8 +413,17 @@ LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_
420} 413}
421 414
422LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, 415LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
423 const std::string& file_name) 416 const std::string& file_name,
424: LLAssetUploadResponder(post_data, file_name) 417 LLAssetType::EType asset_type)
418: LLAssetUploadResponder(post_data, file_name, asset_type)
419{
420}
421
422LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
423 const std::string& file_name,
424 const LLUUID& queue_id,
425 LLAssetType::EType asset_type)
426: LLAssetUploadResponder(post_data, file_name, asset_type), mQueueId(queue_id)
425{ 427{
426} 428}
427 429
@@ -432,35 +434,16 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
432 LLUUID item_id = mPostData["item_id"]; 434 LLUUID item_id = mPostData["item_id"];
433 LLUUID task_id = mPostData["task_id"]; 435 LLUUID task_id = mPostData["task_id"];
434 436
435 LLViewerObject* object = gObjectList.findObject(task_id);
436 if (!object)
437 {
438 llwarns << "LLUpdateTaskInventoryResponder::uploadComplete task " << task_id
439 << " no longer exist." << llendl;
440 return;
441 }
442 LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(item_id);
443 if (!item)
444 {
445 llwarns << "LLUpdateTaskInventoryResponder::uploadComplete item "
446 << item_id << " is no longer in task " << task_id
447 << "'s inventory." << llendl;
448 return;
449 }
450 LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
451 // Update Viewer inventory
452 object->updateViewerInventoryAsset(new_item, content["new_asset"]);
453 dialog_refresh_all(); 437 dialog_refresh_all();
454 438
455 LLInventoryType::EType inventory_type = new_item->getInventoryType(); 439 switch(mAssetType)
456 switch(inventory_type)
457 { 440 {
458 case LLInventoryType::IT_NOTECARD: 441 case LLAssetType::AT_NOTECARD:
459 { 442 {
460 443
461 // Update the UI with the new asset. 444 // Update the UI with the new asset.
462 LLPreviewNotecard* nc; 445 LLPreviewNotecard* nc;
463 nc = (LLPreviewNotecard*)LLPreview::find(new_item->getUUID()); 446 nc = (LLPreviewNotecard*)LLPreview::find(item_id);
464 if(nc) 447 if(nc)
465 { 448 {
466 // *HACK: we have to delete the asset in the VFS so 449 // *HACK: we have to delete the asset in the VFS so
@@ -480,28 +463,39 @@ void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
480 } 463 }
481 } 464 }
482 break; 465 break;
483 case LLInventoryType::IT_LSL: 466 case LLAssetType::AT_LSL_TEXT:
484 { 467 {
485 LLLiveLSLEditor* preview = LLLiveLSLEditor::find(item_id, task_id); 468 if(mQueueId.notNull())
486 if (preview)
487 { 469 {
488 // Bytecode save completed 470 LLFloaterCompileQueue* queue =
489 if (content["compiled"]) 471 (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId);
472 if(NULL != queue)
490 { 473 {
491 preview->callbackLSLCompileSucceeded( 474 queue->removeItemByItemID(item_id);
492 task_id,
493 item_id,
494 mPostData["is_script_running"]);
495 } 475 }
496 else 476 }
477 else
478 {
479 LLLiveLSLEditor* preview = LLLiveLSLEditor::find(item_id, task_id);
480 if (preview)
497 { 481 {
498 preview->callbackLSLCompileFailed(content["errors"]); 482 // Bytecode save completed
483 if (content["compiled"])
484 {
485 preview->callbackLSLCompileSucceeded(
486 task_id,
487 item_id,
488 mPostData["is_script_running"]);
489 }
490 else
491 {
492 preview->callbackLSLCompileFailed(content["errors"]);
493 }
499 } 494 }
500 } 495 }
501 } 496 }
502 break; 497 break;
503 case LLInventoryType::IT_WEARABLE: 498 default:
504 default: 499 break;
505 break;
506 } 500 }
507} 501}