From a6ada6652524fc2b708bdae82ca3b5cb44bbbb2d Mon Sep 17 00:00:00 2001 From: thickbrick Date: Tue, 30 Nov 2010 16:53:55 +0200 Subject: Fix #673: IMs & Logging prefs don't persist Enable per-account settings only after we have an account. Also, make settings that are saved locally not depend on UserInfoReply being received. --- linden/indra/newview/llfloaterpreference.cpp | 14 ++ linden/indra/newview/llfloaterpreference.h | 3 + linden/indra/newview/llprefsim.cpp | 166 ++++++++++++--------- linden/indra/newview/llprefsim.h | 1 + linden/indra/newview/llstartup.cpp | 3 + .../default/xui/en-us/panel_preferences_im.xml | 3 + 6 files changed, 117 insertions(+), 73 deletions(-) diff --git a/linden/indra/newview/llfloaterpreference.cpp b/linden/indra/newview/llfloaterpreference.cpp index 2fe4b4d..0f81be6 100644 --- a/linden/indra/newview/llfloaterpreference.cpp +++ b/linden/indra/newview/llfloaterpreference.cpp @@ -362,6 +362,11 @@ void LLPreferenceCore::setPersonalInfo(const std::string& visibility, bool im_vi mPrefsIM->setPersonalInfo(visibility, im_via_email, email); } +void LLPreferenceCore::updateIsLoggedIn(bool enable) +{ + mPrefsIM->preparePerAccountPrefs(enable); +} + void LLPreferenceCore::refreshEnabledGraphics() { LLFloaterHardwareSettings::instance()->refreshEnabledState(); @@ -537,6 +542,15 @@ void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_ } } +// static +void LLFloaterPreference::updateIsLoggedIn(bool enable) +{ + if(sInstance && sInstance->mPreferenceCore) + { + sInstance->mPreferenceCore->updateIsLoggedIn(enable); + } +} + void LLFloaterPreference::refreshEnabledGraphics() { sInstance->mPreferenceCore->refreshEnabledGraphics(); diff --git a/linden/indra/newview/llfloaterpreference.h b/linden/indra/newview/llfloaterpreference.h index c52f541..931c8b6 100644 --- a/linden/indra/newview/llfloaterpreference.h +++ b/linden/indra/newview/llfloaterpreference.h @@ -73,6 +73,7 @@ public: LLTabContainer* getTabContainer() { return mTabContainer; } void setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email); + void updateIsLoggedIn(bool enable); static void onTabChanged(void* user_data, bool from_click); @@ -113,6 +114,8 @@ public: // static data update, called from message handler static void updateUserInfo(const std::string& visibility, bool im_via_email, const std::string& email); + // static data update, called after login + static void updateIsLoggedIn(bool enable); // refresh all the graphics preferences menus static void refreshEnabledGraphics(); diff --git a/linden/indra/newview/llprefsim.cpp b/linden/indra/newview/llprefsim.cpp index 9e86cd3..5ac2bb2 100644 --- a/linden/indra/newview/llprefsim.cpp +++ b/linden/indra/newview/llprefsim.cpp @@ -66,6 +66,7 @@ public: void apply(); void cancel(); void setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email); + void preparePerAccountPrefs(bool enable); void enableHistory(); static void onClickLogPath(void* user_data); @@ -76,6 +77,7 @@ public: protected: bool mGotPersonalInfo; + bool mGotPerAccountSettings; bool mOriginalIMViaEmail; bool mOriginalHideOnlineStatus; @@ -86,7 +88,9 @@ protected: LLPrefsIMImpl::LLPrefsIMImpl() : LLPanel(std::string("IM Prefs Panel")), mGotPersonalInfo(false), - mOriginalIMViaEmail(false) + mGotPerAccountSettings(false), + mOriginalIMViaEmail(false), + mOriginalHideOnlineStatus(false) { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_im.xml"); } @@ -106,55 +110,38 @@ BOOL LLPrefsIMImpl::postBuild() childSetLabelArg("send_im_to_email", "[EMAIL]", getString("log_in_to_change")); - // Don't enable this until we get personal data - // Unless we're already logged in. Some non-SL grids won't send us the data we need -- MC - childSetEnabled("include_im_in_chat_console", LLStartUp::isLoggedIn()); - childSetEnabled("include_im_in_chat_history", LLStartUp::isLoggedIn()); - childSetEnabled("show_timestamps_check", LLStartUp::isLoggedIn()); - childSetEnabled("friends_online_notify_checkbox", LLStartUp::isLoggedIn()); - - childSetEnabled("online_visibility", LLStartUp::isLoggedIn()); - childSetEnabled("send_im_to_email", LLStartUp::isLoggedIn()); - childSetEnabled("log_instant_messages", LLStartUp::isLoggedIn()); - childSetEnabled("log_chat", LLStartUp::isLoggedIn()); - childSetEnabled("log_show_history", LLStartUp::isLoggedIn()); - childSetEnabled("log_path_button", LLStartUp::isLoggedIn()); - childSetEnabled("busy_response", LLStartUp::isLoggedIn()); - childSetEnabled("log_instant_messages_timestamp", LLStartUp::isLoggedIn()); - childSetEnabled("log_chat_timestamp", LLStartUp::isLoggedIn()); - childSetEnabled("log_chat_IM", LLStartUp::isLoggedIn()); - childSetEnabled("log_date_timestamp", LLStartUp::isLoggedIn()); - - childSetText("busy_response", getString("log_in_to_change")); + // Don't enable these until we get personal data + childSetEnabled("online_visibility", false); + childSetEnabled("send_im_to_email", false); + // These are safe to enable + childSetEnabled("include_im_in_chat_console", true); + childSetEnabled("include_im_in_chat_history", true); + childSetEnabled("show_timestamps_check", true); + childSetEnabled("friends_online_notify_checkbox", true); + childSetEnabled("vertical-imtabs-toggle", true); childSetValue("include_im_in_chat_console", gSavedSettings.getBOOL("IMInChatConsole")); childSetValue("include_im_in_chat_history", gSavedSettings.getBOOL("IMInChatHistory")); childSetValue("show_timestamps_check", gSavedSettings.getBOOL("IMShowTimestamps")); childSetValue("friends_online_notify_checkbox", gSavedSettings.getBOOL("ChatOnlineNotification")); childSetValue("vertical-imtabs-toggle", gSavedSettings.getBOOL("VerticalIMTabs")); - childSetText("log_path_string", gSavedPerAccountSettings.getString("InstantMessageLogPath")); - childSetValue("log_instant_messages", gSavedPerAccountSettings.getBOOL("LogInstantMessages")); - childSetValue("log_chat", gSavedPerAccountSettings.getBOOL("LogChat")); - childSetValue("log_show_history", gSavedPerAccountSettings.getBOOL("LogShowHistory")); - childSetValue("log_instant_messages_timestamp", gSavedPerAccountSettings.getBOOL("IMLogTimestamp")); - childSetValue("log_chat_timestamp", gSavedPerAccountSettings.getBOOL("LogChatTimestamp")); - childSetValue("log_chat_IM", gSavedPerAccountSettings.getBOOL("LogChatIM")); - childSetValue("log_date_timestamp", gSavedPerAccountSettings.getBOOL("LogTimestampDate")); - childSetAction("log_path_button", onClickLogPath, this); childSetCommitCallback("log_chat",onCommitLogging,this); childSetCommitCallback("log_instant_messages",onCommitLogging,this); childSetAction("busy_adv_btn", onClickBusyAdvanced, this); + preparePerAccountPrefs(LLStartUp::isLoggedIn()); + return TRUE; } void LLPrefsIMImpl::enableHistory() { - if (childGetValue("log_instant_messages").asBoolean() || childGetValue("log_chat").asBoolean()) + if (mGotPerAccountSettings && + (childGetValue("log_instant_messages").asBoolean() || childGetValue("log_chat").asBoolean())) { childEnable("log_show_history"); childEnable("log_path_button"); @@ -168,23 +155,16 @@ void LLPrefsIMImpl::enableHistory() void LLPrefsIMImpl::apply() { - LLTextEditor* busy = getChild("busy_response"); - LLWString busy_response; - if (busy) busy_response = busy->getWText(); - LLWStringUtil::replaceTabsWithSpaces(busy_response, 4); - LLWStringUtil::replaceChar(busy_response, '\n', '^'); - LLWStringUtil::replaceChar(busy_response, ' ', '%'); - - if(mGotPersonalInfo) + if (mGotPerAccountSettings) { - + LLTextEditor* busy = getChild("busy_response"); + LLWString busy_response; + if (busy) busy_response = busy->getWText(); + LLWStringUtil::replaceTabsWithSpaces(busy_response, 4); + LLWStringUtil::replaceChar(busy_response, '\n', '^'); + LLWStringUtil::replaceChar(busy_response, ' ', '%'); gSavedPerAccountSettings.setString("BusyModeResponse", std::string(wstring_to_utf8str(busy_response))); - gSavedSettings.setBOOL("IMInChatConsole", childGetValue("include_im_in_chat_console").asBoolean()); - gSavedSettings.setBOOL("IMInChatHistory", childGetValue("include_im_in_chat_history").asBoolean()); - gSavedSettings.setBOOL("IMShowTimestamps", childGetValue("show_timestamps_check").asBoolean()); - gSavedSettings.setBOOL("ChatOnlineNotification", childGetValue("friends_online_notify_checkbox").asBoolean()); - gSavedPerAccountSettings.setString("InstantMessageLogPath", childGetText("log_path_string")); gSavedPerAccountSettings.setBOOL("LogInstantMessages",childGetValue("log_instant_messages").asBoolean()); gSavedPerAccountSettings.setBOOL("LogChat",childGetValue("log_chat").asBoolean()); @@ -207,7 +187,10 @@ void LLPrefsIMImpl::apply() gSavedSettings.getString("FirstName"), gSavedSettings.getString("LastName") ); } LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir()); - + } + + if (mGotPersonalInfo) + { bool new_im_via_email = childGetValue("send_im_to_email").asBoolean(); bool new_hide_online = childGetValue("online_visibility").asBoolean(); @@ -237,9 +220,15 @@ void LLPrefsIMImpl::apply() gAgent.sendReliableMessage(); } } + gSavedSettings.setBOOL("VerticalIMTabs", childGetValue("vertical-imtabs-toggle").asBoolean()); + gSavedSettings.setBOOL("IMInChatConsole", childGetValue("include_im_in_chat_console").asBoolean()); + gSavedSettings.setBOOL("IMInChatHistory", childGetValue("include_im_in_chat_history").asBoolean()); + gSavedSettings.setBOOL("IMShowTimestamps", childGetValue("show_timestamps_check").asBoolean()); + gSavedSettings.setBOOL("ChatOnlineNotification", childGetValue("friends_online_notify_checkbox").asBoolean()); } +// Enable and set the value of settings recieved from the sim in AgentInfoReply void LLPrefsIMImpl::setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email) { mGotPersonalInfo = true; @@ -261,36 +250,10 @@ void LLPrefsIMImpl::setPersonalInfo(const std::string& visibility, bool im_via_e mOriginalHideOnlineStatus = true; } - childEnable("include_im_in_chat_console"); - childEnable("include_im_in_chat_history"); - childEnable("show_timestamps_check"); - childEnable("friends_online_notify_checkbox"); - childSetValue("online_visibility", mOriginalHideOnlineStatus); childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility); childEnable("send_im_to_email"); childSetValue("send_im_to_email", im_via_email); - childEnable("log_instant_messages"); - childEnable("log_chat"); - childEnable("busy_response"); - childEnable("log_instant_messages_timestamp"); - childEnable("log_chat_timestamp"); - childEnable("log_chat_IM"); - childEnable("log_date_timestamp"); - - //RN: get wide string so replace char can work (requires fixed-width encoding) - LLWString busy_response = utf8str_to_wstring( gSavedPerAccountSettings.getString("BusyModeResponse") ); - LLWStringUtil::replaceChar(busy_response, '^', '\n'); - LLWStringUtil::replaceChar(busy_response, '%', ' '); - childSetText("busy_response", wstring_to_utf8str(busy_response)); -// [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) - if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM)) - { - childDisable("busy_response"); - } -// [/RLVa:KB] - - enableHistory(); // Truncate the e-mail address if it's too long (to prevent going off // the edge of the dialog). @@ -300,10 +263,62 @@ void LLPrefsIMImpl::setPersonalInfo(const std::string& visibility, bool im_via_e display_email.resize(30); display_email += "..."; } - + else if (display_email.empty()) + { + display_email = getString("default_email_used"); + } childSetLabelArg("send_im_to_email", "[EMAIL]", display_email); } +// Enable and set the value of settings that need an account name +void LLPrefsIMImpl::preparePerAccountPrefs(bool enable) +{ + if (mGotPerAccountSettings && enable) + { + return; // prevent overwriting unsaved changes. + } + mGotPerAccountSettings = enable; + + childSetEnabled("log_chat", enable); + childSetEnabled("log_chat_timestamp", enable); + childSetEnabled("log_chat_IM", enable); + childSetEnabled("log_instant_messages_timestamp", enable); + childSetEnabled("log_instant_messages", enable); + childSetEnabled("log_date_timestamp", enable); + + childSetValue("log_chat", gSavedPerAccountSettings.getBOOL("LogChat")); + childSetValue("log_chat_timestamp", gSavedPerAccountSettings.getBOOL("LogChatTimestamp")); + childSetValue("log_chat_IM", gSavedPerAccountSettings.getBOOL("LogChatIM")); + childSetValue("log_instant_messages_timestamp", gSavedPerAccountSettings.getBOOL("IMLogTimestamp")); + childSetValue("log_instant_messages", gSavedPerAccountSettings.getBOOL("LogInstantMessages")); + childSetValue("log_date_timestamp", gSavedPerAccountSettings.getBOOL("LogTimestampDate")); + + childSetValue("log_show_history", gSavedPerAccountSettings.getBOOL("LogShowHistory")); + enableHistory(); + childSetText("log_path_string", gSavedPerAccountSettings.getString("InstantMessageLogPath")); + + childSetEnabled("busy_response", enable); + if (enable) + { + //RN: get wide string so replace char can work (requires fixed-width encoding) + LLWString busy_response = utf8str_to_wstring( gSavedPerAccountSettings.getString("BusyModeResponse") ); + LLWStringUtil::replaceChar(busy_response, '^', '\n'); + LLWStringUtil::replaceChar(busy_response, '%', ' '); + childSetText("busy_response", wstring_to_utf8str(busy_response)); + } + else + { + childSetText("busy_response", getString("log_in_to_change")); + } +// [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) + if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDIM)) + { + childDisable("busy_response"); + } +// [/RLVa:KB] + + childSetEnabled("busy_adv_btn", enable); +} // static void LLPrefsIMImpl::onClickBusyAdvanced(void* user_data) @@ -363,6 +378,11 @@ void LLPrefsIM::setPersonalInfo(const std::string& visibility, bool im_via_email impl.setPersonalInfo(visibility, im_via_email, email); } +void LLPrefsIM::preparePerAccountPrefs(bool enable) +{ + impl.preparePerAccountPrefs(enable); +} + LLPanel* LLPrefsIM::getPanel() { return &impl; diff --git a/linden/indra/newview/llprefsim.h b/linden/indra/newview/llprefsim.h index 90bf465..acf9b0f 100644 --- a/linden/indra/newview/llprefsim.h +++ b/linden/indra/newview/llprefsim.h @@ -46,6 +46,7 @@ public: void apply(); void cancel(); void setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email); + void preparePerAccountPrefs(bool enable); LLPanel* getPanel(); diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index b744961..aba9bb6 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp @@ -101,6 +101,7 @@ #include "llfloatergesture.h" #include "llfloaterhud.h" #include "llfloaterland.h" +#include "llfloaterpreference.h" #include "llfloaterteleporthistory.h" #include "llfloatertopobjects.h" #include "llfloatertos.h" @@ -2876,6 +2877,8 @@ bool idle_startup() gDebugView->mFastTimerView->setVisible(TRUE); #endif + LLFloaterPreference::updateIsLoggedIn(true); + return TRUE; } diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_im.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_im.xml index e64f6c7..fe17e7a 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_im.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_im.xml @@ -22,6 +22,9 @@ log in to change + + using default address +