summaryrefslogtreecommitdiff
path: root/indra/newview/llpostcard.cpp
diff options
context:
space:
mode:
authorGlenn Glazer <coyot@lindenlab.com>2016-04-07 12:10:13 -0700
committerGlenn Glazer <coyot@lindenlab.com>2016-04-07 12:10:13 -0700
commit369cefd5b3f2f52ae0dd203fcd45a4618f74b0f3 (patch)
tree941d27a32099abaf71bae8a2865002e2b25a3512 /indra/newview/llpostcard.cpp
parent0494a502aafac73800352dc26c4eb3a27b02a8ce (diff)
parent18928ea6c6f2830a0d45ec412c915eceff1b76b0 (diff)
pull from viewer-release
Diffstat (limited to 'indra/newview/llpostcard.cpp')
-rwxr-xr-xindra/newview/llpostcard.cpp124
1 files changed, 22 insertions, 102 deletions
diff --git a/indra/newview/llpostcard.cpp b/indra/newview/llpostcard.cpp
index 5987044bff..2e639b56eb 100755
--- a/indra/newview/llpostcard.cpp
+++ b/indra/newview/llpostcard.cpp
@@ -36,84 +36,36 @@
#include "llagent.h"
#include "llassetstorage.h"
-#include "llassetuploadresponders.h"
+#include "llviewerassetupload.h"
///////////////////////////////////////////////////////////////////////////////
-// misc
-static void postcard_upload_callback(const LLUUID& asset_id, void *user_data, S32 result, LLExtStat ext_status)
+LLPostcardUploadInfo::LLPostcardUploadInfo(std::string emailFrom, std::string nameFrom, std::string emailTo,
+ std::string subject, std::string message, LLVector3d globalPosition,
+ LLPointer<LLImageFormatted> image, invnUploadFinish_f finish) :
+ LLBufferedAssetUploadInfo(LLUUID::null, image, finish),
+ mEmailFrom(emailFrom),
+ mNameFrom(nameFrom),
+ mEmailTo(emailTo),
+ mSubject(subject),
+ mMessage(message),
+ mGlobalPosition(globalPosition)
{
- LLSD* postcard_data = (LLSD*)user_data;
-
- if (result)
- {
- // TODO: display the error messages in UI
- LL_WARNS() << "Failed to send postcard: " << LLAssetStorage::getErrorString(result) << LL_ENDL;
- LLPostCard::reportPostResult(false);
- }
- else
- {
- // only create the postcard once the upload succeeds
-
- // request the postcard
- const LLSD& data = *postcard_data;
- LLMessageSystem* msg = gMessageSystem;
- msg->newMessage("SendPostcard");
- msg->nextBlock("AgentData");
- msg->addUUID("AgentID", gAgent.getID());
- msg->addUUID("SessionID", gAgent.getSessionID());
- msg->addUUID("AssetID", data["asset-id"].asUUID());
- msg->addVector3d("PosGlobal", LLVector3d(data["pos-global"]));
- msg->addString("To", data["to"]);
- msg->addString("From", data["from"]);
- msg->addString("Name", data["name"]);
- msg->addString("Subject", data["subject"]);
- msg->addString("Msg", data["msg"]);
- msg->addBOOL("AllowPublish", FALSE);
- msg->addBOOL("MaturePublish", FALSE);
- gAgent.sendReliableMessage();
-
- LLPostCard::reportPostResult(true);
- }
-
- delete postcard_data;
}
-
-///////////////////////////////////////////////////////////////////////////////
-// LLPostcardSendResponder
-
-class LLPostcardSendResponder : public LLAssetUploadResponder
+LLSD LLPostcardUploadInfo::generatePostBody()
{
- LOG_CLASS(LLPostcardSendResponder);
-
-public:
- LLPostcardSendResponder(const LLSD &post_data,
- const LLUUID& vfile_id,
- LLAssetType::EType asset_type):
- LLAssetUploadResponder(post_data, vfile_id, asset_type)
- {
- }
-
- /*virtual*/ void httpFailure()
- {
- LL_WARNS() << "Sending postcard failed, status: " << getStatus() << LL_ENDL;
- LLPostCard::reportPostResult(false);
- }
-
- /*virtual*/ void uploadComplete(const LLSD& content)
- {
- LL_INFOS() << "Postcard sent" << LL_ENDL;
- LL_DEBUGS("Snapshots") << "content: " << content << LL_ENDL;
- LLPostCard::reportPostResult(true);
- }
+ LLSD postcard = LLSD::emptyMap();
+ postcard["pos-global"] = mGlobalPosition.getValue();
+ postcard["to"] = mEmailTo;
+ postcard["from"] = mEmailFrom;
+ postcard["name"] = mNameFrom;
+ postcard["subject"] = mSubject;
+ postcard["msg"] = mMessage;
+
+ return postcard;
+}
- /*virtual*/ void uploadFailure(const LLSD& content)
- {
- LL_WARNS() << "Sending postcard failed: " << content << LL_ENDL;
- LLPostCard::reportPostResult(false);
- }
-};
///////////////////////////////////////////////////////////////////////////////
// LLPostCard
@@ -121,38 +73,6 @@ public:
LLPostCard::result_callback_t LLPostCard::mResultCallback;
// static
-void LLPostCard::send(LLPointer<LLImageFormatted> image, const LLSD& postcard_data)
-{
- LLTransactionID transaction_id;
- LLAssetID asset_id;
-
- transaction_id.generate();
- asset_id = transaction_id.makeAssetID(gAgent.getSecureSessionID());
- LLVFile::writeFile(image->getData(), image->getDataSize(), gVFS, asset_id, LLAssetType::AT_IMAGE_JPEG);
-
- // upload the image
- std::string url = gAgent.getRegion()->getCapability("SendPostcard");
- if (!url.empty())
- {
- LL_INFOS() << "Sending postcard via capability" << LL_ENDL;
- // the capability already encodes: agent ID, region ID
- LL_DEBUGS("Snapshots") << "url: " << url << LL_ENDL;
- LL_DEBUGS("Snapshots") << "body: " << postcard_data << LL_ENDL;
- LL_DEBUGS("Snapshots") << "data size: " << image->getDataSize() << LL_ENDL;
- LLHTTPClient::post(url, postcard_data,
- new LLPostcardSendResponder(postcard_data, asset_id, LLAssetType::AT_IMAGE_JPEG));
- }
- else
- {
- LL_INFOS() << "Sending postcard" << LL_ENDL;
- LLSD* data = new LLSD(postcard_data);
- (*data)["asset-id"] = asset_id;
- gAssetStorage->storeAssetData(transaction_id, LLAssetType::AT_IMAGE_JPEG,
- &postcard_upload_callback, (void *)data, FALSE);
- }
-}
-
-// static
void LLPostCard::reportPostResult(bool ok)
{
if (mResultCallback)