From f69510e20c14f8afbdaa9fad06f7dbb2ba09b774 Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Tue, 2 Feb 2010 14:19:15 +0200 Subject: added loading/parsing of Nearby Chat history - EXT-4777 Implement saving and loading chat history for Nearby Chat (both plain text and widgeted chat) --HG-- branch : product-engine --- indra/newview/llnearbychat.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ indra/newview/llnearbychat.h | 4 ++++ indra/newview/llstartup.cpp | 10 ++++++++++ 3 files changed, 54 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index 90482eb74d..1dcb6abf81 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -62,6 +62,12 @@ static const S32 RESIZE_BAR_THICKNESS = 3; +const static std::string IM_TIME("time"); +const static std::string IM_TEXT("message"); +const static std::string IM_FROM("from"); +const static std::string IM_FROM_ID("from_id"); + + LLNearbyChat::LLNearbyChat(const LLSD& key) : LLDockableFloater(NULL, false, false, key) ,mChatHistory(NULL) @@ -262,6 +268,39 @@ void LLNearbyChat::processChatHistoryStyleUpdate(const LLSD& newvalue) nearby_chat->updateChatHistoryStyle(); } +void LLNearbyChat::loadHistory() +{ + std::list history; + LLLogChat::loadAllHistory("chat", history); + + std::list::const_iterator it = history.begin(); + while (it != history.end()) + { + const LLSD& msg = *it; + + std::string from = msg[IM_FROM]; + LLUUID from_id = LLUUID::null; + if (msg[IM_FROM_ID].isUndefined()) + { + gCacheName->getUUID(from, from_id); + } + + LLChat chat; + chat.mFromName = from; + chat.mFromID = from_id; + chat.mText = msg[IM_TEXT]; + chat.mTimeStr = msg[IM_TIME]; + addMessage(chat); + + it++; + } +} + +//static +LLNearbyChat* LLNearbyChat::getInstance() +{ + return LLFloaterReg::getTypedInstance("nearby_chat", LLSD()); +} //////////////////////////////////////////////////////////////////////////////// // @@ -278,3 +317,4 @@ void LLNearbyChat::onFocusLost() setBackgroundOpaque(false); LLPanel::onFocusLost(); } + diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h index 5fb8ade19e..6ea4248578 100644 --- a/indra/newview/llnearbychat.h +++ b/indra/newview/llnearbychat.h @@ -65,6 +65,10 @@ public: static void processChatHistoryStyleUpdate(const LLSD& newvalue); + void loadHistory(); + + static LLNearbyChat* getInstance(); + private: virtual void applySavedVariables(); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 6b816f8786..ce5da8bb24 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -67,6 +67,7 @@ #include "llmemorystream.h" #include "llmessageconfig.h" #include "llmoveview.h" +#include "llnearbychat.h" #include "llnotifications.h" #include "llnotificationsutil.h" #include "llteleporthistory.h" @@ -904,6 +905,7 @@ bool idle_startup() LLFile::mkdir(gDirUtilp->getChatLogsDir()); LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir()); + //good as place as any to create user windlight directories std::string user_windlight_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", "")); LLFile::mkdir(user_windlight_path_name.c_str()); @@ -1284,6 +1286,14 @@ bool idle_startup() LLAppViewer::instance()->loadNameCache(); } + //gCacheName is required for nearby chat history loading + //so I just moved nearby history loading a few states further + if (!gNoRender && gSavedPerAccountSettings.getBOOL("LogShowHistory")) + { + LLNearbyChat* nearby_chat = LLNearbyChat::getInstance(); + if (nearby_chat) nearby_chat->loadHistory(); + } + // *Note: this is where gWorldMap used to be initialized. // register null callbacks for audio until the audio system is initialized -- cgit v1.2.3 From 0763fac7653d0c280ed2fd808f2c1bb594c2e804 Mon Sep 17 00:00:00 2001 From: Igor Borovkov Date: Tue, 2 Feb 2010 14:37:31 +0200 Subject: added saving of nearby chat history - EXT-4777 Implement saving and loading chat history for Nearby Chat (both plain text and widgeted chat) --HG-- branch : product-engine --- indra/newview/llnearbychat.cpp | 12 ++++++++++++ indra/newview/llnearbychat.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index 1dcb6abf81..49ab61556f 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -200,6 +200,18 @@ void LLNearbyChat::addMessage(const LLChat& chat,bool archive,const LLSD &args) mMessageArchive.push_back(chat); if(mMessageArchive.size()>200) mMessageArchive.erase(mMessageArchive.begin()); + + if (gSavedPerAccountSettings.getBOOL("LogChat")) + { + if (chat.mChatType != CHAT_TYPE_WHISPER && chat.mChatType != CHAT_TYPE_SHOUT) + { + LLLogChat::saveHistory("chat", chat.mFromName, chat.mFromID, chat.mText); + } + else + { + LLLogChat::saveHistory("chat", "", chat.mFromID, chat.mFromName + " " + chat.mText); + } + } } } diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h index 6ea4248578..6ef2a1fee3 100644 --- a/indra/newview/llnearbychat.h +++ b/indra/newview/llnearbychat.h @@ -47,6 +47,8 @@ public: ~LLNearbyChat(); BOOL postBuild (); + + /** @param archive true - to save a message to the chat history log */ void addMessage (const LLChat& message,bool archive = true, const LLSD &args = LLSD()); void onNearbyChatContextMenuItemClicked(const LLSD& userdata); bool onNearbyChatCheckContextMenuItem(const LLSD& userdata); -- cgit v1.2.3