summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatersnapshot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatersnapshot.cpp')
-rw-r--r--indra/newview/llfloatersnapshot.cpp102
1 files changed, 89 insertions, 13 deletions
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 2df297fc42..948f3f56d4 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -39,6 +39,7 @@
// Viewer includes
#include "llagent.h"
#include "llagentui.h"
+#include "llavatarpropertiesprocessor.h"
#include "llbottomtray.h"
#include "llbutton.h"
#include "llcallbacklist.h"
@@ -166,7 +167,7 @@ public:
void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; }
void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f);
LLFloaterPostcard* savePostcard();
- void saveTexture();
+ void saveTexture(bool set_as_profile_pic = false);
BOOL saveLocal();
void saveWeb(std::string url);
@@ -974,13 +975,21 @@ LLFloaterPostcard* LLSnapshotLivePreview::savePostcard()
return floater;
}
-void LLSnapshotLivePreview::saveTexture()
+// Callback for asset upload
+void profile_pic_upload_callback(const LLUUID& uuid)
+{
+ LLFloaterSnapshot* floater = LLFloaterReg::getTypedInstance<LLFloaterSnapshot>("snapshot");
+ floater->setAsProfilePic(uuid);
+}
+
+
+void LLSnapshotLivePreview::saveTexture(bool set_as_profile_pic)
{
// gen a new uuid for this asset
LLTransactionID tid;
tid.generate();
LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-
+
LLPointer<LLImageJ2C> formatted = new LLImageJ2C;
LLPointer<LLImageRaw> scaled = new LLImageRaw(mPreviewImage->getData(),
mPreviewImage->getWidth(),
@@ -991,26 +1000,30 @@ void LLSnapshotLivePreview::saveTexture()
if (formatted->encode(scaled, 0.0f))
{
+ boost::function<void(const LLUUID& uuid)> callback = NULL;
+
+ if (set_as_profile_pic)
+ {
+ callback = profile_pic_upload_callback;
+ }
+
LLVFile::writeFile(formatted->getData(), formatted->getDataSize(), gVFS, new_asset_id, LLAssetType::AT_TEXTURE);
std::string pos_string;
LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL);
std::string who_took_it;
LLAgentUI::buildFullname(who_took_it);
- LLAssetStorage::LLStoreAssetCallback callback = NULL;
S32 expected_upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
- void *userdata = NULL;
upload_new_resource(tid, // tid
LLAssetType::AT_TEXTURE,
"Snapshot : " + pos_string,
"Taken by " + who_took_it + " at " + pos_string,
- 0,
LLFolderType::FT_SNAPSHOT_CATEGORY,
LLInventoryType::IT_SNAPSHOT,
PERM_ALL, // Note: Snapshots to inventory is a special case of content upload
PERM_NONE, // that ignores the user's premissions preferences and continues to
PERM_NONE, // always use these fairly permissive hard-coded initial perms. - MG
"Snapshot : " + pos_string,
- callback, expected_upload_cost, userdata);
+ callback, expected_upload_cost);
gViewerWindow->playSnapshotAnimAndSound();
}
else
@@ -1151,6 +1164,7 @@ public:
static void onCommitSnapshotFormat(LLUICtrl* ctrl, void* data);
static void onCommitCustomResolution(LLUICtrl *ctrl, void* data);
static void onCommitSnapshot(LLFloaterSnapshot* view, LLSnapshotLivePreview::ESnapshotType type);
+ static void onCommitProfilePic(LLFloaterSnapshot* view);
static void onToggleAdvanced(LLUICtrl *ctrl, void* data);
static void resetSnapshotSizeOnUI(LLFloaterSnapshot *view, S32 width, S32 height) ;
static BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value);
@@ -1661,6 +1675,60 @@ void LLFloaterSnapshot::Impl::onToggleAdvanced(LLUICtrl* ctrl, void* data)
}
}
+// This object represents a pending request for avatar properties information
+class LLAvatarDataRequest : public LLAvatarPropertiesObserver
+{
+public:
+ LLAvatarDataRequest(const LLUUID& avatar_id, const LLUUID& image_id, LLFloaterSnapshot* floater)
+ : mAvatarID(avatar_id),
+ mImageID(image_id),
+ mSnapshotFloater(floater)
+
+ {
+ }
+
+ ~LLAvatarDataRequest()
+ {
+ // remove ourselves as an observer
+ LLAvatarPropertiesProcessor::getInstance()->
+ removeObserver(mAvatarID, this);
+ }
+
+ void processProperties(void* data, EAvatarProcessorType type)
+ {
+ // route the data to the inspector
+ if (data
+ && type == APT_PROPERTIES)
+ {
+
+ LLAvatarData* avatar_data = static_cast<LLAvatarData*>(data);
+
+ LLAvatarData new_data(*avatar_data);
+ new_data.image_id = mImageID;
+
+ LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate(&new_data);
+
+ delete this;
+ }
+ }
+
+ // Store avatar ID so we can un-register the observer on destruction
+ LLUUID mAvatarID;
+ LLUUID mImageID;
+ LLFloaterSnapshot* mSnapshotFloater;
+};
+
+void LLFloaterSnapshot::Impl::onCommitProfilePic(LLFloaterSnapshot* view)
+{
+ //first save to harddrive
+ LLSnapshotLivePreview* previewp = getPreviewView(view);
+
+ if(previewp)
+ {
+ previewp->saveTexture(true);
+ }
+}
+
void LLFloaterSnapshot::Impl::onCommitSnapshot(LLFloaterSnapshot* view, LLSnapshotLivePreview::ESnapshotType type)
{
LLSnapshotLivePreview* previewp = getPreviewView(view);
@@ -1717,8 +1785,6 @@ void LLFloaterSnapshot::Impl::onCommitSnapshotFormat(LLUICtrl* ctrl, void* data)
}
}
-
-
// Sets the named size combo to "custom" mode.
// static
void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const std::string& comboname)
@@ -1732,8 +1798,6 @@ void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const s
checkAspectRatio(floater, -1); // -1 means custom
}
-
-
//static
BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value)
{
@@ -1925,7 +1989,8 @@ BOOL LLFloaterSnapshot::postBuild()
getChild<LLButton>("share_to_email")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_POSTCARD));
getChild<LLButton>("save_to_inventory")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_TEXTURE));
getChild<LLButton>("save_to_computer")->setCommitCallback(boost::bind(&Impl::onCommitSnapshot, this, LLSnapshotLivePreview::SNAPSHOT_LOCAL));
-
+ getChild<LLButton>("set_profile_pic")->setCommitCallback(boost::bind(&Impl::onCommitProfilePic, this));
+
childSetCommitCallback("show_advanced", Impl::onToggleAdvanced, this);
childSetCommitCallback("hide_advanced", Impl::onToggleAdvanced, this);
@@ -2082,7 +2147,6 @@ void LLFloaterSnapshot::update()
}
}
-
bool LLFloaterSnapshot::updateButtons(ESnapshotMode mode)
{
childSetVisible("share", mode == SNAPSHOT_MAIN);
@@ -2099,6 +2163,18 @@ bool LLFloaterSnapshot::updateButtons(ESnapshotMode mode)
return true;
}
+
+void LLFloaterSnapshot::setAsProfilePic(const LLUUID& image_id)
+{
+ LLAvatarDataRequest* avatar_data_request = new LLAvatarDataRequest(gAgent.getID(), image_id, this);
+
+ LLAvatarPropertiesProcessor* processor =
+ LLAvatarPropertiesProcessor::getInstance();
+
+ processor->addObserver(gAgent.getID(), avatar_data_request);
+ processor->sendAvatarPropertiesRequest(gAgent.getID());
+}
+
///----------------------------------------------------------------------------
/// Class LLSnapshotFloaterView
///----------------------------------------------------------------------------