summaryrefslogtreecommitdiff
path: root/indra/newview/llwearablelist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llwearablelist.cpp')
-rw-r--r--indra/newview/llwearablelist.cpp130
1 files changed, 39 insertions, 91 deletions
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp
index 512c03fa4d..5636256856 100644
--- a/indra/newview/llwearablelist.cpp
+++ b/indra/newview/llwearablelist.cpp
@@ -39,22 +39,18 @@
#include "llagent.h"
#include "llvoavatar.h"
#include "llviewerinventory.h"
-//#include "llfloaterchat.h"
#include "llviewerstats.h"
-#include "llnotify.h"
-
-// Globals
-LLWearableList gWearableList; // Globally constructed; be careful that there's no dependency with gAgent.
-
+#include "llnotificationsutil.h"
+#include "llinventorymodel.h"
+#include "lltrans.h"
+// Callback struct
struct LLWearableArrivedData
{
- LLWearableArrivedData(
- LLAssetType::EType asset_type,
+ LLWearableArrivedData(LLAssetType::EType asset_type,
const std::string& wearable_name,
void(*asset_arrived_callback)(LLWearable*, void* userdata),
- void* userdata )
- :
+ void* userdata) :
mAssetType( asset_type ),
mCallback( asset_arrived_callback ),
mUserdata( userdata ),
@@ -69,18 +65,21 @@ struct LLWearableArrivedData
S32 mRetries;
};
-
-
////////////////////////////////////////////////////////////////////////////
// LLWearableList
LLWearableList::~LLWearableList()
{
+ llassert_always(mList.empty()) ;
+}
+
+void LLWearableList::cleanup()
+{
for_each(mList.begin(), mList.end(), DeletePairedPointer());
mList.clear();
}
-void LLWearableList::getAsset( const LLAssetID& assetID, const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata )
+void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata)
{
llassert( (asset_type == LLAssetType::AT_CLOTHING) || (asset_type == LLAssetType::AT_BODYPART) );
LLWearable* instance = get_if_there(mList, assetID, (LLWearable*)NULL );
@@ -90,8 +89,7 @@ void LLWearableList::getAsset( const LLAssetID& assetID, const std::string& wear
}
else
{
- gAssetStorage->getAssetData(
- assetID,
+ gAssetStorage->getAssetData(assetID,
asset_type,
LLWearableList::processGetAssetReply,
(void*)new LLWearableArrivedData( asset_type, wearable_name, asset_arrived_callback, userdata ),
@@ -110,8 +108,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
{
LL_WARNS("Wearable") << "Bad Wearable Asset: missing file." << LL_ENDL;
}
- else
- if( status >= 0 )
+ else if (status >= 0)
{
// read the file
LLFILE* fp = LLFile::fopen(std::string(filename), "rb"); /*Flawfinder: ignore*/
@@ -180,27 +177,26 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
if (wearable) // success
{
- gWearableList.mList[ uuid ] = wearable;
+ LLWearableList::instance().mList[ uuid ] = wearable;
LL_DEBUGS("Wearable") << "processGetAssetReply()" << LL_ENDL;
LL_DEBUGS("Wearable") << wearable << LL_ENDL;
}
else
{
LLSD args;
- // *TODO:translate
- args["TYPE"] = LLAssetType::lookupHumanReadable(data->mAssetType);
+ args["TYPE"] =LLTrans::getString(LLAssetType::lookupHumanReadable(data->mAssetType));
if (isNewWearable)
{
- LLNotifications::instance().add("InvalidWearable");
+ LLNotificationsUtil::add("InvalidWearable");
}
else if (data->mName.empty())
{
- LLNotifications::instance().add("FailedToFindWearableUnnamed", args);
+ LLNotificationsUtil::add("FailedToFindWearableUnnamed", args);
}
else
{
args["DESC"] = data->mName;
- LLNotifications::instance().add("FailedToFindWearable", args);
+ LLNotificationsUtil::add("FailedToFindWearable", args);
}
}
// Always call callback; wearable will be NULL if we failed
@@ -214,73 +210,18 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
}
-// Creates a new wearable just like the old_wearable but with data copied over from item
-LLWearable* LLWearableList::createWearableMatchedToInventoryItem( LLWearable* old_wearable, LLViewerInventoryItem* item )
+LLWearable* LLWearableList::createCopy(const LLWearable* old_wearable, const std::string& new_name)
{
- lldebugs << "LLWearableList::createWearableMatchedToInventoryItem()" << llendl;
-
- LLTransactionID tid;
- LLAssetID new_asset_id;
- new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
- LLWearable* wearable = new LLWearable( tid );
- wearable->copyDataFrom( old_wearable );
-
- wearable->setName( item->getName() );
- wearable->setDescription( item->getDescription() );
- wearable->setPermissions( item->getPermissions() );
- wearable->setSaleInfo( item->getSaleInfo() );
-
- mList[ new_asset_id ] = wearable;
-
- // Send to the dataserver
- wearable->saveNewAsset();
-
- return wearable;
-}
+ lldebugs << "LLWearableList::createCopy()" << llendl;
-LLWearable* LLWearableList::createCopyFromAvatar( LLWearable* old_wearable, const std::string& new_name )
-{
- lldebugs << "LLWearableList::createCopyFromAvatar()" << llendl;
+ LLWearable *wearable = generateNewWearable();
+ wearable->copyDataFrom(old_wearable);
- LLTransactionID tid;
- LLAssetID new_asset_id;
- tid.generate();
- new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
- LLWearable* wearable = new LLWearable( tid );
- wearable->copyDataFrom( old_wearable );
LLPermissions perm(old_wearable->getPermissions());
perm.setOwnerAndGroup(LLUUID::null, gAgent.getID(), LLUUID::null, true);
wearable->setPermissions(perm);
- wearable->readFromAvatar(); // update from the avatar
-
- if (!new_name.empty()) wearable->setName(new_name);
- mList[ new_asset_id ] = wearable;
-
- // Send to the dataserver
- wearable->saveNewAsset();
-
- return wearable;
-}
-
-
-LLWearable* LLWearableList::createCopy( LLWearable* old_wearable )
-{
- lldebugs << "LLWearableList::createCopy()" << llendl;
-
- LLTransactionID tid;
- LLAssetID new_asset_id;
- tid.generate();
- new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
- LLWearable* wearable = new LLWearable( tid );
- wearable->copyDataFrom( old_wearable );
- LLPermissions perm(old_wearable->getPermissions());
- perm.setOwnerAndGroup(LLUUID::null, gAgent.getID(), LLUUID::null, true);
- wearable->setPermissions(perm);
- mList[ new_asset_id ] = wearable;
+ if (!new_name.empty()) wearable->setName(new_name);
// Send to the dataserver
wearable->saveNewAsset();
@@ -292,12 +233,7 @@ LLWearable* LLWearableList::createNewWearable( EWearableType type )
{
lldebugs << "LLWearableList::createNewWearable()" << llendl;
- LLTransactionID tid;
- LLAssetID new_asset_id;
- tid.generate();
- new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
- LLWearable* wearable = new LLWearable( tid );
+ LLWearable *wearable = generateNewWearable();
wearable->setType( type );
std::string name = "New ";
@@ -310,14 +246,26 @@ LLWearable* LLWearableList::createNewWearable( EWearableType type )
wearable->setPermissions(perm);
// Description and sale info have default values.
-
wearable->setParamsToDefaults();
wearable->setTexturesToDefaults();
- mList[ new_asset_id ] = wearable;
+ //mark all values (params & images) as saved
+ wearable->saveValues();
// Send to the dataserver
wearable->saveNewAsset();
+
+ return wearable;
+}
+
+LLWearable *LLWearableList::generateNewWearable()
+{
+ LLTransactionID tid;
+ tid.generate();
+ LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
+
+ LLWearable* wearable = new LLWearable(tid);
+ mList[new_asset_id] = wearable;
return wearable;
}