summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Wolk <jwolk@lindenlab.com>2009-11-03 19:36:39 +0000
committerJon Wolk <jwolk@lindenlab.com>2009-11-03 19:36:39 +0000
commit9c3595465972ba4be916e871f6b0a62cc0c13d4a (patch)
tree877661f1a3529783d079917551f28887f2cb11c3
parent3e80fa3dbc943de9b784fedc202ba38cf238f46d (diff)
Changed variable price upload responders to reflect server changes. I hope this gets pulled into the hg repository
-rw-r--r--indra/newview/llassetuploadresponders.cpp176
-rw-r--r--indra/newview/llassetuploadresponders.h3
-rw-r--r--indra/newview/llviewermenufile.cpp138
-rw-r--r--indra/newview/llviewermenufile.h16
4 files changed, 212 insertions, 121 deletions
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index cb03379b23..680d1acd81 100644
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -72,7 +72,7 @@ static const S32 FILE_COUNT_DISPLAY_THRESHOLD = 5;
void dialog_refresh_all();
-void on_new_single_inventory_upload_complete(
+static void on_new_single_inventory_upload_complete(
LLAssetType::EType asset_type,
LLInventoryType::EType inventory_type,
const std::string inventory_type_string,
@@ -736,22 +736,103 @@ public:
LLUploadDialog::modalUploadFinished();
}
- void onApplicationLevelError(const std::string& error_identifier)
+ void onApplicationLevelError(const LLSD& error)
{
- // TODO*: Pull these user visible strings from an xml file
- // to be localized
+ static const std::string _IDENTIFIER = "identifier";
+
static const std::string _INSUFFICIENT_FUNDS =
"NewAgentInventory_InsufficientLindenDollarBalance";
+ static const std::string _MISSING_REQUIRED_PARAMETER =
+ "NewAgentInventory_MissingRequiredParamater";
+ static const std::string _INVALID_REQUEST_BODY =
+ "NewAgentInventory_InvalidRequestBody";
+ static const std::string _RESOURCE_COST_DIFFERS =
+ "NewAgentInventory_ResourceCostDiffers";
+
+ static const std::string _MISSING_PARAMETER = "missing_parameter";
+ static const std::string _INVALID_PARAMETER = "invalid_parameter";
+ static const std::string _MISSING_RESOURCE = "missing_resource";
+ static const std::string _INVALID_RESOURCE = "invalid_resource";
+
+ // TODO* Add the other error_identifiers
+ std::string error_identifier = error[_IDENTIFIER].asString();
+ // TODO*: Pull these user visible strings from an xml file
+ // to be localized
if ( _INSUFFICIENT_FUNDS == error_identifier )
{
displayCannotUploadReason("You do not have a sufficient L$ balance to complete this upload.");
}
+ else if ( _MISSING_REQUIRED_PARAMETER == error_identifier )
+ {
+ // Missing parameters
+ if (error.has(_MISSING_PARAMETER) )
+ {
+ std::string message =
+ "Upload request was missing required parameter '[P]'";
+ LLStringUtil::replaceString(
+ message,
+ "[P]",
+ error[_MISSING_PARAMETER].asString());
+
+ displayCannotUploadReason(message);
+ }
+ else
+ {
+ std::string message =
+ "Upload request was missing a required parameter";
+ displayCannotUploadReason(message);
+ }
+ }
+ else if ( _INVALID_REQUEST_BODY == error_identifier )
+ {
+ // Invalid request body, check to see if
+ // a particular parameter was invalid
+ if ( error.has(_INVALID_PARAMETER) )
+ {
+ std::string message = "Upload parameter '[P]' is invalid.";
+ LLStringUtil::replaceString(
+ message,
+ "[P]",
+ error[_INVALID_PARAMETER].asString());
+
+ // See if the server also responds with what resource
+ // is missing.
+ if ( error.has(_MISSING_RESOURCE) )
+ {
+ message += "\nMissing resource '[R]'.";
+
+ LLStringUtil::replaceString(
+ message,
+ "[R]",
+ error[_MISSING_RESOURCE].asString());
+ }
+ else if ( error.has(_INVALID_RESOURCE) )
+ {
+ message += "\nInvalid resource '[R]'.";
+
+ LLStringUtil::replaceString(
+ message,
+ "[R]",
+ error[_INVALID_RESOURCE].asString());
+ }
+
+ displayCannotUploadReason(message);
+ }
+ else
+ {
+ std::string message = "Upload request was malformed";
+ displayCannotUploadReason(message);
+ }
+ }
+ else if ( _RESOURCE_COST_DIFFERS == error_identifier )
+ {
+ displayCannotUploadReason("The resource cost associated with this upload is not consistent with the server.");
+ }
else
{
displayCannotUploadReason("Unknown Error");
-
}
}
@@ -761,14 +842,18 @@ public:
"The server is experiencing unexpected difficulties.");
}
- void onTransportError(const std::string& error_identifier)
+ void onTransportError(const LLSD& error)
{
- // TODO*: Pull these user visible strings from an xml file
- // to be localized
+ static const std::string _IDENTIFIER = "identifier";
static const std::string _SERVER_ERROR_AFTER_CHARGE =
"NewAgentInventory_ServerErrorAfterCharge";
+ std::string error_identifier = error[_IDENTIFIER].asString();
+
+ // TODO*: Pull the user visible strings from an xml file
+ // to be localized
+
if ( _SERVER_ERROR_AFTER_CHARGE == error_identifier )
{
displayCannotUploadReason(
@@ -779,7 +864,6 @@ public:
displayCannotUploadReason(
"The server is experiencing unexpected difficulties.");
}
-
}
bool uploadConfirmationCallback(
@@ -798,17 +882,26 @@ public:
notification["payload"]["confirmation_url"].asString();
// Yay! We are confirming or cancelling our upload
- LLSD body;
-
- body["confirm_upload"] = false;
-
switch(option)
{
case 0:
{
- body["confirm_upload"] = true;
- body["expected_upload_price"] =
- notification["payload"]["expected_upload_price"];
+ if ( getFilename().empty() )
+ {
+ // we have no filename, use virtual file ID instead
+ LLHTTPClient::postFile(
+ confirmation_url,
+ getVFileID(),
+ getAssetType(),
+ responder);
+ }
+ else
+ {
+ LLHTTPClient::postFile(
+ confirmation_url,
+ getFilename(),
+ responder);
+ }
}
break;
case 1:
@@ -816,8 +909,6 @@ public:
break;
}
- LLHTTPClient::post(confirmation_url, body, responder);
-
return false;
}
@@ -865,9 +956,8 @@ void LLNewAgentInventoryVariablePriceResponder::errorWithContent(
if ( content.has("error") )
{
static const std::string _ERROR = "error";
- static const std::string _IDENTIFIER = "identifier";
- mImpl->onTransportError(content[_ERROR][_IDENTIFIER].asString());
+ mImpl->onTransportError(content[_ERROR]);
}
else
{
@@ -880,52 +970,25 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
// Parse out application level errors and the appropriate
// responses for them
static const std::string _ERROR = "error";
- static const std::string _IDENTIFIER = "identifier";
static const std::string _STATE = "state";
static const std::string _COMPLETE = "complete";
- static const std::string _COST_ANALYSIS = "cost_analysis";
- static const std::string _NEEDS_CONFIRMATION = "needs_confirmation";
- static const std::string _CANCEL = "cancel";
+ static const std::string _CONFIRM_UPLOAD = "confirm_upload";
- static const std::string _RESOURCE_COST = "resource_cost";
static const std::string _UPLOAD_PRICE = "upload_price";
-
- static const std::string _ANALYZER = "analyzer";
static const std::string _RSVP = "rsvp";
// Check for application level errors
if ( content.has(_ERROR) )
{
- onApplicationLevelError(content[_ERROR][_IDENTIFIER].asString());
+ onApplicationLevelError(content[_ERROR]);
return;
}
std::string state = content[_STATE];
LLAssetType::EType asset_type = mImpl->getAssetType();
- if ( _COST_ANALYSIS == state )
- {
- std::string analyzer_url = content[_ANALYZER];
-
- if ( mImpl->getFilename().empty() )
- {
- // we have no filename, use virtual file ID instead
- LLHTTPClient::postFile(
- analyzer_url,
- mImpl->getVFileID(),
- asset_type,
- this);
- }
- else
- {
- LLHTTPClient::postFile(
- analyzer_url,
- mImpl->getFilename(),
- this);
- }
- }
- else if ( _COMPLETE == state )
+ if ( _COMPLETE == state )
{
// rename file in VFS with new asset id
if (mImpl->getFilename().empty())
@@ -952,17 +1015,12 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
// TODO* Add bulk (serial) uploading or add
// a super class of this that does so
}
- else if ( _NEEDS_CONFIRMATION == state )
+ else if ( _CONFIRM_UPLOAD == state )
{
showConfirmationDialog(
content[_UPLOAD_PRICE].asInteger(),
- content[_RESOURCE_COST].asInteger(),
content[_RSVP].asString());
}
- else if ( _CANCEL == state )
- {
- // cancelled, do nothing
- }
else
{
onApplicationLevelError("");
@@ -970,14 +1028,13 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
}
void LLNewAgentInventoryVariablePriceResponder::onApplicationLevelError(
- const std::string& error_identifier)
+ const LLSD& error)
{
- mImpl->onApplicationLevelError(error_identifier);
+ mImpl->onApplicationLevelError(error);
}
void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
S32 upload_price,
- S32 resource_cost,
const std::string& confirmation_url)
{
if ( 0 == upload_price )
@@ -998,7 +1055,6 @@ void LLNewAgentInventoryVariablePriceResponder::showConfirmationDialog(
substitutions["PRICE"] = upload_price;
payload["confirmation_url"] = confirmation_url;
- payload["expected_upload_price"] = upload_price;
// The creating of a new instrusive_ptr(this)
// creates a new boost::intrusive_ptr
diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h
index adbf13519b..04636d4977 100644
--- a/indra/newview/llassetuploadresponders.h
+++ b/indra/newview/llassetuploadresponders.h
@@ -102,10 +102,9 @@ public:
void result(const LLSD& content);
virtual void onApplicationLevelError(
- const std::string& error_identifier);
+ const LLSD& error);
virtual void showConfirmationDialog(
S32 upload_price,
- S32 resource_cost,
const std::string& confirmation_url);
private:
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 836ac79a87..7b9494c02a 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -964,60 +964,24 @@ void upload_done_callback(
}
}
-LLAssetID upload_new_resource_prep(
- const LLTransactionID &tid,
+static LLAssetID upload_new_resource_prep(
+ const LLTransactionID& tid,
LLAssetType::EType asset_type,
LLInventoryType::EType& inventory_type,
std::string& name,
const std::string& display_name,
std::string& description)
{
- if ( gDisconnected )
- {
- LLAssetID rv;
+ LLAssetID uuid = generate_asset_id_for_new_upload(tid);
- rv.setNull();
- return rv;
- }
+ increase_new_upload_stats(asset_type);
- LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());
-
- if ( LLAssetType::AT_SOUND == asset_type )
- {
- LLViewerStats::getInstance()->incStat(
- LLViewerStats::ST_UPLOAD_SOUND_COUNT );
- }
- else if ( LLAssetType::AT_TEXTURE == asset_type )
- {
- LLViewerStats::getInstance()->incStat(
- LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
- }
- else if ( LLAssetType::AT_ANIMATION == asset_type )
- {
- LLViewerStats::getInstance()->incStat(
- LLViewerStats::ST_UPLOAD_ANIM_COUNT );
- }
-
- if ( LLInventoryType::IT_NONE == inventory_type )
- {
- inventory_type = LLInventoryType::defaultForAssetType(asset_type);
- }
- LLStringUtil::stripNonprintable(name);
- LLStringUtil::stripNonprintable(description);
-
- if ( name.empty() )
- {
- name = "(No Name)";
- }
- if ( description.empty() )
- {
- description = "(No Description)";
- }
-
- // At this point, we're ready for the upload.
- std::string upload_message = "Uploading...\n\n";
- upload_message.append(display_name);
- LLUploadDialog::modalUploadDialog(upload_message);
+ assign_defaults_and_show_upload_message(
+ asset_type,
+ inventory_type,
+ name,
+ display_name,
+ description);
return uuid;
}
@@ -1146,27 +1110,27 @@ void upload_new_resource(
{
asset_callback = callback;
}
- gAssetStorage->storeAssetData(data->mAssetInfo.mTransactionID, data->mAssetInfo.mType,
- asset_callback,
- (void*)data,
- FALSE);
+ gAssetStorage->storeAssetData(
+ data->mAssetInfo.mTransactionID,
+ data->mAssetInfo.mType,
+ asset_callback,
+ (void*)data,
+ FALSE);
}
}
-BOOL upload_new_variable_cost_resource(
+BOOL upload_new_variable_price_resource(
const LLTransactionID &tid,
LLAssetType::EType asset_type,
std::string name,
std::string desc,
- S32 compression_info,
LLAssetType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perms,
U32 group_perms,
U32 everyone_perms,
const std::string& display_name,
- LLAssetStorage::LLStoreAssetCallback callback,
- void *userdata)
+ const LLSD& asset_resources)
{
LLAssetID uuid =
upload_new_resource_prep(
@@ -1209,6 +1173,8 @@ BOOL upload_new_variable_cost_resource(
group_perms,
everyone_perms);
+ body["asset_resources"] = asset_resources;
+
LLHTTPClient::post(
url,
body,
@@ -1224,6 +1190,70 @@ BOOL upload_new_variable_cost_resource(
}
}
+LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid)
+{
+ if ( gDisconnected )
+ {
+ LLAssetID rv;
+
+ rv.setNull();
+ return rv;
+ }
+
+ LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID());
+
+ return uuid;
+}
+
+void increase_new_upload_stats(LLAssetType::EType asset_type)
+{
+ if ( LLAssetType::AT_SOUND == asset_type )
+ {
+ LLViewerStats::getInstance()->incStat(
+ LLViewerStats::ST_UPLOAD_SOUND_COUNT );
+ }
+ else if ( LLAssetType::AT_TEXTURE == asset_type )
+ {
+ LLViewerStats::getInstance()->incStat(
+ LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
+ }
+ else if ( LLAssetType::AT_ANIMATION == asset_type )
+ {
+ LLViewerStats::getInstance()->incStat(
+ LLViewerStats::ST_UPLOAD_ANIM_COUNT );
+ }
+}
+
+void assign_defaults_and_show_upload_message(
+ LLAssetType::EType asset_type,
+ LLInventoryType::EType& inventory_type,
+ std::string& name,
+ const std::string& display_name,
+ std::string& description)
+{
+ if ( LLInventoryType::IT_NONE == inventory_type )
+ {
+ inventory_type = LLInventoryType::defaultForAssetType(asset_type);
+ }
+ LLStringUtil::stripNonprintable(name);
+ LLStringUtil::stripNonprintable(description);
+
+ if ( name.empty() )
+ {
+ name = "(No Name)";
+ }
+ if ( description.empty() )
+ {
+ description = "(No Description)";
+ }
+
+ // At this point, we're ready for the upload.
+ std::string upload_message = "Uploading...\n\n";
+ upload_message.append(display_name);
+ LLUploadDialog::modalUploadDialog(upload_message);
+}
+
+
void init_menu_file()
{
view_listener_t::addCommit(new LLFileUploadImage(), "File.UploadImage");
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index b51192b499..858fcd51de 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -77,20 +77,26 @@ void upload_new_resource(
// used
// We make a new function here to ensure that previous code is not broken
-BOOL upload_new_variable_cost_resource(
- const LLTransactionID &tid,
+BOOL upload_new_variable_price_resource(
+ const LLTransactionID& tid,
LLAssetType::EType type,
std::string name,
std::string desc,
- S32 compression_info,
LLAssetType::EType destination_folder_type,
LLInventoryType::EType inv_type,
U32 next_owner_perms,
U32 group_perms,
U32 everyone_perms,
const std::string& display_name,
- LLAssetStorage::LLStoreAssetCallback callback,
- void *userdata);
+ const LLSD& asset_resources);
+LLAssetID generate_asset_id_for_new_upload(const LLTransactionID& tid);
+void increase_new_upload_stats(LLAssetType::EType asset_type);
+void assign_defaults_and_show_upload_message(
+ LLAssetType::EType asset_type,
+ LLInventoryType::EType& inventory_type,
+ std::string& name,
+ const std::string& display_name,
+ std::string& description);
#endif