aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llassetuploadresponders.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llassetuploadresponders.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llassetuploadresponders.cpp159
1 files changed, 120 insertions, 39 deletions
diff --git a/linden/indra/newview/llassetuploadresponders.cpp b/linden/indra/newview/llassetuploadresponders.cpp
index be3882e..5b04e24 100644
--- a/linden/indra/newview/llassetuploadresponders.cpp
+++ b/linden/indra/newview/llassetuploadresponders.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 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 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 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -33,12 +34,11 @@
33 34
34#include "llassetuploadresponders.h" 35#include "llassetuploadresponders.h"
35 36
37// viewer includes
36#include "llagent.h" 38#include "llagent.h"
37#include "llcompilequeue.h" 39#include "llcompilequeue.h"
38#include "llfloaterbuycurrency.h" 40#include "llfloaterbuycurrency.h"
39#include "lleconomy.h"
40#include "llfilepicker.h" 41#include "llfilepicker.h"
41#include "llfocusmgr.h"
42#include "llnotify.h" 42#include "llnotify.h"
43#include "llinventorymodel.h" 43#include "llinventorymodel.h"
44#include "llinventoryview.h" 44#include "llinventoryview.h"
@@ -47,12 +47,24 @@
47#include "llpreviewscript.h" 47#include "llpreviewscript.h"
48#include "llpreviewgesture.h" 48#include "llpreviewgesture.h"
49#include "llgesturemgr.h" 49#include "llgesturemgr.h"
50#include "llscrolllistctrl.h" 50#include "llstatusbar.h" // sendMoneyBalanceRequest()
51#include "llsdserialize.h"
51#include "lluploaddialog.h" 52#include "lluploaddialog.h"
52#include "llviewerobject.h" 53#include "llviewerobject.h"
54#include "llviewercontrol.h"
53#include "llviewerobjectlist.h" 55#include "llviewerobjectlist.h"
54#include "llviewermenufile.h" 56#include "llviewermenufile.h"
55#include "llviewerwindow.h" 57#include "llviewerwindow.h"
58#include "lltexlayer.h"
59
60// library includes
61#include "lleconomy.h"
62#include "llfocusmgr.h"
63#include "llscrolllistctrl.h"
64#include "llsdserialize.h"
65
66// When uploading multiple files, don't display any of them when uploading more than this number.
67static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5;
56 68
57void dialog_refresh_all(); 69void dialog_refresh_all();
58 70
@@ -97,21 +109,21 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason)
97{ 109{
98 llinfos << "LLAssetUploadResponder::error " << statusNum 110 llinfos << "LLAssetUploadResponder::error " << statusNum
99 << " reason: " << reason << llendl; 111 << " reason: " << reason << llendl;
100 LLStringUtil::format_map_t args; 112 LLSD args;
101 switch(statusNum) 113 switch(statusNum)
102 { 114 {
103 case 400: 115 case 400:
104 args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); 116 args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName);
105 args["[REASON]"] = "Error in upload request. Please visit " 117 args["REASON"] = "Error in upload request. Please visit "
106 "http://secondlife.com/support for help fixing this problem."; 118 "http://secondlife.com/support for help fixing this problem.";
107 gViewerWindow->alertXml("CannotUploadReason", args); 119 LLNotifications::instance().add("CannotUploadReason", args);
108 break; 120 break;
109 case 500: 121 case 500:
110 default: 122 default:
111 args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); 123 args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName);
112 args["[REASON]"] = "The server is experiencing unexpected " 124 args["REASON"] = "The server is experiencing unexpected "
113 "difficulties."; 125 "difficulties.";
114 gViewerWindow->alertXml("CannotUploadReason", args); 126 LLNotifications::instance().add("CannotUploadReason", args);
115 break; 127 break;
116 } 128 }
117 LLUploadDialog::modalUploadFinished(); 129 LLUploadDialog::modalUploadFinished();
@@ -133,6 +145,7 @@ void LLAssetUploadResponder::result(const LLSD& content)
133 if (mFileName.empty()) 145 if (mFileName.empty())
134 { 146 {
135 // rename the file in the VFS to the actual asset id 147 // rename the file in the VFS to the actual asset id
148 // llinfos << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << llendl;
136 gVFS->renameFile(mVFileID, mAssetType, content["new_asset"].asUUID(), mAssetType); 149 gVFS->renameFile(mVFileID, mAssetType, content["new_asset"].asUUID(), mAssetType);
137 } 150 }
138 uploadComplete(content); 151 uploadComplete(content);
@@ -166,10 +179,10 @@ void LLAssetUploadResponder::uploadFailure(const LLSD& content)
166 } 179 }
167 else 180 else
168 { 181 {
169 LLStringUtil::format_map_t args; 182 LLSD args;
170 args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); 183 args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName);
171 args["[REASON]"] = content["message"].asString(); 184 args["REASON"] = content["message"].asString();
172 gViewerWindow->alertXml("CannotUploadReason", args); 185 LLNotifications::instance().add("CannotUploadReason", args);
173 } 186 }
174} 187}
175 188
@@ -193,9 +206,14 @@ LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data
193void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) 206void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
194{ 207{
195 lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; 208 lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl;
209
210 //std::ostringstream llsdxml;
211 //LLSDSerialize::toXML(content, llsdxml);
212 //llinfos << "upload complete content:\n " << llsdxml.str() << llendl;
196 213
197 LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString()); 214 LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString());
198 LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString()); 215 LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString());
216 S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
199 217
200 // Update L$ and ownership credit information 218 // Update L$ and ownership credit information
201 // since it probably changed on the server 219 // since it probably changed on the server
@@ -203,17 +221,11 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
203 asset_type == LLAssetType::AT_SOUND || 221 asset_type == LLAssetType::AT_SOUND ||
204 asset_type == LLAssetType::AT_ANIMATION) 222 asset_type == LLAssetType::AT_ANIMATION)
205 { 223 {
206 gMessageSystem->newMessageFast(_PREHASH_MoneyBalanceRequest); 224 LLStatusBar::sendMoneyBalanceRequest();
207 gMessageSystem->nextBlockFast(_PREHASH_AgentData); 225
208 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); 226 LLSD args;
209 gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); 227 args["AMOUNT"] = llformat("%d", expected_upload_cost);
210 gMessageSystem->nextBlockFast(_PREHASH_MoneyData); 228 LLNotifications::instance().add("UploadPayment", args);
211 gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
212 gAgent.sendReliableMessage();
213
214 LLStringUtil::format_map_t args;
215 args["[AMOUNT]"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload());
216 LLNotifyBox::showXml("UploadPayment", args);
217 } 229 }
218 230
219 // Actually add the upload to viewer inventory 231 // Actually add the upload to viewer inventory
@@ -221,23 +233,39 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
221 << content["new_asset"].asUUID() << " to inventory." << llendl; 233 << content["new_asset"].asUUID() << " to inventory." << llendl;
222 if(mPostData["folder_id"].asUUID().notNull()) 234 if(mPostData["folder_id"].asUUID().notNull())
223 { 235 {
224 LLPermissions perm; 236 //std::ostringstream out;
225 U32 next_owner_perm; 237 //LLSDXMLFormatter *formatter = new LLSDXMLFormatter;
226 perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); 238 //formatter->format(mPostData, out, LLSDFormatter::OPTIONS_PRETTY);
227 if (mPostData["inventory_type"].asString() == "snapshot") 239 //llinfos << "Post Data: " << out.str() << llendl;
240
241 U32 everyone_perms = PERM_NONE;
242 U32 group_perms = PERM_NONE;
243 U32 next_owner_perms = PERM_ALL;
244 if(content.has("new_next_owner_mask"))
228 { 245 {
229 next_owner_perm = PERM_ALL; 246 // This is a new sim that provides creation perms so use them.
247 // Do not assume we got the perms we asked for in mPostData
248 // since the sim may not have granted them all.
249 everyone_perms = content["new_everyone_mask"].asInteger();
250 group_perms = content["new_group_mask"].asInteger();
251 next_owner_perms = content["new_next_owner_mask"].asInteger();
230 } 252 }
231 else 253 else
232 { 254 {
233 next_owner_perm = PERM_MOVE | PERM_TRANSFER; 255 // This old sim doesn't provide creation perms so use old assumption-based perms.
256 if(mPostData["inventory_type"].asString() != "snapshot")
257 {
258 next_owner_perms = PERM_MOVE | PERM_TRANSFER;
259 }
234 } 260 }
235 perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, next_owner_perm); 261 LLPermissions new_perms;
262 new_perms.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null);
263 new_perms.initMasks(PERM_ALL, PERM_ALL, everyone_perms, group_perms, next_owner_perms);
236 S32 creation_date_now = time_corrected(); 264 S32 creation_date_now = time_corrected();
237 LLPointer<LLViewerInventoryItem> item 265 LLPointer<LLViewerInventoryItem> item
238 = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(), 266 = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(),
239 mPostData["folder_id"].asUUID(), 267 mPostData["folder_id"].asUUID(),
240 perm, 268 new_perms,
241 content["new_asset"].asUUID(), 269 content["new_asset"].asUUID(),
242 asset_type, 270 asset_type,
243 inventory_type, 271 inventory_type,
@@ -255,10 +283,9 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
255 if(view) 283 if(view)
256 { 284 {
257 LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); 285 LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus();
258
259 view->getPanel()->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO); 286 view->getPanel()->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO);
260 if((LLAssetType::AT_TEXTURE == asset_type) 287 if((LLAssetType::AT_TEXTURE == asset_type || LLAssetType::AT_SOUND == asset_type)
261 || (LLAssetType::AT_SOUND == asset_type)) 288 && LLFilePicker::instance().getFileCount() <= FILE_COUNT_DISPLAY_THRESHOLD)
262 { 289 {
263 view->getPanel()->openSelected(); 290 view->getPanel()->openSelected();
264 } 291 }
@@ -289,8 +316,62 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
289 LLStringUtil::stripNonprintable(asset_name); 316 LLStringUtil::stripNonprintable(asset_name);
290 LLStringUtil::trim(asset_name); 317 LLStringUtil::trim(asset_name);
291 318
319 // Continuing the horrible hack above, we need to extract the originally requested permissions data, if any,
320 // and use them for each next file to be uploaded. Note the requested perms are not the same as the
321 // granted ones found in the given "content" structure but can still be found in mPostData. -MG
322 U32 everyone_perms = mPostData.has("everyone_mask") ? mPostData.get("everyone_mask" ).asInteger() : PERM_NONE;
323 U32 group_perms = mPostData.has("group_mask") ? mPostData.get("group_mask" ).asInteger() : PERM_NONE;
324 U32 next_owner_perms = mPostData.has("next_owner_mask") ? mPostData.get("next_owner_mask").asInteger() : PERM_NONE;
325 std::string display_name = LLStringUtil::null;
326 LLAssetStorage::LLStoreAssetCallback callback = NULL;
327 void *userdata = NULL;
292 upload_new_resource(next_file, asset_name, asset_name, 328 upload_new_resource(next_file, asset_name, asset_name,
293 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); 329 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
330 next_owner_perms, group_perms,
331 everyone_perms, display_name,
332 callback, expected_upload_cost, userdata);
333 }
334}
335
336LLSendTexLayerResponder::LLSendTexLayerResponder(const LLSD& post_data,
337 const LLUUID& vfile_id,
338 LLAssetType::EType asset_type,
339 LLBakedUploadData * baked_upload_data)
340 : LLAssetUploadResponder(post_data, vfile_id, asset_type),
341 mBakedUploadData(baked_upload_data)
342{
343}
344
345LLSendTexLayerResponder::~LLSendTexLayerResponder()
346{
347 // mBakedUploadData is normally deleted by calls to LLTexLayerSetBuffer::onTextureUploadComplete() below
348 if (mBakedUploadData)
349 { // ...but delete it in the case where uploadComplete() is never called
350 delete mBakedUploadData;
351 mBakedUploadData = NULL;
352 }
353}
354
355
356// Baked texture upload completed
357void LLSendTexLayerResponder::uploadComplete(const LLSD& content)
358{
359 LLUUID item_id = mPostData["item_id"];
360
361 std::string result = content["state"];
362 LLUUID new_id = content["new_asset"];
363
364 llinfos << "LLSendTexLayerResponder::result from capabilities: " << result << llendl;
365 if (result == "complete"
366 && mBakedUploadData != NULL)
367 { // Invoke
368 LLTexLayerSetBuffer::onTextureUploadComplete(new_id, (void*) mBakedUploadData, 0, LL_EXSTAT_NONE);
369 mBakedUploadData = NULL; // deleted in onTextureUploadComplete()
370 }
371 else
372 { // Invoke the original callback with an error result
373 LLTexLayerSetBuffer::onTextureUploadComplete(new_id, (void*) mBakedUploadData, -1, LL_EXSTAT_NONE);
374 mBakedUploadData = NULL; // deleted in onTextureUploadComplete()
294 } 375 }
295} 376}
296 377