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/llassetuploadresponders.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/llassetuploadresponders.cpp | 537 |
1 files changed, 390 insertions, 147 deletions
diff --git a/linden/indra/newview/llassetuploadresponders.cpp b/linden/indra/newview/llassetuploadresponders.cpp index 1c094bb..7c615dd 100644 --- a/linden/indra/newview/llassetuploadresponders.cpp +++ b/linden/indra/newview/llassetuploadresponders.cpp | |||
@@ -1,29 +1,6 @@ | |||
1 | /** | 1 | // llassetuploadresponders.cpp |
2 | * @file llmapresponders.h | 2 | // Copyright 2006, Linden Research, Inc. |
3 | * @brief Processes responses received for asset upload requests. | 3 | // Processes responses received for asset upload requests. |
4 | * | ||
5 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | 4 | ||
28 | #include "llviewerprecompiledheaders.h" | 5 | #include "llviewerprecompiledheaders.h" |
29 | 6 | ||
@@ -38,39 +15,71 @@ | |||
38 | #include "llinventorymodel.h" | 15 | #include "llinventorymodel.h" |
39 | #include "llinventoryview.h" | 16 | #include "llinventoryview.h" |
40 | #include "llpermissionsflags.h" | 17 | #include "llpermissionsflags.h" |
18 | #include "llpreviewnotecard.h" | ||
19 | #include "llpreviewscript.h" | ||
20 | #include "llscrolllistctrl.h" | ||
41 | #include "lluploaddialog.h" | 21 | #include "lluploaddialog.h" |
42 | #include "llviewermenu.h" // for upload_new_resource() | 22 | #include "llviewerobject.h" |
23 | #include "llviewerobjectlist.h" | ||
24 | #include "llviewermenu.h" | ||
43 | #include "llviewerwindow.h" | 25 | #include "llviewerwindow.h" |
44 | #include "viewer.h" | 26 | #include "viewer.h" |
45 | 27 | ||
46 | LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLUUID& uuid, | 28 | void dialog_refresh_all(); |
47 | const LLSD &post_data) | 29 | |
48 | : LLHTTPClient::Responder() | 30 | LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, |
31 | const LLUUID& vfile_id, | ||
32 | LLAssetType::EType asset_type) | ||
33 | : LLHTTPClient::Responder(), | ||
34 | mPostData(post_data), | ||
35 | mVFileID(vfile_id), | ||
36 | mAssetType(asset_type) | ||
37 | { | ||
38 | if (!gVFS->getExists(vfile_id, asset_type)) | ||
39 | { | ||
40 | llwarns << "LLAssetUploadResponder called with nonexistant vfile_id" << llendl; | ||
41 | mVFileID.setNull(); | ||
42 | mAssetType = LLAssetType::AT_NONE; | ||
43 | return; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, | ||
48 | const std::string& file_name) | ||
49 | : LLHTTPClient::Responder(), | ||
50 | mPostData(post_data), | ||
51 | mFileName(file_name) | ||
52 | { | ||
53 | } | ||
54 | |||
55 | LLAssetUploadResponder::~LLAssetUploadResponder() | ||
49 | { | 56 | { |
50 | mUUID = uuid; | 57 | if (!mFileName.empty()) |
51 | mPostData = post_data; | 58 | { |
59 | // Delete temp file | ||
60 | LLFile::remove(mFileName.c_str()); | ||
61 | } | ||
52 | } | 62 | } |
53 | 63 | ||
54 | // virtual | 64 | // virtual |
55 | void LLNewAgentInventoryResponder::error(U32 statusNum, const std::string& reason) | 65 | void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason) |
56 | { | 66 | { |
57 | llinfos << "LLNewAgentInventoryResponder::error " << statusNum << llendl; | 67 | llinfos << "LLAssetUploadResponder::error " << statusNum |
68 | << " reason: " << reason << llendl; | ||
58 | LLStringBase<char>::format_map_t args; | 69 | LLStringBase<char>::format_map_t args; |
59 | switch(statusNum) | 70 | switch(statusNum) |
60 | { | 71 | { |
61 | case 400: | 72 | case 400: |
62 | args["[FILE]"] = mPostData["inventory_type"].asString(); | 73 | args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); |
63 | args["[REASON]"] = "invalid parameters in upload request"; | 74 | args["[REASON]"] = "Error in upload request. Please contact " |
75 | "support@lindenlab.com for help fixing this problem."; | ||
64 | gViewerWindow->alertXml("CannotUploadReason", args); | 76 | gViewerWindow->alertXml("CannotUploadReason", args); |
65 | break; | 77 | break; |
66 | case 402: | ||
67 | //(result["message"].asString() == "insufficient funds") | ||
68 | LLFloaterBuyCurrency::buyCurrency("Uploading costs", gGlobalEconomy->getPriceUpload()); | ||
69 | break; | ||
70 | case 500: | 78 | case 500: |
71 | default: | 79 | default: |
72 | args["[FILE]"] = mPostData["inventory_type"].asString(); | 80 | args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); |
73 | args["[REASON]"] = "the server is experiencing unexpected difficulties"; | 81 | args["[REASON]"] = "The server is experiencing unexpected " |
82 | "difficulties. Please try again later."; | ||
74 | gViewerWindow->alertXml("CannotUploadReason", args); | 83 | gViewerWindow->alertXml("CannotUploadReason", args); |
75 | break; | 84 | break; |
76 | } | 85 | } |
@@ -78,139 +87,373 @@ void LLNewAgentInventoryResponder::error(U32 statusNum, const std::string& reaso | |||
78 | } | 87 | } |
79 | 88 | ||
80 | //virtual | 89 | //virtual |
81 | void LLNewAgentInventoryResponder::result(const LLSD& result) | 90 | void LLAssetUploadResponder::result(const LLSD& content) |
82 | { | 91 | { |
83 | lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; | 92 | lldebugs << "LLAssetUploadResponder::result from capabilities" << llendl; |
84 | 93 | ||
85 | if (!result["success"]) | 94 | std::string state = content["state"]; |
95 | if (state == "upload") | ||
96 | { | ||
97 | uploadUpload(content); | ||
98 | } | ||
99 | else if (state == "complete") | ||
100 | { | ||
101 | // rename file in VFS with new asset id | ||
102 | if (mFileName.empty()) | ||
103 | { | ||
104 | // rename the file in the VFS to the actual asset id | ||
105 | gVFS->renameFile(mVFileID, mAssetType, content["new_asset"].asUUID(), mAssetType); | ||
106 | } | ||
107 | uploadComplete(content); | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | uploadFailure(content); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | void LLAssetUploadResponder::uploadUpload(const LLSD& content) | ||
116 | { | ||
117 | std::string uploader = content["uploader"]; | ||
118 | if (mFileName.empty()) | ||
119 | { | ||
120 | LLHTTPClient::postFile(uploader, mVFileID, mAssetType, this); | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | LLHTTPClient::postFile(uploader, mFileName, this); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | void LLAssetUploadResponder::uploadFailure(const LLSD& content) | ||
129 | { | ||
130 | std::string reason = content["state"]; | ||
131 | // deal with money errors | ||
132 | if (reason == "insufficient funds") | ||
133 | { | ||
134 | LLFloaterBuyCurrency::buyCurrency("Uploading costs", gGlobalEconomy->getPriceUpload()); | ||
135 | } | ||
136 | else | ||
86 | { | 137 | { |
87 | LLStringBase<char>::format_map_t args; | 138 | LLStringBase<char>::format_map_t args; |
88 | args["[FILE]"] = mPostData["inventory_type"].asString(); | 139 | args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); |
89 | args["[REASON]"] = "the server is experiencing unexpected difficulties"; | 140 | args["[REASON]"] = content["message"].asString(); |
90 | gViewerWindow->alertXml("CannotUploadReason", args); | 141 | gViewerWindow->alertXml("CannotUploadReason", args); |
91 | return; | ||
92 | } | 142 | } |
143 | } | ||
144 | |||
145 | void LLAssetUploadResponder::uploadComplete(const LLSD& content) | ||
146 | { | ||
147 | } | ||
148 | |||
149 | LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, | ||
150 | const LLUUID& vfile_id, | ||
151 | LLAssetType::EType asset_type) | ||
152 | : LLAssetUploadResponder(post_data, vfile_id, asset_type) | ||
153 | { | ||
154 | } | ||
155 | |||
156 | LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name) | ||
157 | : LLAssetUploadResponder(post_data, file_name) | ||
158 | { | ||
159 | } | ||
160 | |||
161 | //virtual | ||
162 | void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) | ||
163 | { | ||
164 | lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl; | ||
93 | 165 | ||
94 | std::string uploader = result["uploader"]; | ||
95 | LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString().c_str()); | 166 | LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString().c_str()); |
96 | LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString().c_str()); | 167 | LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString().c_str()); |
97 | // request succeeded | 168 | |
98 | if (!uploader.empty()) | 169 | // Update money and ownership credit information |
170 | // since it probably changed on the server | ||
171 | if (asset_type == LLAssetType::AT_TEXTURE || | ||
172 | asset_type == LLAssetType::AT_SOUND || | ||
173 | asset_type == LLAssetType::AT_ANIMATION) | ||
99 | { | 174 | { |
100 | LLHTTPClient::postFile(uploader, mUUID, asset_type, this); | 175 | gMessageSystem->newMessageFast(_PREHASH_MoneyBalanceRequest); |
176 | gMessageSystem->nextBlockFast(_PREHASH_AgentData); | ||
177 | gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
178 | gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
179 | gMessageSystem->nextBlockFast(_PREHASH_MoneyData); | ||
180 | gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); | ||
181 | gAgent.sendReliableMessage(); | ||
182 | |||
183 | LLString::format_map_t args; | ||
184 | args["[AMOUNT]"] = llformat("%d",gGlobalEconomy->getPriceUpload()); | ||
185 | LLNotifyBox::showXml("UploadPayment", args); | ||
101 | } | 186 | } |
102 | // upload succeeded | ||
103 | else | ||
104 | { | ||
105 | // rename the file in the VFS to the actual asset id | ||
106 | gVFS->renameFile(mUUID, asset_type, result["new_asset"].asUUID(), asset_type); | ||
107 | 187 | ||
108 | // TODO: only request for textures, sound, and animation uploads | 188 | // Actually add the upload to viewer inventory |
109 | // Update money and ownership credit information | 189 | llinfos << "Adding " << content["new_inventory_item"].asUUID() << " " |
110 | // since it probably changed on the server | 190 | << content["new_asset"].asUUID() << " to inventory." << llendl; |
111 | if (mPostData["asset_type"].asString() == "texture" || | 191 | if(mPostData["folder_id"].asUUID().notNull()) |
112 | mPostData["asset_type"].asString() == "sound" || | 192 | { |
113 | mPostData["asset_type"].asString() == "animatn") | 193 | LLPermissions perm; |
194 | U32 next_owner_perm; | ||
195 | perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); | ||
196 | if (mPostData["inventory_type"].asString() == "snapshot") | ||
114 | { | 197 | { |
115 | gMessageSystem->newMessageFast(_PREHASH_MoneyBalanceRequest); | 198 | next_owner_perm = PERM_ALL; |
116 | gMessageSystem->nextBlockFast(_PREHASH_AgentData); | ||
117 | gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
118 | gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
119 | gMessageSystem->nextBlockFast(_PREHASH_MoneyData); | ||
120 | gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); | ||
121 | gAgent.sendReliableMessage(); | ||
122 | |||
123 | LLString::format_map_t args; | ||
124 | args["[AMOUNT]"] = llformat("%d",gGlobalEconomy->getPriceUpload()); | ||
125 | LLNotifyBox::showXml("UploadPayment", args); | ||
126 | } | 199 | } |
127 | // Actually add the upload to viewer inventory | 200 | else |
128 | llinfos << "Adding " << result["new_inventory_item"].asUUID() << " " | ||
129 | << result["new_asset"].asUUID() << " to inventory." << llendl; | ||
130 | if(mPostData["folder_id"].asUUID().notNull()) | ||
131 | { | 201 | { |
132 | LLPermissions perm; | 202 | next_owner_perm = PERM_MOVE | PERM_TRANSFER; |
133 | U32 next_owner_perm; | 203 | } |
134 | perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); | 204 | perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, next_owner_perm); |
135 | if (mPostData["inventory_type"].asString() == "snapshot") | 205 | S32 creation_date_now = time_corrected(); |
206 | LLPointer<LLViewerInventoryItem> item | ||
207 | = new LLViewerInventoryItem(content["new_inventory_item"].asUUID(), | ||
208 | mPostData["folder_id"].asUUID(), | ||
209 | perm, | ||
210 | content["new_asset"].asUUID(), | ||
211 | asset_type, | ||
212 | inventory_type, | ||
213 | mPostData["name"].asString(), | ||
214 | mPostData["description"].asString(), | ||
215 | LLSaleInfo::DEFAULT, | ||
216 | LLInventoryItem::II_FLAGS_NONE, | ||
217 | creation_date_now); | ||
218 | gInventory.updateItem(item); | ||
219 | gInventory.notifyObservers(); | ||
220 | |||
221 | // Show the preview panel for textures and sounds to let | ||
222 | // user know that the image (or snapshot) arrived intact. | ||
223 | LLInventoryView* view = LLInventoryView::getActiveInventory(); | ||
224 | if(view) | ||
225 | { | ||
226 | LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); | ||
227 | LLFocusMgr::FocusLostCallback callback = gFocusMgr.getFocusCallback(); | ||
228 | |||
229 | view->getPanel()->setSelection(content["new_inventory_item"].asUUID(), TAKE_FOCUS_NO); | ||
230 | if((LLAssetType::AT_TEXTURE == asset_type) | ||
231 | || (LLAssetType::AT_SOUND == asset_type)) | ||
136 | { | 232 | { |
137 | next_owner_perm = PERM_ALL; | 233 | view->getPanel()->openSelected(); |
138 | } | 234 | } |
139 | else | 235 | //LLInventoryView::dumpSelectionInformation((void*)view); |
236 | // restore keyboard focus | ||
237 | gFocusMgr.setKeyboardFocus(focus_ctrl, callback); | ||
238 | } | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | llwarns << "Can't find a folder to put it in" << llendl; | ||
243 | } | ||
244 | |||
245 | // remove the "Uploading..." message | ||
246 | LLUploadDialog::modalUploadFinished(); | ||
247 | |||
248 | // *FIX: This is a pretty big hack. What this does is check the | ||
249 | // file picker if there are any more pending uploads. If so, | ||
250 | // upload that file. | ||
251 | const char* next_file = LLFilePicker::instance().getNextFile(); | ||
252 | if(next_file) | ||
253 | { | ||
254 | const char* name = LLFilePicker::instance().getDirname(); | ||
255 | |||
256 | LLString asset_name = name; | ||
257 | LLString::replaceNonstandardASCII( asset_name, '?' ); | ||
258 | LLString::replaceChar(asset_name, '|', '?'); | ||
259 | LLString::stripNonprintable(asset_name); | ||
260 | LLString::trim(asset_name); | ||
261 | |||
262 | char* asset_name_str = (char*)asset_name.c_str(); | ||
263 | char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists | ||
264 | if( !end_p ) | ||
265 | { | ||
266 | end_p = asset_name_str + strlen( asset_name_str ); /*Flawfinder: ignore*/ | ||
267 | } | ||
268 | |||
269 | S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); | ||
270 | |||
271 | asset_name = asset_name.substr( 0, len ); | ||
272 | |||
273 | upload_new_resource(next_file, asset_name, asset_name, | ||
274 | 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); | ||
275 | } | ||
276 | } | ||
277 | |||
278 | |||
279 | LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data, | ||
280 | const LLUUID& vfile_id, | ||
281 | LLAssetType::EType asset_type) | ||
282 | : LLAssetUploadResponder(post_data, vfile_id, asset_type) | ||
283 | { | ||
284 | } | ||
285 | |||
286 | LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data, | ||
287 | const std::string& file_name) | ||
288 | : LLAssetUploadResponder(post_data, file_name) | ||
289 | { | ||
290 | } | ||
291 | |||
292 | //virtual | ||
293 | void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content) | ||
294 | { | ||
295 | llinfos << "LLUpdateAgentInventoryResponder::result from capabilities" << llendl; | ||
296 | LLUUID item_id = mPostData["item_id"]; | ||
297 | |||
298 | LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(item_id); | ||
299 | if(!item) | ||
300 | { | ||
301 | llwarns << "Inventory item for " << mVFileID | ||
302 | << " is no longer in agent inventory." << llendl; | ||
303 | return; | ||
304 | } | ||
305 | |||
306 | // Update viewer inventory item | ||
307 | LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); | ||
308 | new_item->setAssetUUID(content["new_asset"].asUUID()); | ||
309 | gInventory.updateItem(new_item); | ||
310 | gInventory.notifyObservers(); | ||
311 | |||
312 | llinfos << "Inventory item " << item->getName() << " saved into " | ||
313 | << content["new_asset"].asString() << llendl; | ||
314 | |||
315 | LLInventoryType::EType inventory_type = new_item->getInventoryType(); | ||
316 | switch(inventory_type) | ||
317 | { | ||
318 | case LLInventoryType::IT_NOTECARD: | ||
140 | { | 319 | { |
141 | next_owner_perm = PERM_MOVE | PERM_TRANSFER; | 320 | |
321 | // Update the UI with the new asset. | ||
322 | LLPreviewNotecard* nc; | ||
323 | nc = (LLPreviewNotecard*)LLPreview::find(new_item->getUUID()); | ||
324 | if(nc) | ||
325 | { | ||
326 | // *HACK: we have to delete the asset in the VFS so | ||
327 | // that the viewer will redownload it. This is only | ||
328 | // really necessary if the asset had to be modified by | ||
329 | // the uploader, so this can be optimized away in some | ||
330 | // cases. A better design is to have a new uuid if the | ||
331 | // script actually changed the asset. | ||
332 | if(nc->hasEmbeddedInventory()) | ||
333 | { | ||
334 | gVFS->removeFile( | ||
335 | content["new_asset"].asUUID(), | ||
336 | LLAssetType::AT_NOTECARD); | ||
337 | } | ||
338 | nc->refreshFromInventory(); | ||
339 | } | ||
142 | } | 340 | } |
143 | perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, next_owner_perm); | 341 | break; |
144 | S32 creation_date_now = time_corrected(); | 342 | case LLInventoryType::IT_LSL: |
145 | LLPointer<LLViewerInventoryItem> item | ||
146 | = new LLViewerInventoryItem(result["new_inventory_item"].asUUID(), | ||
147 | mPostData["folder_id"].asUUID(), | ||
148 | perm, | ||
149 | result["new_asset"].asUUID(), | ||
150 | asset_type, | ||
151 | inventory_type, | ||
152 | mPostData["name"].asString(), | ||
153 | mPostData["description"].asString(), | ||
154 | LLSaleInfo::DEFAULT, | ||
155 | LLInventoryItem::II_FLAGS_NONE, | ||
156 | creation_date_now); | ||
157 | gInventory.updateItem(item); | ||
158 | gInventory.notifyObservers(); | ||
159 | |||
160 | // Show the preview panel for textures and sounds to let | ||
161 | // user know that the image (or snapshot) arrived intact. | ||
162 | LLInventoryView* view = LLInventoryView::getActiveInventory(); | ||
163 | if(view) | ||
164 | { | 343 | { |
165 | LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); | 344 | // Find our window and close it if requested. |
166 | LLFocusMgr::FocusLostCallback callback = gFocusMgr.getFocusCallback(); | 345 | LLPreviewLSL* preview = (LLPreviewLSL*)LLPreview::find(item_id); |
167 | 346 | if (preview) | |
168 | view->getPanel()->setSelection(result["new_inventory_item"].asUUID(), TAKE_FOCUS_NO); | ||
169 | if((LLAssetType::AT_TEXTURE == asset_type) | ||
170 | || (LLAssetType::AT_SOUND == asset_type)) | ||
171 | { | 347 | { |
172 | view->getPanel()->openSelected(); | 348 | // Bytecode save completed |
349 | if (content["compiled"]) | ||
350 | { | ||
351 | preview->callbackLSLCompileSucceeded(); | ||
352 | } | ||
353 | else | ||
354 | { | ||
355 | preview->callbackLSLCompileFailed(content["errors"]); | ||
356 | } | ||
173 | } | 357 | } |
174 | //LLInventoryView::dumpSelectionInformation((void*)view); | ||
175 | // restore keyboard focus | ||
176 | gFocusMgr.setKeyboardFocus(focus_ctrl, callback); | ||
177 | } | 358 | } |
178 | } | 359 | break; |
179 | else | 360 | case LLInventoryType::IT_WEARABLE: |
180 | { | 361 | default: |
181 | llwarns << "Can't find a folder to put it in" << llendl; | 362 | break; |
182 | } | 363 | } |
364 | } | ||
183 | 365 | ||
184 | // remove the "Uploading..." message | ||
185 | LLUploadDialog::modalUploadFinished(); | ||
186 | |||
187 | // *NOTE: This is a pretty big hack. What this does is check | ||
188 | // the file picker if there are any more pending uploads. If | ||
189 | // so, upload that file. | ||
190 | const char* next_file = LLFilePicker::instance().getNextFile(); | ||
191 | if(next_file) | ||
192 | { | ||
193 | const char* name = LLFilePicker::instance().getDirname(); | ||
194 | 366 | ||
195 | LLString asset_name = name; | 367 | LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, |
196 | LLString::replaceNonstandardASCII( asset_name, '?' ); | 368 | const LLUUID& vfile_id, |
197 | LLString::replaceChar(asset_name, '|', '?'); | 369 | LLAssetType::EType asset_type) |
198 | LLString::stripNonprintable(asset_name); | 370 | : LLAssetUploadResponder(post_data, vfile_id, asset_type) |
199 | LLString::trim(asset_name); | 371 | { |
372 | } | ||
200 | 373 | ||
201 | char* asset_name_str = (char*)asset_name.c_str(); | 374 | LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, |
202 | char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists | 375 | const std::string& file_name) |
203 | if( !end_p ) | 376 | : LLAssetUploadResponder(post_data, file_name) |
377 | { | ||
378 | } | ||
379 | |||
380 | //virtual | ||
381 | void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content) | ||
382 | { | ||
383 | llinfos << "LLUpdateTaskInventoryResponder::result from capabilities" << llendl; | ||
384 | LLUUID item_id = mPostData["item_id"]; | ||
385 | LLUUID task_id = mPostData["task_id"]; | ||
386 | |||
387 | LLViewerObject* object = gObjectList.findObject(task_id); | ||
388 | if (!object) | ||
389 | { | ||
390 | llwarns << "LLUpdateTaskInventoryResponder::uploadComplete task " << task_id | ||
391 | << " no longer exist." << llendl; | ||
392 | return; | ||
393 | } | ||
394 | LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(item_id); | ||
395 | if (!item) | ||
396 | { | ||
397 | llwarns << "LLUpdateTaskInventoryResponder::uploadComplete item " | ||
398 | << item_id << " is no longer in task " << task_id | ||
399 | << "'s inventory." << llendl; | ||
400 | return; | ||
401 | } | ||
402 | LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); | ||
403 | // Update Viewer inventory | ||
404 | object->updateViewerInventoryAsset(new_item, content["new_asset"]); | ||
405 | dialog_refresh_all(); | ||
406 | |||
407 | LLInventoryType::EType inventory_type = new_item->getInventoryType(); | ||
408 | switch(inventory_type) | ||
409 | { | ||
410 | case LLInventoryType::IT_NOTECARD: | ||
204 | { | 411 | { |
205 | end_p = asset_name_str + strlen( asset_name_str ); | ||
206 | } | ||
207 | |||
208 | S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) ); | ||
209 | 412 | ||
210 | asset_name = asset_name.substr( 0, len ); | 413 | // Update the UI with the new asset. |
414 | LLPreviewNotecard* nc; | ||
415 | nc = (LLPreviewNotecard*)LLPreview::find(new_item->getUUID()); | ||
416 | if(nc) | ||
417 | { | ||
418 | // *HACK: we have to delete the asset in the VFS so | ||
419 | // that the viewer will redownload it. This is only | ||
420 | // really necessary if the asset had to be modified by | ||
421 | // the uploader, so this can be optimized away in some | ||
422 | // cases. A better design is to have a new uuid if the | ||
423 | // script actually changed the asset. | ||
424 | if(nc->hasEmbeddedInventory()) | ||
425 | { | ||
426 | gVFS->removeFile( | ||
427 | content["new_asset"].asUUID(), | ||
428 | LLAssetType::AT_NOTECARD); | ||
429 | } | ||
211 | 430 | ||
212 | upload_new_resource(next_file, asset_name, asset_name, | 431 | nc->refreshFromInventory(); |
213 | 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE); | 432 | } |
214 | } | 433 | } |
434 | break; | ||
435 | case LLInventoryType::IT_LSL: | ||
436 | { | ||
437 | LLLiveLSLEditor* preview = LLLiveLSLEditor::find(item_id, task_id); | ||
438 | if (preview) | ||
439 | { | ||
440 | // Bytecode save completed | ||
441 | if (content["compiled"]) | ||
442 | { | ||
443 | preview->callbackLSLCompileSucceeded( | ||
444 | task_id, | ||
445 | item_id, | ||
446 | mPostData["is_script_running"]); | ||
447 | } | ||
448 | else | ||
449 | { | ||
450 | preview->callbackLSLCompileFailed(content["errors"]); | ||
451 | } | ||
452 | } | ||
453 | } | ||
454 | break; | ||
455 | case LLInventoryType::IT_WEARABLE: | ||
456 | default: | ||
457 | break; | ||
215 | } | 458 | } |
216 | } | 459 | } |