From ba90e388855f99ec5b3f1991f2437f616a5d9e62 Mon Sep 17 00:00:00 2001 From: Merov Linden <merov@lindenlab.com> Date: Wed, 5 Jun 2013 19:40:33 -0700 Subject: ACME-464 : WIP : Make the menu Connect to FB only connect and be disabled if the user is already connected --- indra/newview/llpanelsnapshotfacebook.cpp | 3 ++- indra/newview/llviewermenu.cpp | 17 +++++++++-------- indra/newview/skins/default/xui/en/menu_viewer.xml | 2 ++ 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelsnapshotfacebook.cpp b/indra/newview/llpanelsnapshotfacebook.cpp index 200c64f16b..27abbfa456 100755 --- a/indra/newview/llpanelsnapshotfacebook.cpp +++ b/indra/newview/llpanelsnapshotfacebook.cpp @@ -90,7 +90,8 @@ void LLPanelSnapshotFacebook::onOpen(const LLSD& key) void LLPanelSnapshotFacebook::updateControls(const LLSD& info) { const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true; - getChild<LLUICtrl>("post_btn")->setEnabled(have_snapshot); + const bool is_connected = LLFacebookConnect::instance().getConnected(); + getChild<LLUICtrl>("post_btn")->setEnabled(have_snapshot && is_connected); } void LLPanelSnapshotFacebook::onSend() diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 471db8d8fc..bc2e13d77e 100755 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -5974,16 +5974,18 @@ void handle_report_abuse() void handle_facebook_connect() { - if (LLFacebookConnect::instance().getConnected()) - { - LLFacebookConnect::instance().disconnectFromFacebook(); - } - else + if (!LLFacebookConnect::instance().getConnected()) { LLFacebookConnect::instance().getConnectionToFacebook(); } } +bool enable_facebook_connect() +{ + // The menu item will be disabled if we are already connected + return !LLFacebookConnect::instance().getConnected(); +} + void handle_facebook_checkin() { @@ -5999,9 +6001,6 @@ void handle_facebook_checkin() LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQDL4jdC_vCh0ow-QCXZjN-WNojEXWiz0APEa6Qhpl8cxawjkoC7w", ""); } -//bool is_facebook_connected(); - - void handle_buy_currency() { LLBuyCurrencyHTML::openCurrencyFloater(); @@ -8754,6 +8753,8 @@ void initialize_menus() // Facebook Connect commit.add("Facebook.Connect", boost::bind(&handle_facebook_connect)); + enable.add("Facebook.EnableConnect", boost::bind(&enable_facebook_connect)); + // Facebook Checkin commit.add("Facebook.Checkin", boost::bind(&handle_facebook_checkin)); } diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 5061842c7f..e67350722d 100755 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -20,6 +20,8 @@ name="ConnectToFacebook"> <menu_item_call.on_click function="Facebook.Connect" /> + <menu_item_call.on_enable + function="Facebook.EnableConnect" /> </menu_item_call> <menu_item_call label="Check in to Facebook" -- cgit v1.2.3 From 4163603a1118a9c1e220e56f22e757d162932ebe Mon Sep 17 00:00:00 2001 From: Merov Linden <merov@lindenlab.com> Date: Thu, 6 Jun 2013 15:06:52 -0700 Subject: ACME-464 : WIP : Post in the snapshot Panel correctly disabled / enabled according to FB connection status --- indra/newview/llpanelsnapshotfacebook.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra') diff --git a/indra/newview/llpanelsnapshotfacebook.cpp b/indra/newview/llpanelsnapshotfacebook.cpp index b434741538..faeabf0a07 100755 --- a/indra/newview/llpanelsnapshotfacebook.cpp +++ b/indra/newview/llpanelsnapshotfacebook.cpp @@ -55,6 +55,7 @@ public: /*virtual*/ void onOpen(const LLSD& key); private: + /*virtual*/ void updateCustomResControls(); ///< Show/hide facebook custom controls /*virtual*/ std::string getWidthSpinnerName() const { return "facebook_snapshot_width"; } /*virtual*/ std::string getHeightSpinnerName() const { return "facebook_snapshot_height"; } /*virtual*/ std::string getAspectRatioCBName() const { return "facebook_keep_aspect_check"; } @@ -84,6 +85,7 @@ BOOL LLPanelSnapshotFacebook::postBuild() // virtual void LLPanelSnapshotFacebook::onOpen(const LLSD& key) { + updateControls(key); LLPanelSnapshot::onOpen(key); } @@ -95,6 +97,13 @@ void LLPanelSnapshotFacebook::updateControls(const LLSD& info) getChild<LLUICtrl>("post_btn")->setEnabled(have_snapshot && is_connected); } +// virtual +void LLPanelSnapshotFacebook::updateCustomResControls() +{ + const bool is_connected = LLFacebookConnect::instance().getConnected(); + getChild<LLUICtrl>("post_btn")->setEnabled(is_connected); +} + void LLPanelSnapshotFacebook::onSend() { std::string caption = getChild<LLUICtrl>("caption")->getValue().asString(); -- cgit v1.2.3 From bee5369b2f2fc0208b1a0645c2702ed1cea43c55 Mon Sep 17 00:00:00 2001 From: Merov Linden <merov@lindenlab.com> Date: Thu, 6 Jun 2013 20:08:46 -0700 Subject: ACME-464 : Fixed : We connect to FB when bringing up the Upload to FB Snapshot panel --- indra/newview/llfloatersnapshot.cpp | 12 +++++++++++- indra/newview/llpanelsnapshotfacebook.cpp | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index d8d62e5bbb..8405d8aeec 100755 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -37,6 +37,7 @@ #include "llcriticaldamp.h" #include "llfloaterperms.h" #include "llui.h" +#include "llfacebookconnect.h" #include "llfocusmgr.h" #include "llbutton.h" #include "llcombobox.h" @@ -2245,7 +2246,16 @@ void LLFloaterSnapshot::update() { changed |= LLSnapshotLivePreview::onIdle(*iter); } - if(changed) + + // We need to pool on facebook connection as it might change any time + static bool s_facebook_connected = false; + if (LLFacebookConnect::instance().getConnected() != s_facebook_connected) + { + s_facebook_connected = LLFacebookConnect::instance().getConnected(); + changed = true; + } + + if (changed) { lldebugs << "changed" << llendl; inst->impl.updateControls(inst); diff --git a/indra/newview/llpanelsnapshotfacebook.cpp b/indra/newview/llpanelsnapshotfacebook.cpp index faeabf0a07..7c8fc044c0 100755 --- a/indra/newview/llpanelsnapshotfacebook.cpp +++ b/indra/newview/llpanelsnapshotfacebook.cpp @@ -85,6 +85,10 @@ BOOL LLPanelSnapshotFacebook::postBuild() // virtual void LLPanelSnapshotFacebook::onOpen(const LLSD& key) { + if (!LLFacebookConnect::instance().getConnected()) + { + LLFacebookConnect::instance().getConnectionToFacebook(); + } updateControls(key); LLPanelSnapshot::onOpen(key); } @@ -100,6 +104,7 @@ void LLPanelSnapshotFacebook::updateControls(const LLSD& info) // virtual void LLPanelSnapshotFacebook::updateCustomResControls() { + LLPanelSnapshot::updateCustomResControls(); const bool is_connected = LLFacebookConnect::instance().getConnected(); getChild<LLUICtrl>("post_btn")->setEnabled(is_connected); } -- cgit v1.2.3