Pull merge from lindenlab/viewer-fbc
commit
ae4c17dee1
|
|
@ -44,6 +44,7 @@
|
|||
#include "llfloaterreg.h"
|
||||
|
||||
boost::scoped_ptr<LLEventPump> LLFacebookConnect::sStateWatcher(new LLEventStream("FacebookConnectState"));
|
||||
boost::scoped_ptr<LLEventPump> LLFacebookConnect::sInfoWatcher(new LLEventStream("FacebookConnectInfo"));
|
||||
boost::scoped_ptr<LLEventPump> LLFacebookConnect::sContentWatcher(new LLEventStream("FacebookConnectContent"));
|
||||
|
||||
// Local functions
|
||||
|
|
@ -244,6 +245,36 @@ private:
|
|||
bool mAutoConnect;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
class LLFacebookInfoResponder : public LLHTTPClient::Responder
|
||||
{
|
||||
LOG_CLASS(LLFacebookInfoResponder);
|
||||
public:
|
||||
|
||||
virtual void completed(U32 status, const std::string& reason, const LLSD& info)
|
||||
{
|
||||
if (isGoodStatus(status))
|
||||
{
|
||||
llinfos << "Facebook: Info received" << llendl;
|
||||
LL_DEBUGS("FacebookConnect") << "Getting Facebook info successful. info: " << info << LL_ENDL;
|
||||
LLFacebookConnect::instance().storeInfo(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_facebook_connect_error("Info", status, reason, info.get("error_code"), info.get("error_description"));
|
||||
}
|
||||
}
|
||||
|
||||
void completedHeader(U32 status, const std::string& reason, const LLSD& content)
|
||||
{
|
||||
if (status == 302)
|
||||
{
|
||||
LLFacebookConnect::instance().openFacebookWeb(content["location"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
class LLFacebookFriendsResponder : public LLHTTPClient::Responder
|
||||
|
|
@ -333,6 +364,14 @@ void LLFacebookConnect::checkConnectionToFacebook(bool auto_connect)
|
|||
}
|
||||
}
|
||||
|
||||
void LLFacebookConnect::loadFacebookInfo()
|
||||
{
|
||||
const bool follow_redirects = false;
|
||||
const F32 timeout = HTTP_REQUEST_EXPIRY_SECS;
|
||||
LLHTTPClient::get(getFacebookConnectURL("/info"), new LLFacebookInfoResponder(),
|
||||
LLSD(), timeout, follow_redirects);
|
||||
}
|
||||
|
||||
void LLFacebookConnect::loadFacebookFriends()
|
||||
{
|
||||
const bool follow_redirects = false;
|
||||
|
|
@ -431,6 +470,17 @@ void LLFacebookConnect::updateStatus(const std::string& message)
|
|||
LLHTTPClient::post(getFacebookConnectURL("/share/wall"), body, new LLFacebookShareResponder());
|
||||
}
|
||||
|
||||
void LLFacebookConnect::storeInfo(const LLSD& info)
|
||||
{
|
||||
mInfo = info;
|
||||
sInfoWatcher->post(info);
|
||||
}
|
||||
|
||||
const LLSD& LLFacebookConnect::getInfo() const
|
||||
{
|
||||
return mInfo;
|
||||
}
|
||||
|
||||
void LLFacebookConnect::storeContent(const LLSD& content)
|
||||
{
|
||||
mGeneration++;
|
||||
|
|
|
|||
|
|
@ -58,12 +58,15 @@ public:
|
|||
void disconnectFromFacebook(); // Disconnect from the FBC service.
|
||||
void checkConnectionToFacebook(bool auto_connect = false); // Check if an access token is available on the FBC service. If not, call connectToFacebook().
|
||||
|
||||
void loadFacebookInfo();
|
||||
void loadFacebookFriends();
|
||||
void postCheckin(const std::string& location, const std::string& name, const std::string& description, const std::string& picture, const std::string& message);
|
||||
void sharePhoto(const std::string& image_url, const std::string& caption);
|
||||
void sharePhoto(LLPointer<LLImageFormatted> image, const std::string& caption);
|
||||
void updateStatus(const std::string& message);
|
||||
|
||||
void storeInfo(const LLSD& info);
|
||||
const LLSD& getInfo() const;
|
||||
void clearContent();
|
||||
void storeContent(const LLSD& content);
|
||||
const LLSD& getContent() const;
|
||||
|
|
@ -84,10 +87,12 @@ private:
|
|||
std::string getFacebookConnectURL(const std::string& route = "");
|
||||
|
||||
EConnectionState mConnectionState;
|
||||
LLSD mInfo;
|
||||
LLSD mContent;
|
||||
S32 mGeneration;
|
||||
|
||||
static boost::scoped_ptr<LLEventPump> sStateWatcher;
|
||||
static boost::scoped_ptr<LLEventPump> sInfoWatcher;
|
||||
static boost::scoped_ptr<LLEventPump> sContentWatcher;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -625,6 +625,8 @@ mDisconnectButton(NULL)
|
|||
mCommitCallbackRegistrar.add("SocialSharing.Connect", boost::bind(&LLSocialAccountPanel::onConnect, this));
|
||||
mCommitCallbackRegistrar.add("SocialSharing.UseAnotherAccount", boost::bind(&LLSocialAccountPanel::onUseAnotherAccount, this));
|
||||
mCommitCallbackRegistrar.add("SocialSharing.Disconnect", boost::bind(&LLSocialAccountPanel::onDisconnect, this));
|
||||
|
||||
setVisibleCallback(boost::bind(&LLSocialAccountPanel::onVisibilityChange, this, _2));
|
||||
}
|
||||
|
||||
BOOL LLSocialAccountPanel::postBuild()
|
||||
|
|
@ -636,11 +638,76 @@ BOOL LLSocialAccountPanel::postBuild()
|
|||
mUseAnotherAccountButton = getChild<LLUICtrl>("use_another_account_btn");
|
||||
mDisconnectButton = getChild<LLUICtrl>("disconnect_btn");
|
||||
|
||||
hideConnectButton();
|
||||
|
||||
return LLPanel::postBuild();
|
||||
}
|
||||
|
||||
void LLSocialAccountPanel::onVisibilityChange(const LLSD& new_visibility)
|
||||
{
|
||||
bool visible = new_visibility.asBoolean();
|
||||
|
||||
if(visible)
|
||||
{
|
||||
LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialAccountPanel");
|
||||
LLEventPumps::instance().obtain("FacebookConnectState").listen("LLSocialAccountPanel", boost::bind(&LLSocialAccountPanel::onFacebookConnectStateChange, this, _1));
|
||||
|
||||
LLFacebookConnect::instance().loadFacebookInfo();
|
||||
|
||||
LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLSocialAccountPanel");
|
||||
LLEventPumps::instance().obtain("FacebookConnectInfo").listen("LLSocialAccountPanel", boost::bind(&LLSocialAccountPanel::onFacebookConnectInfoChange, this));
|
||||
|
||||
if(LLFacebookConnect::instance().isConnected())
|
||||
{
|
||||
showConnectedLayout();
|
||||
}
|
||||
else
|
||||
{
|
||||
showDisconnectedLayout();
|
||||
LLFacebookConnect::instance().checkConnectionToFacebook();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLSocialAccountPanel");
|
||||
LLEventPumps::instance().obtain("FacebookConnectInfo").stopListening("LLSocialAccountPanel");
|
||||
}
|
||||
}
|
||||
|
||||
bool LLSocialAccountPanel::onFacebookConnectStateChange(const LLSD& data)
|
||||
{
|
||||
|
||||
switch (data.get("enum").asInteger())
|
||||
{
|
||||
case LLFacebookConnect::FB_CONNECTED:
|
||||
case LLFacebookConnect::FB_POSTING:
|
||||
case LLFacebookConnect::FB_POSTED:
|
||||
case LLFacebookConnect::FB_POST_FAILED:
|
||||
showConnectedLayout();
|
||||
break;
|
||||
case LLFacebookConnect::FB_NOT_CONNECTED:
|
||||
case LLFacebookConnect::FB_CONNECTION_IN_PROGRESS:
|
||||
case LLFacebookConnect::FB_CONNECTION_FAILED:
|
||||
showDisconnectedLayout();
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LLSocialAccountPanel::onFacebookConnectInfoChange()
|
||||
{
|
||||
LLSD info = LLFacebookConnect::instance().getInfo();
|
||||
std::string clickable_name;
|
||||
|
||||
if(info.has("link") && info.has("name"))
|
||||
{
|
||||
clickable_name = "[" + info["link"].asString() + " " + info["name"].asString() + "]";
|
||||
}
|
||||
|
||||
mAccountNameLabel->setText(clickable_name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LLSocialAccountPanel::showConnectButton()
|
||||
{
|
||||
if(!mConnectButton->getVisible())
|
||||
|
|
@ -671,9 +738,24 @@ void LLSocialAccountPanel::hideConnectButton()
|
|||
}
|
||||
}
|
||||
|
||||
void LLSocialAccountPanel::showDisconnectedLayout()
|
||||
{
|
||||
mAccountCaptionLabel->setText(getString("facebook_disconnected"));
|
||||
mAccountNameLabel->setText(std::string(""));
|
||||
showConnectButton();
|
||||
}
|
||||
|
||||
void LLSocialAccountPanel::showConnectedLayout()
|
||||
{
|
||||
LLFacebookConnect::instance().loadFacebookInfo();
|
||||
|
||||
mAccountCaptionLabel->setText(getString("facebook_connected"));
|
||||
hideConnectButton();
|
||||
}
|
||||
|
||||
void LLSocialAccountPanel::onConnect()
|
||||
{
|
||||
hideConnectButton();
|
||||
LLFacebookConnect::instance().checkConnectionToFacebook(true);
|
||||
}
|
||||
|
||||
void LLSocialAccountPanel::onUseAnotherAccount()
|
||||
|
|
@ -683,7 +765,7 @@ void LLSocialAccountPanel::onUseAnotherAccount()
|
|||
|
||||
void LLSocialAccountPanel::onDisconnect()
|
||||
{
|
||||
showConnectButton();
|
||||
LLFacebookConnect::instance().disconnectFromFacebook();
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
|
|
|
|||
|
|
@ -122,12 +122,17 @@ public:
|
|||
BOOL postBuild();
|
||||
|
||||
private:
|
||||
void onVisibilityChange(const LLSD& new_visibility);
|
||||
bool onFacebookConnectStateChange(const LLSD& data);
|
||||
bool onFacebookConnectInfoChange();
|
||||
void onConnect();
|
||||
void onUseAnotherAccount();
|
||||
void onDisconnect();
|
||||
|
||||
void showConnectButton();
|
||||
void hideConnectButton();
|
||||
void showDisconnectedLayout();
|
||||
void showConnectedLayout();
|
||||
|
||||
LLTextBox * mAccountCaptionLabel;
|
||||
LLTextBox * mAccountNameLabel;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,12 @@
|
|||
width="304"
|
||||
layout="topleft"
|
||||
name="panel_social_account">
|
||||
|
||||
<string
|
||||
name="facebook_connected"
|
||||
value="You are connected to Facebook as:" />
|
||||
<string
|
||||
name="facebook_disconnected"
|
||||
value="Not connected to Facebook" />
|
||||
<text
|
||||
layout="topleft"
|
||||
length="1"
|
||||
|
|
@ -14,7 +19,7 @@
|
|||
name="account_caption_label"
|
||||
top="21"
|
||||
type="string">
|
||||
You are connected to Facebook as:
|
||||
Not connected to Facebook.
|
||||
</text>
|
||||
<text
|
||||
layout="topleft"
|
||||
|
|
@ -25,10 +30,8 @@
|
|||
height="16"
|
||||
left="9"
|
||||
name="account_name_label"
|
||||
type="string">
|
||||
[secondlife:/// Philippe Bossut]
|
||||
</text>
|
||||
|
||||
parse_urls="true"
|
||||
type="string"/>
|
||||
<panel
|
||||
layout="topleft"
|
||||
name="panel_buttons"
|
||||
|
|
@ -53,7 +56,8 @@
|
|||
height="23"
|
||||
label="Use another account..."
|
||||
name="use_another_account_btn"
|
||||
width="210">
|
||||
width="210"
|
||||
visible="false">
|
||||
<commit_callback function="SocialSharing.UseAnotherAccount"/>
|
||||
</button>
|
||||
|
||||
|
|
@ -64,7 +68,8 @@
|
|||
height="23"
|
||||
label="Disconnect"
|
||||
name="disconnect_btn"
|
||||
width="210">
|
||||
width="210"
|
||||
visible="false">
|
||||
<commit_callback function="SocialSharing.Disconnect"/>
|
||||
</button>
|
||||
</panel>
|
||||
|
|
|
|||
Loading…
Reference in New Issue