summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xindra/newview/llpanelsnapshotfacebook.cpp11
-rwxr-xr-xindra/newview/llviewermenu.cpp6
-rwxr-xr-xindra/newview/llwebprofile.cpp45
-rwxr-xr-xindra/newview/llwebprofile.h5
4 files changed, 53 insertions, 14 deletions
diff --git a/indra/newview/llpanelsnapshotfacebook.cpp b/indra/newview/llpanelsnapshotfacebook.cpp
index 27abbfa456..b434741538 100755
--- a/indra/newview/llpanelsnapshotfacebook.cpp
+++ b/indra/newview/llpanelsnapshotfacebook.cpp
@@ -64,6 +64,7 @@ private:
/*virtual*/ void updateControls(const LLSD& info);
void onSend();
+ void onImageUploaded(const std::string& caption, const std::string& image_url);
};
static LLRegisterPanelClassWrapper<LLPanelSnapshotFacebook> panel_class("llpanelsnapshotfacebook");
@@ -99,9 +100,17 @@ void LLPanelSnapshotFacebook::onSend()
std::string caption = getChild<LLUICtrl>("caption")->getValue().asString();
bool add_location = getChild<LLUICtrl>("add_location_cb")->getValue().asBoolean();
- LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location);
+ LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location, boost::bind(&LLPanelSnapshotFacebook::onImageUploaded, this, caption, _1));
LLFloaterSnapshot::postSave();
// test with a placeholder image, until we can figure out a way to grab the uploaded image url
LLFacebookConnect::instance().sharePhoto("http://fc02.deviantart.net/fs43/i/2009/125/a/9/Future_of_Frog_by_axcho.jpg", caption);
}
+
+void LLPanelSnapshotFacebook::onImageUploaded(const std::string& caption, const std::string& image_url)
+{
+ if (!image_url.empty())
+ {
+ LLFacebookConnect::instance().sharePhoto(image_url, caption);
+ }
+}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index bc2e13d77e..1bfa5ac2d1 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5997,8 +5997,12 @@ void handle_facebook_checkin()
std::string region_name = gAgent.getRegion()->getName();
std::string description;
LLAgentUI::buildLocationString(description, LLAgentUI::LOCATION_FORMAT_NORMAL_COORDS, gAgent.getPositionAgent());
+ LLVector3d center_agent = gAgent.getRegion()->getCenterGlobal();
+ int x_pos = center_agent[0] / 256.0;
+ int y_pos = center_agent[1] / 256.0;
+ std::string locationMap = llformat("http://map.secondlife.com/map-1-%d-%d-objects.jpg", x_pos, y_pos);
- LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQDL4jdC_vCh0ow-QCXZjN-WNojEXWiz0APEa6Qhpl8cxawjkoC7w", "");
+ LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, locationMap, "");
}
void handle_buy_currency()
diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp
index 641f338f2c..6923724de2 100755
--- a/indra/newview/llwebprofile.cpp
+++ b/indra/newview/llwebprofile.cpp
@@ -62,8 +62,8 @@ class LLWebProfileResponders::ConfigResponder : public LLHTTPClient::Responder
LOG_CLASS(LLWebProfileResponders::ConfigResponder);
public:
- ConfigResponder(LLPointer<LLImageFormatted> imagep)
- : mImagep(imagep)
+ ConfigResponder(LLPointer<LLImageFormatted> imagep, LLWebProfile::image_url_callback_t cb)
+ : mImagep(imagep), mImageCallback(cb)
{
}
@@ -113,11 +113,12 @@ public:
// Do the actual image upload using the configuration.
LL_DEBUGS("Snapshots") << "Got upload config, POSTing image to " << upload_url << ", config=[" << config << "]" << llendl;
- LLWebProfile::post(mImagep, config, upload_url);
+ LLWebProfile::post(mImagep, config, upload_url, mImageCallback);
}
private:
LLPointer<LLImageFormatted> mImagep;
+ LLWebProfile::image_url_callback_t mImageCallback;
};
///////////////////////////////////////////////////////////////////////////////
@@ -127,6 +128,22 @@ class LLWebProfileResponders::PostImageRedirectResponder : public LLHTTPClient::
LOG_CLASS(LLWebProfileResponders::PostImageRedirectResponder);
public:
+ PostImageRedirectResponder(LLWebProfile::image_url_callback_t cb)
+ : mImageCallback(cb)
+ {
+ }
+
+ /*virtual*/ void completedHeader(U32 status, const std::string& reason, const LLSD& content)
+ {
+ if (status == 200)
+ {
+ std::string image_url = content.get("Location");
+ llinfos << "Image uploaded to " << image_url << llendl;
+ if (!mImageCallback.empty() && !image_url.empty())
+ mImageCallback(image_url);
+ }
+ }
+
/*virtual*/ void completedRaw(
U32 status,
const std::string& reason,
@@ -148,9 +165,9 @@ public:
LL_DEBUGS("Snapshots") << "Uploading image succeeded. Response: [" << body << "]" << llendl;
LLWebProfile::reportImageUploadStatus(true);
}
-
+
private:
- LLPointer<LLImageFormatted> mImagep;
+ LLWebProfile::image_url_callback_t mImageCallback;
};
@@ -161,6 +178,11 @@ class LLWebProfileResponders::PostImageResponder : public LLHTTPClient::Responde
LOG_CLASS(LLWebProfileResponders::PostImageResponder);
public:
+ PostImageResponder(LLWebProfile::image_url_callback_t cb)
+ : mImageCallback(cb)
+ {
+ }
+
/*virtual*/ void completedHeader(U32 status, const std::string& reason, const LLSD& content)
{
// Viewer seems to fail to follow a 303 redirect on POST request
@@ -172,7 +194,7 @@ public:
headers["Cookie"] = LLWebProfile::getAuthCookie();
const std::string& redir_url = content["location"];
LL_DEBUGS("Snapshots") << "Got redirection URL: " << redir_url << llendl;
- LLHTTPClient::get(redir_url, new LLWebProfileResponders::PostImageRedirectResponder, headers);
+ LLHTTPClient::get(redir_url, new LLWebProfileResponders::PostImageRedirectResponder(mImageCallback), headers);
}
else
{
@@ -188,6 +210,9 @@ public:
const LLIOPipe::buffer_ptr_t& buffer)
{
}
+
+private:
+ LLWebProfile::image_url_callback_t mImageCallback;
};
///////////////////////////////////////////////////////////////////////////////
@@ -197,7 +222,7 @@ std::string LLWebProfile::sAuthCookie;
LLWebProfile::status_callback_t LLWebProfile::mStatusCallback;
// static
-void LLWebProfile::uploadImage(LLPointer<LLImageFormatted> image, const std::string& caption, bool add_location)
+void LLWebProfile::uploadImage(LLPointer<LLImageFormatted> image, const std::string& caption, bool add_location, LLWebProfile::image_url_callback_t cb)
{
// Get upload configuration data.
std::string config_url(getProfileURL(LLStringUtil::null) + "snapshots/s3_upload_config");
@@ -207,7 +232,7 @@ void LLWebProfile::uploadImage(LLPointer<LLImageFormatted> image, const std::str
LL_DEBUGS("Snapshots") << "Requesting " << config_url << llendl;
LLSD headers = LLViewerMedia::getHeaders();
headers["Cookie"] = getAuthCookie();
- LLHTTPClient::get(config_url, new LLWebProfileResponders::ConfigResponder(image), headers);
+ LLHTTPClient::get(config_url, new LLWebProfileResponders::ConfigResponder(image, cb), headers);
}
// static
@@ -218,7 +243,7 @@ void LLWebProfile::setAuthCookie(const std::string& cookie)
}
// static
-void LLWebProfile::post(LLPointer<LLImageFormatted> image, const LLSD& config, const std::string& url)
+void LLWebProfile::post(LLPointer<LLImageFormatted> image, const LLSD& config, const std::string& url, LLWebProfile::image_url_callback_t cb)
{
if (dynamic_cast<LLImagePNG*>(image.get()) == 0)
{
@@ -284,7 +309,7 @@ void LLWebProfile::post(LLPointer<LLImageFormatted> image, const LLSD& config, c
memcpy(data, body.str().data(), size);
// Send request, successful upload will trigger posting metadata.
- LLHTTPClient::postRaw(url, data, size, new LLWebProfileResponders::PostImageResponder(), headers);
+ LLHTTPClient::postRaw(url, data, size, new LLWebProfileResponders::PostImageResponder(cb), headers);
}
// static
diff --git a/indra/newview/llwebprofile.h b/indra/newview/llwebprofile.h
index 10279bffac..63dccf80af 100755
--- a/indra/newview/llwebprofile.h
+++ b/indra/newview/llwebprofile.h
@@ -48,8 +48,9 @@ class LLWebProfile
public:
typedef boost::function<void(bool ok)> status_callback_t;
+ typedef boost::function<void(const std::string& image_url)> image_url_callback_t;
- static void uploadImage(LLPointer<LLImageFormatted> image, const std::string& caption, bool add_location);
+ static void uploadImage(LLPointer<LLImageFormatted> image, const std::string& caption, bool add_location, image_url_callback_t cb = image_url_callback_t());
static void setAuthCookie(const std::string& cookie);
static void setImageUploadResultCallback(status_callback_t cb) { mStatusCallback = cb; }
@@ -58,7 +59,7 @@ private:
friend class LLWebProfileResponders::PostImageResponder;
friend class LLWebProfileResponders::PostImageRedirectResponder;
- static void post(LLPointer<LLImageFormatted> image, const LLSD& config, const std::string& url);
+ static void post(LLPointer<LLImageFormatted> image, const LLSD& config, const std::string& url, image_url_callback_t cb);
static void reportImageUploadStatus(bool ok);
static std::string getAuthCookie();