llpaneldatabase.cpp

Go to the documentation of this file.
00001 
00029 #include "llviewerprecompiledheaders.h"
00030 
00031 #include "llpaneldatabase.h"
00032 
00033 #include "llscrolllistctrl.h"
00034 #include "llviewerwindow.h"
00035 #include "llviewercontrol.h"
00036 #include "llvieweruictrlfactory.h"
00037 #include "llfloateravatarpicker.h"
00038 #include "llagentdata.h"
00039 #include "llnotify.h"
00040 
00041 //-----------------------------------------------------------------------------
00042 LLPanelDatabase::LLPanelDatabase() :
00043         LLPanel("Messages Panel")
00044 {
00045         gUICtrlFactory->buildPanel(this, "panel_preferences_database.xml");
00046         childSetAction("change_avatar_btn", onClickChangeAvatar, this);
00047 };
00048 
00049 //-----------------------------------------------------------------------------
00050 // postBuild()
00051 //-----------------------------------------------------------------------------
00052 
00053 void LLPanelDatabase::refresh() 
00054 {
00055         llinfos << "Loading settings" << llendl;
00056         mAvatarName      = gSavedPerAccountSettings.getString("DBAvatarName");
00057         mAvatarKey.set(gSavedPerAccountSettings.getString("DBAvatarKey"));
00058         mURL             = gSavedSettings.getString("DBURL");;
00059         mUsername        = gSavedSettings.getString("DBURLUsername");;
00060         mPassword        = gSavedSettings.getString("DBURLPassword");;
00061         mSendPattern     = gSavedSettings.getString("DBSendPattern");;
00062         mPositivePattern = gSavedSettings.getString("DBPositivePattern");;
00063         mNegativePattern = gSavedSettings.getString("DBNegativePattern");;
00064         mDeniedPattern   = gSavedSettings.getString("DBDeniedPattern");;
00065 
00066 }
00067 
00068 BOOL LLPanelDatabase::postBuild()
00069 {
00070         refresh();
00071 
00072         llinfos << "Setting settings in window" << llendl;
00073         childSetText("db_avatar"       ,mAvatarName );
00074         childSetText("db_url"          ,mURL );
00075         childSetText("db_url_username" ,mUsername );
00076         childSetText("db_url_password" ,mPassword );
00077         childSetText("send_pattern"    ,mSendPattern );
00078         childSetText("positive_pattern",mPositivePattern );
00079         childSetText("negative_pattern",mNegativePattern );
00080         childSetText("denied_pattern"  ,mDeniedPattern );
00081 
00082         return TRUE;
00083 }
00084 
00085 
00086 void LLPanelDatabase::draw()
00087 {
00088         LLPanel::draw();
00089 }
00090 
00091 void LLPanelDatabase::apply()
00092 {
00093         llinfos << "Saving settings" << llendl;
00094 
00095         gSavedPerAccountSettings.setString("DBAvatarName", childGetText("db_avatar").c_str());
00096         gSavedPerAccountSettings.setString("DBAvatarKey", mAvatarKey.asString());
00097         gSavedSettings.setString("DBURL", childGetText("db_url").c_str());
00098         gSavedSettings.setString("DBURLUsername", childGetText("db_url_username").c_str());
00099         gSavedSettings.setString("DBURLPassword", childGetText("db_url_password").c_str());
00100 
00101         gSavedSettings.setString("DBSendPattern", childGetText("send_pattern").c_str());
00102         gSavedSettings.setString("DBPositivePattern", childGetText("positive_pattern").c_str());
00103         gSavedSettings.setString("DBNegativePattern", childGetText("negative_pattern").c_str());
00104         gSavedSettings.setString("DBDeniedPattern", childGetText("denied_pattern").c_str());    
00105 
00106 
00107 }
00108 
00109 void LLPanelDatabase::cancel()
00110 {
00111         
00112 }
00113 
00114 //static
00115 void LLPanelDatabase::onClickChangeAvatar(void *userdata)
00116 {
00117         LLFloaterAvatarPicker::show(onPickAvatar, userdata, FALSE, TRUE);
00118 }
00119 
00120 //static
00121 void LLPanelDatabase::onPickAvatar(const std::vector<std::string>& names,
00122                                    const std::vector<LLUUID>& ids,
00123                                    void* user_data)
00124 {
00125         if (names.empty()) return;
00126         if (ids.empty()) return;
00127 
00128         LLPanelDatabase *self = (LLPanelDatabase*)user_data;
00129 
00130 #ifndef LL_DEBUG
00131         // TODO: LL_DEBUG isn't the right one, what is it?
00132         //
00133         // Using yourself as the database avatar should work, and be useful
00134         // for debugging, but it's not something a normal user should be able
00135         // to do.
00136         
00137 //      if(ids[0] == gAgentID)
00138 //      {
00139 //              LLNotifyBox::showXml("AddSelfDatabase");
00140 //              return;
00141 //      }
00142 #endif
00143 
00144         self->childSetText("db_avatar", names[0]);
00145         self->mAvatarName = names[0];
00146         self->mAvatarKey = ids[0];
00147 }
00148 
00149 

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