From bb356b9821442fb2d4fb0590fdfa8dd562f55b53 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 23 Aug 2010 21:07:05 -0700 Subject: Added vivox license window when enabling voice or starting up for the first time (voice can now be included from here on out :) --- linden/indra/newview/CMakeLists.txt | 3 + linden/indra/newview/app_settings/settings.xml | 24 ++- linden/indra/newview/floatervoicelicense.cpp | 237 +++++++++++++++++++++ linden/indra/newview/floatervoicelicense.h | 72 +++++++ linden/indra/newview/llfirstuse.cpp | 20 +- linden/indra/newview/llfirstuse.h | 1 + linden/indra/newview/llprefsvoice.cpp | 15 +- linden/indra/newview/llstartup.cpp | 23 +- linden/indra/newview/llstartup.h | 1 + .../default/xui/en-us/floater_voice_license.xml | 36 ++++ 10 files changed, 426 insertions(+), 6 deletions(-) create mode 100644 linden/indra/newview/floatervoicelicense.cpp create mode 100644 linden/indra/newview/floatervoicelicense.h create mode 100644 linden/indra/newview/skins/default/xui/en-us/floater_voice_license.xml (limited to 'linden/indra/newview') diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index a7b78f1..6decbf6 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -71,6 +71,7 @@ set(viewer_SOURCE_FILES floaterbusy.cpp floatergriddefault.cpp floatergridmanager.cpp + floatervoicelicense.cpp hbfloatergrouptitles.cpp hippoGridManager.cpp hippoLimits.cpp @@ -503,6 +504,7 @@ set(viewer_HEADER_FILES floaterbusy.h floatergriddefault.h floatergridmanager.h + floatervoicelicense.h hbfloatergrouptitles.h hippoGridManager.h hippoLimits.h @@ -1215,6 +1217,7 @@ set(viewer_XUI_FILES skins/default/xui/en-us/floater_top_objects.xml skins/default/xui/en-us/floater_tos.xml skins/default/xui/en-us/floater_url_entry.xml + skins/default/xui/en-us/floater_voice_license.xml skins/default/xui/en-us/floater_voice_wizard.xml skins/default/xui/en-us/floater_water.xml skins/default/xui/en-us/floater_wearable_save_as.xml diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 9f67615..1951e07 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -844,6 +844,17 @@ Value 0 + VivoxLicenseAccepted + + Comment + By setting to true, you agree to accept the Vivox personal license agreement at http://www.vivox.com/vivox_aup.html + Persist + 1 + Type + Boolean + Value + 0 + WarnFirstAO Comment @@ -877,6 +888,17 @@ Value 1 + WarnFirstVoiceLicense + + Comment + Enables FirstVoiceLicense window on login + Persist + 1 + Type + Boolean + Value + 1 + DefaultGrid Comment @@ -4531,7 +4553,7 @@ Type Boolean Value - 1 + 0 EnergyFromTop diff --git a/linden/indra/newview/floatervoicelicense.cpp b/linden/indra/newview/floatervoicelicense.cpp new file mode 100644 index 0000000..4004290 --- /dev/null +++ b/linden/indra/newview/floatervoicelicense.cpp @@ -0,0 +1,237 @@ +/** +* @file floatervoicelicense.cpp +* @brief prompts user to agree to the Vivox license in order to enable voice +* +* $LicenseInfo:firstyear=2009&license=viewergpl$ +* +* Copyright (c) 2010, McCabe Maxsted +* +* Imprudence Viewer Source Code +* The source code in this file ("Source Code") is provided to you +* under the terms of the GNU General Public License, version 2.0 +* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in +* this distribution, or online at +* http://secondlifegrid.net/programs/open_source/licensing/gplv2 +* +* There are special exceptions to the terms and conditions of the GPL as +* it is applied to this Source Code. View the full text of the exception +* in the file doc/FLOSS-exception.txt in this software distribution, or +* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception +* +* By copying, modifying or distributing this software, you acknowledge +* that you have read and understood your obligations described above, +* and agree to abide by those obligations. +* +* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO +* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +* COMPLETENESS OR PERFORMANCE. +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "floatervoicelicense.h" + +// viewer includes +#include "llagent.h" +#include "llappviewer.h" +#include "llstartup.h" +#include "llviewercontrol.h" +#include "llviewerstats.h" +#include "llviewertexteditor.h" +#include "llviewerwindow.h" + +// linden library includes +#include "llbutton.h" +#include "llhttpclient.h" +#include "llhttpstatuscodes.h" // for HTTP_FOUND +#include "llradiogroup.h" +#include "lltextbox.h" +#include "llui.h" +#include "lluictrlfactory.h" +#include "llvfile.h" +#include "message.h" + + +FloaterVoiceLicense::FloaterVoiceLicense(const LLSD& key) +: LLModalDialog( std::string(" "), 100, 100 ), + mWebBrowserWindowId( 0 ), + mLoadCompleteCount( 0 ) +{ + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_voice_license.xml"); +} + +// helper class that trys to download a URL from a web site and calls a method +// on parent class indicating if the web server is working or not +class LLIamHere : public LLHTTPClient::Responder +{ + private: + LLIamHere( FloaterVoiceLicense* parent ) : + mParent( parent ) + {} + + FloaterVoiceLicense* mParent; + + public: + + static boost::intrusive_ptr< LLIamHere > build( FloaterVoiceLicense* parent ) + { + return boost::intrusive_ptr< LLIamHere >( new LLIamHere( parent ) ); + }; + + virtual void setParent( FloaterVoiceLicense* parentIn ) + { + mParent = parentIn; + }; + + virtual void result( const LLSD& content ) + { + if ( mParent ) + mParent->setSiteIsAlive( true ); + }; + + virtual void error( U32 status, const std::string& reason ) + { + if ( mParent ) + { + // *HACK: For purposes of this alive check, 302 Found + // (aka Moved Temporarily) is considered alive. The web site + // redirects this link to a "cache busting" temporary URL. JC + bool alive = (status == HTTP_FOUND); + mParent->setSiteIsAlive( alive ); + } + }; +}; + +// this is global and not a class member to keep crud out of the header file +namespace { + boost::intrusive_ptr< LLIamHere > gResponsePtr = 0; +}; + +BOOL FloaterVoiceLicense::postBuild() +{ + childSetAction("Continue", onContinue, this); + childSetAction("Cancel", onCancel, this); + childSetCommitCallback("agree_chk", updateAgree, this); + + // disable Agree to License radio button until the page has fully loaded + LLCheckBoxCtrl* license_agreement = getChild("agree_chk"); + license_agreement->setEnabled( false ); + + // hide the SL text widget if we're displaying license with using a browser widget. + LLTextEditor *editor = getChild("license_text"); + editor->setVisible( FALSE ); + + LLWebBrowserCtrl* web_browser = getChild("license_html"); + if ( web_browser ) + { + // start to observe it so we see navigate complete events + web_browser->addObserver( this ); + + gResponsePtr = LLIamHere::build( this ); + LLHTTPClient::get( getString( "real_url" ), gResponsePtr ); + } + + return TRUE; +} + +void FloaterVoiceLicense::setSiteIsAlive( bool alive ) +{ + LLWebBrowserCtrl* web_browser = getChild("license_html"); + // if the contents of the site was retrieved + if ( alive ) + { + if ( web_browser ) + { + // navigate to the "real" page + web_browser->navigateTo( getString( "real_url" ) ); + } + } + else + { + // normally this is set when navigation to license page completes (so you can't accept before it loads) + // but if the page is unavailable, we need to do this now + LLCheckBoxCtrl* license_agreement = getChild("agree_chk"); + license_agreement->setEnabled( true ); + } +} + +FloaterVoiceLicense::~FloaterVoiceLicense() +{ + // stop observing events + LLWebBrowserCtrl* web_browser = getChild("license_html"); + if ( web_browser ) + { + web_browser->remObserver( this ); + } + + // tell the responder we're not here anymore + if ( gResponsePtr ) + { + gResponsePtr->setParent( 0 ); + } +} + +// virtual +void FloaterVoiceLicense::draw() +{ + // draw children + LLModalDialog::draw(); +} + +// static +void FloaterVoiceLicense::updateAgree(LLUICtrl*, void* userdata ) +{ + FloaterVoiceLicense* self = (FloaterVoiceLicense*) userdata; + bool agree = self->childGetValue("agree_chk").asBoolean(); + self->childSetEnabled("Continue", agree); +} + +// static +void FloaterVoiceLicense::onContinue( void* userdata ) +{ + FloaterVoiceLicense* self = (FloaterVoiceLicense*) userdata; + llinfos << "User agreed to the Vivox personal license" << llendl; + + // enabling voice by default here seems like the best behavior + gSavedSettings.setBOOL("EnableVoiceChat", TRUE); + gSavedSettings.setBOOL("VivoxLicenseAccepted", TRUE); + + // save these settings in case something bad happens later + gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); + + if (LLStartUp::getStartupState() == STATE_LOGIN_VOICE_LICENSE) + { + LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); // Go back and finish authentication + } + self->close(); // destroys this object +} + +// static +void FloaterVoiceLicense::onCancel( void* userdata ) +{ + FloaterVoiceLicense* self = (FloaterVoiceLicense*) userdata; + llinfos << "User disagreed with the vivox personal license" << llendl; + gSavedSettings.setBOOL("EnableVoiceChat", FALSE); + gSavedSettings.setBOOL("VivoxLicenseAccepted", FALSE); + + if (LLStartUp::getStartupState() == STATE_LOGIN_VOICE_LICENSE) + { + LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); // Go back and finish authentication + } + self->mLoadCompleteCount = 0; // reset counter for next time we come here + self->close(); // destroys this object +} + +//virtual +void FloaterVoiceLicense::onNavigateComplete( const EventType& eventIn ) +{ + // skip past the loading screen navigate complete + if ( ++mLoadCompleteCount == 2 ) + { + llinfos << "NAVIGATE COMPLETE" << llendl; + // enable Agree to License radio button now that page has loaded + LLCheckBoxCtrl * license_agreement = getChild("agree_chk"); + license_agreement->setEnabled( true ); + } +} diff --git a/linden/indra/newview/floatervoicelicense.h b/linden/indra/newview/floatervoicelicense.h new file mode 100644 index 0000000..4130d22 --- /dev/null +++ b/linden/indra/newview/floatervoicelicense.h @@ -0,0 +1,72 @@ +/** +* @file floatervoicelicense.h +* @brief prompts user to agree to the Vivox license in order to enable voice +* +* $LicenseInfo:firstyear=2009&license=viewergpl$ +* +* Copyright (c) 2010, McCabe Maxsted +* +* Imprudence Viewer Source Code +* The source code in this file ("Source Code") is provided to you +* under the terms of the GNU General Public License, version 2.0 +* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in +* this distribution, or online at +* http://secondlifegrid.net/programs/open_source/licensing/gplv2 +* +* There are special exceptions to the terms and conditions of the GPL as +* it is applied to this Source Code. View the full text of the exception +* in the file doc/FLOSS-exception.txt in this software distribution, or +* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception +* +* By copying, modifying or distributing this software, you acknowledge +* that you have read and understood your obligations described above, +* and agree to abide by those obligations. +* +* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO +* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +* COMPLETENESS OR PERFORMANCE. +* $/LicenseInfo$ +*/ + +#ifndef FLOATERVOICELICENSE_H +#define FLOATERVOICELICENSE_H + +#include "llfloater.h" + +#include "llmodaldialog.h" +#include "llassetstorage.h" +#include "llwebbrowserctrl.h" + +class LLButton; +class LLRadioGroup; +class LLVFS; +class LLTextEditor; +class LLUUID; + +class FloaterVoiceLicense : + public LLModalDialog, + public LLWebBrowserCtrlObserver, + public LLFloaterSingleton +{ +public: + FloaterVoiceLicense(const LLSD& key); + virtual ~FloaterVoiceLicense(); + + BOOL postBuild(); + + virtual void draw(); + + static void updateAgree( LLUICtrl *, void* userdata ); + static void onContinue( void* userdata ); + static void onCancel( void* userdata ); + + void setSiteIsAlive( bool alive ); + + virtual void onNavigateComplete( const EventType& eventIn ); + +private: + int mWebBrowserWindowId; + int mLoadCompleteCount; +}; + +#endif // FLOATERVOICELICENSE_H diff --git a/linden/indra/newview/llfirstuse.cpp b/linden/indra/newview/llfirstuse.cpp index 886bb94..e82aa96 100644 --- a/linden/indra/newview/llfirstuse.cpp +++ b/linden/indra/newview/llfirstuse.cpp @@ -45,9 +45,11 @@ #include "llappviewer.h" #include "lltracker.h" -#include "llvoavatar.h" #include "floatergriddefault.h" +#include "floatervoicelicense.h" #include "hippoGridManager.h" +#include "llstartup.h" +#include "llvoavatar.h" // static std::set LLFirstUse::sConfigVariables; @@ -387,3 +389,19 @@ void LLFirstUse::useLoginScreen() FloaterGridDefault::getInstance()->center(); } } + +// static +void LLFirstUse::voiceLicenseAgreement() +{ + if (gSavedSettings.getWarning("FirstVoiceLicense")) + { + gSavedSettings.setWarning("FirstVoiceLicense", FALSE); + + FloaterVoiceLicense::getInstance()->open(); + FloaterVoiceLicense::getInstance()->center(); + } + else // currently in STATE_LOGIN_VOICE_LICENSE when arriving here + { + LLStartUp::setStartupState(STATE_LOGIN_AUTH_INIT); + } +} diff --git a/linden/indra/newview/llfirstuse.h b/linden/indra/newview/llfirstuse.h index c77f0b2..b0bf05f 100644 --- a/linden/indra/newview/llfirstuse.h +++ b/linden/indra/newview/llfirstuse.h @@ -115,6 +115,7 @@ public: static void useLoginScreen(); static void callbackClientTags(const LLSD& notification, const LLSD& response); static void ClientTags(); + static void voiceLicenseAgreement(); protected: static std::set sConfigVariables; diff --git a/linden/indra/newview/llprefsvoice.cpp b/linden/indra/newview/llprefsvoice.cpp index 167e079..2d6eeb0 100644 --- a/linden/indra/newview/llprefsvoice.cpp +++ b/linden/indra/newview/llprefsvoice.cpp @@ -35,6 +35,7 @@ #include "llprefsvoice.h" +#include "floatervoicelicense.h" #include "llcheckboxctrl.h" #include "llfloatervoicedevicesettings.h" #include "llfocusmgr.h" @@ -136,8 +137,6 @@ BOOL LLPrefsVoice::postBuild() void LLPrefsVoice::apply() { - gSavedSettings.setBOOL("EnableVoiceChat", childGetValue("enable_voice_check")); - gSavedSettings.setString("PushToTalkButton", childGetValue("modifier_combo")); gSavedSettings.setBOOL("VoiceCallsFriendsOnly", childGetValue("voice_call_friends_only_check")); gSavedSettings.setBOOL("AutoDisengageMic", childGetValue("auto_disengage_mic_check")); @@ -149,6 +148,18 @@ void LLPrefsVoice::apply() { voice_device_settings->apply(); } + + bool enable_voice = childGetValue("enable_voice_check"); + if (enable_voice && !gSavedSettings.getBOOL("VivoxLicenseAccepted")) + { + // This window enables voice chat if license is accepted + FloaterVoiceLicense::getInstance()->open(); + FloaterVoiceLicense::getInstance()->center(); + } + else + { + gSavedSettings.setBOOL("EnableVoiceChat", enable_voice); + } } void LLPrefsVoice::cancel() diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index e438f0c..3f55fd8 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp @@ -1045,12 +1045,30 @@ bool idle_startup() // color init must be after saved settings loaded init_colors(); - // skipping over STATE_UPDATE_CHECK because that just waits for input - LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); + if (gSavedSettings.getBOOL("VivoxLicenseAccepted")) + { + // skipping over STATE_LOGIN_VOICE_LICENSE since we don't need it + // skipping over STATE_UPDATE_CHECK because that just waits for input + LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); + } + else + { + LLStartUp::setStartupState(STATE_LOGIN_VOICE_LICENSE); + LLFirstUse::voiceLicenseAgreement(); + } return FALSE; } + if (STATE_LOGIN_VOICE_LICENSE == LLStartUp::getStartupState()) + { + LL_DEBUGS("AppInitStartupState") << "STATE_LOGIN_VOICE_LICENSE" << LL_ENDL; + // prompt the user to agree to the voice license before enabling voice. + // only send users here on first login, otherwise continue + // on to STATE_LOGIN_AUTH_INIT + return FALSE; + } + if (STATE_UPDATE_CHECK == LLStartUp::getStartupState()) { LL_DEBUGS("AppInitStartupState") << "STATE_UPDATE_CHECK" << LL_ENDL; @@ -3642,6 +3660,7 @@ std::string LLStartUp::startupStateToString(EStartupState state) RTNENUM( STATE_LOGIN_SHOW ); RTNENUM( STATE_LOGIN_WAIT ); RTNENUM( STATE_LOGIN_CLEANUP ); + RTNENUM( STATE_LOGIN_VOICE_LICENSE ); RTNENUM( STATE_UPDATE_CHECK ); RTNENUM( STATE_LOGIN_AUTH_INIT ); RTNENUM( STATE_LOGIN_AUTHENTICATE ); diff --git a/linden/indra/newview/llstartup.h b/linden/indra/newview/llstartup.h index 65bfc68..9a3c91c 100644 --- a/linden/indra/newview/llstartup.h +++ b/linden/indra/newview/llstartup.h @@ -50,6 +50,7 @@ typedef enum { STATE_LOGIN_SHOW, // Show login screen STATE_LOGIN_WAIT, // Wait for user input at login screen STATE_LOGIN_CLEANUP, // Get rid of login screen and start login + STATE_LOGIN_VOICE_LICENSE, // Show license agreement for using voice STATE_UPDATE_CHECK, // Wait for user at a dialog box (updates, term-of-service, etc) STATE_LOGIN_AUTH_INIT, // Start login to SL servers STATE_LOGIN_AUTHENTICATE, // Do authentication voodoo diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_voice_license.xml b/linden/indra/newview/skins/default/xui/en-us/floater_voice_license.xml new file mode 100644 index 0000000..3a2b0be --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/floater_voice_license.xml @@ -0,0 +1,36 @@ + + +