llpanelweb.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 // file include
00035 #include "llpanelweb.h"
00036 
00037 // linden library includes
00038 #include "llerror.h"
00039 #include "llrect.h"
00040 #include "llstring.h"
00041 
00042 // project includes
00043 #include "llbutton.h"
00044 #include "llui.h"
00045 #include "lluictrlfactory.h"
00046 #include "llcheckboxctrl.h"
00047 #include "llviewercontrol.h"
00048 #include "llvieweruictrlfactory.h"
00049 #include "llviewerwindow.h"
00050 
00051 #if LL_LIBXUL_ENABLED
00052 #include "llmozlib.h"
00053 #endif // LL_LIBXUL_ENABLED
00054 
00055 LLPanelWeb::LLPanelWeb()
00056 {
00057         gUICtrlFactory->buildPanel(this, "panel_preferences_web.xml");
00058 }
00059 
00060 BOOL LLPanelWeb::postBuild()
00061 {
00062         childSetAction( "clear_cache", onClickClearCache, this );
00063         childSetAction( "clear_cookies", onClickClearCookies, this );
00064 //      childSetEnabled( "connection_port", gSavedSettings.getBOOL( "CookiesEnabled" ) );
00065         childSetCommitCallback( "cookies_enabled", onCommitCookies, this );
00066 
00067         refresh();
00068 
00069         return TRUE;
00070 }
00071 
00072 LLPanelWeb::~LLPanelWeb()
00073 {
00074         // Children all cleaned up by default view destructor.
00075 }
00076 
00077 void LLPanelWeb::apply()
00078 {
00079 }
00080 
00081 void LLPanelWeb::refresh()
00082 {
00083         LLPanel::refresh();
00084 
00085         mCookiesEnabled = gSavedSettings.getBOOL("CookiesEnabled");
00086 
00087 #if LL_LIBXUL_ENABLED
00088         llinfos << "setting cookies enabled to " << mCookiesEnabled << llendl;
00089         LLMozLib::getInstance()->enableCookies( mCookiesEnabled );
00090 #endif // LL_LIBXUL_ENABLED
00091 
00092 }
00093 
00094 void LLPanelWeb::cancel()
00095 {
00096 #if LL_LIBXUL_ENABLED
00097         llinfos << "setting cookies enabled to " << mCookiesEnabled << llendl;
00098         LLMozLib::getInstance()->enableCookies( mCookiesEnabled );
00099 #endif // LL_LIBXUL_ENABLED
00100 
00101         gSavedSettings.setBOOL( "CookiesEnabled", mCookiesEnabled );
00102 }
00103 
00104 // static
00105 void LLPanelWeb::onClickClearCache(void*)
00106 {
00107 #if LL_LIBXUL_ENABLED
00108         gViewerWindow->alertXml("ConfirmClearBrowserCache", callback_clear_browser_cache, 0);
00109 #endif // LL_LIBXUL_ENABLED
00110 }
00111 
00112 //static
00113 void LLPanelWeb::callback_clear_browser_cache(S32 option, void* userdata)
00114 {
00115 #if LL_LIBXUL_ENABLED
00116         if ( option == 0 ) // YES
00117         {
00118                 llinfos << "clearing browser cache" << llendl;
00119                 LLMozLib::getInstance()->clearCache();
00120         }
00121 #endif // LL_LIBXUL_ENABLED
00122 }
00123 
00124 // static
00125 void LLPanelWeb::onClickClearCookies(void*)
00126 {
00127 #if LL_LIBXUL_ENABLED
00128         gViewerWindow->alertXml("ConfirmClearCookies", callback_clear_cookies, 0);
00129 #endif // LL_LIBXUL_ENABLED
00130 }
00131 
00132 //static
00133 void LLPanelWeb::callback_clear_cookies(S32 option, void* userdata)
00134 {
00135 #if LL_LIBXUL_ENABLED
00136         if ( option == 0 ) // YES
00137         {
00138                 llinfos << "clearing browser cookies" << llendl;
00139                 LLMozLib::getInstance()->clearAllCookies();
00140         }
00141 #endif // LL_LIBXUL_ENABLED
00142 }
00143 
00144 // static
00145 void LLPanelWeb::onCommitCookies(LLUICtrl* ctrl, void* data)
00146 {
00147   LLPanelWeb* self = (LLPanelWeb*)data;
00148   LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
00149 
00150   if (!self || !check) return;
00151 
00152 #if LL_LIBXUL_ENABLED
00153         llinfos << "setting cookies enabled to " << check->get() << llendl;
00154         LLMozLib::getInstance()->enableCookies( check->get() );
00155 #endif // LL_LIBXUL_ENABLED
00156   
00157 }

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