llfloaterreleasemsg.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llvieweruictrlfactory.h"
00035 #include "llviewerwindow.h"
00036 #include "llviewercontrol.h"
00037 #include "llfloaterreleasemsg.h"
00038 #include "llagent.h"
00039 #include "llviewerregion.h"
00040 
00041 extern LLAgent gAgent;
00042 extern LLString gLastVersionChannel;
00043 
00044 LLFloaterReleaseMsg* LLFloaterReleaseMsg::sInstance = 0;
00045 
00046 
00048 //
00049 LLFloaterReleaseMsg* LLFloaterReleaseMsg::getInstance()
00050 {
00051     if ( ! sInstance )
00052         sInstance = new LLFloaterReleaseMsg;
00053 
00054         return sInstance;
00055 }
00056 
00058 //
00059 LLFloaterReleaseMsg::LLFloaterReleaseMsg()
00060 :       LLFloater( "Release Message Floater" )
00061 
00062 #if LL_LIBXUL_ENABLED
00063         ,
00064         mWebBrowser( 0 )
00065 #endif // LL_LIBXUL_ENABLED
00066 {
00067         // create floater from its XML definition
00068         gUICtrlFactory->buildFloater( this, "floater_sim_release_message.xml" );
00069 
00070         mTitleBase = getTitle();
00071 
00072         // reposition floater from saved settings
00073         LLRect rect = gSavedSettings.getRect( "HtmlReleaseMessage" );
00074         reshape( rect.getWidth(), rect.getHeight(), FALSE );
00075         setRect( rect );
00076 
00077 #if LL_LIBXUL_ENABLED
00078         mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this,  "release_message_floater_browser" );
00079         if ( mWebBrowser )
00080         {
00081                 // observe browser events
00082                 mWebBrowser->addObserver( this );
00083 
00084                 // make links open in external browser
00085                 mWebBrowser->setOpenInExternalBrowser( true );
00086 
00087                 // don't automatically open secondlife links since we want to catch
00088                 // special ones that do other stuff (like open F1 Help)
00089                 //mWebBrowser->setOpenSecondLifeLinksInMap( false );
00090         }
00091 #endif // LL_LIBXUL_ENABLED
00092                         
00093         childSetAction("close_btn", onClickClose, this);
00094         setDefaultBtn("close_btn");
00095 }
00096 
00098 //
00099 LLFloaterReleaseMsg::~LLFloaterReleaseMsg()
00100 {
00101 #if LL_LIBXUL_ENABLED
00102         // stop observing browser events
00103         if ( mWebBrowser )
00104                 mWebBrowser->remObserver( this );
00105 #endif // LL_LIBXUL_ENABLED
00106 
00107         // save position of floater
00108         gSavedSettings.setRect( "HtmlReleaseMessage", mRect );
00109 
00110         sInstance = 0;
00111 }
00112 
00114 //
00115 void LLFloaterReleaseMsg::show()
00116 {
00117 
00118         std::string url = gAgent.getRegion()->getCapability("ServerReleaseNotes");
00119 
00120         if (url.empty()) return;
00121 
00122         llinfos << "Release message url: " << url << llendl;
00123 
00124         if (!sInstance)
00125         {
00126                 sInstance = new LLFloaterReleaseMsg();
00127                 sInstance->center();
00128         }
00129 
00130         sInstance->setTitle(sInstance->mTitleBase + " " + gLastVersionChannel);
00131         sInstance->open();
00132 
00133 #if LL_LIBXUL_ENABLED
00134         // navigate to the URL
00135         if ( sInstance->mWebBrowser )
00136                 sInstance->mWebBrowser->navigateTo( url );
00137 #endif // LL_LIBXUL_ENABLED
00138 
00139         // make floater appear
00140         sInstance->setVisibleAndFrontmost();
00141 
00142         sInstance->draw();
00143 }
00144 
00145 
00147 //
00148 void LLFloaterReleaseMsg::onClickClose( void* data )
00149 {
00150         LLFloaterReleaseMsg* self = ( LLFloaterReleaseMsg* )data;
00151 
00152         self->setVisible( false );
00153 }
00154 
00155 

Generated on Thu Jul 1 06:08:36 2010 for Second Life Viewer by  doxygen 1.4.7