DRTVWR-493 LLLogChat to singleton
parent
37eb735ba7
commit
0ea0b98084
|
|
@ -111,7 +111,7 @@ void LLFloaterConversationPreview::setPages(std::list<LLSD>* messages, const std
|
|||
getChild<LLTextBox>("page_num_label")->setValue(total_page_num);
|
||||
mShowHistory = true;
|
||||
}
|
||||
LLLoadHistoryThread* loadThread = LLLogChat::getLoadHistoryThread(mSessionID);
|
||||
LLLoadHistoryThread* loadThread = LLLogChat::getInstance()->getLoadHistoryThread(mSessionID);
|
||||
if (loadThread)
|
||||
{
|
||||
loadThread->removeLoadEndSignal(boost::bind(&LLFloaterConversationPreview::setPages, this, _1, _2));
|
||||
|
|
@ -135,7 +135,7 @@ void LLFloaterConversationPreview::onOpen(const LLSD& key)
|
|||
return;
|
||||
}
|
||||
mOpened = true;
|
||||
if (!LLLogChat::historyThreadsFinished(mSessionID))
|
||||
if (!LLLogChat::getInstance()->historyThreadsFinished(mSessionID))
|
||||
{
|
||||
LLNotificationsUtil::add("ChatHistoryIsBusyAlert");
|
||||
mHistoryThreadsBusy = true;
|
||||
|
|
@ -165,15 +165,16 @@ void LLFloaterConversationPreview::onOpen(const LLSD& key)
|
|||
// LLDeleteHistoryThread is started in destructor
|
||||
std::list<LLSD>* messages = new std::list<LLSD>();
|
||||
|
||||
LLLogChat::cleanupHistoryThreads();
|
||||
LLLogChat *log_chat_inst = LLLogChat::getInstance();
|
||||
log_chat_inst->cleanupHistoryThreads();
|
||||
|
||||
LLLoadHistoryThread* loadThread = new LLLoadHistoryThread(mChatHistoryFileName, messages, load_params);
|
||||
loadThread->setLoadEndSignal(boost::bind(&LLFloaterConversationPreview::setPages, this, _1, _2));
|
||||
loadThread->start();
|
||||
LLLogChat::addLoadHistoryThread(mSessionID, loadThread);
|
||||
log_chat_inst->addLoadHistoryThread(mSessionID, loadThread);
|
||||
|
||||
LLDeleteHistoryThread* deleteThread = new LLDeleteHistoryThread(messages, loadThread);
|
||||
LLLogChat::addDeleteHistoryThread(mSessionID, deleteThread);
|
||||
log_chat_inst->addDeleteHistoryThread(mSessionID, deleteThread);
|
||||
|
||||
mShowHistory = true;
|
||||
}
|
||||
|
|
@ -183,7 +184,7 @@ void LLFloaterConversationPreview::onClose(bool app_quitting)
|
|||
mOpened = false;
|
||||
if (!mHistoryThreadsBusy)
|
||||
{
|
||||
LLDeleteHistoryThread* deleteThread = LLLogChat::getDeleteHistoryThread(mSessionID);
|
||||
LLDeleteHistoryThread* deleteThread = LLLogChat::getInstance()->getDeleteHistoryThread(mSessionID);
|
||||
if (deleteThread)
|
||||
{
|
||||
deleteThread->start();
|
||||
|
|
|
|||
|
|
@ -523,7 +523,7 @@ BOOL LLFloaterPreference::postBuild()
|
|||
// set 'enable' property for 'Clear log...' button
|
||||
changed();
|
||||
|
||||
LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
|
||||
LLLogChat::getInstance()->setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
|
||||
|
||||
LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
|
||||
fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
|
||||
|
|
|
|||
|
|
@ -209,11 +209,24 @@ LLLogChatTimeScanner::LLLogChatTimeScanner()
|
|||
mTimeStream.imbue(std::locale(mTimeStream.getloc(), new time_input_facet(DATE_FORMAT)));
|
||||
}
|
||||
|
||||
LLLogChat::save_history_signal_t * LLLogChat::sSaveHistorySignal = NULL;
|
||||
LLLogChat::LLLogChat()
|
||||
: mSaveHistorySignal(NULL) // only needed in preferences
|
||||
{
|
||||
mHistoryThreadsMutex = new LLMutex();
|
||||
}
|
||||
|
||||
std::map<LLUUID,LLLoadHistoryThread *> LLLogChat::sLoadHistoryThreads;
|
||||
std::map<LLUUID,LLDeleteHistoryThread *> LLLogChat::sDeleteHistoryThreads;
|
||||
LLMutex* LLLogChat::sHistoryThreadsMutex = NULL;
|
||||
LLLogChat::~LLLogChat()
|
||||
{
|
||||
delete mHistoryThreadsMutex;
|
||||
mHistoryThreadsMutex = NULL;
|
||||
|
||||
if (mSaveHistorySignal)
|
||||
{
|
||||
mSaveHistorySignal->disconnect_all_slots();
|
||||
delete mSaveHistorySignal;
|
||||
mSaveHistorySignal = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//static
|
||||
|
|
@ -338,10 +351,7 @@ void LLLogChat::saveHistory(const std::string& filename,
|
|||
|
||||
file.close();
|
||||
|
||||
if (NULL != sSaveHistorySignal)
|
||||
{
|
||||
(*sSaveHistorySignal)();
|
||||
}
|
||||
LLLogChat::getInstance()->triggerHistorySignal();
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
@ -416,13 +426,12 @@ void LLLogChat::loadChatHistory(const std::string& file_name, std::list<LLSD>& m
|
|||
fclose(fptr);
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLLogChat::historyThreadsFinished(LLUUID session_id)
|
||||
{
|
||||
LLMutexLock lock(historyThreadsMutex());
|
||||
bool finished = true;
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::iterator it = sLoadHistoryThreads.find(session_id);
|
||||
if (it != sLoadHistoryThreads.end())
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::iterator it = mLoadHistoryThreads.find(session_id);
|
||||
if (it != mLoadHistoryThreads.end())
|
||||
{
|
||||
finished = it->second->isFinished();
|
||||
}
|
||||
|
|
@ -430,95 +439,93 @@ bool LLLogChat::historyThreadsFinished(LLUUID session_id)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
std::map<LLUUID,LLDeleteHistoryThread *>::iterator dit = sDeleteHistoryThreads.find(session_id);
|
||||
if (dit != sDeleteHistoryThreads.end())
|
||||
std::map<LLUUID,LLDeleteHistoryThread *>::iterator dit = mDeleteHistoryThreads.find(session_id);
|
||||
if (dit != mDeleteHistoryThreads.end())
|
||||
{
|
||||
finished = finished && dit->second->isFinished();
|
||||
}
|
||||
return finished;
|
||||
}
|
||||
|
||||
// static
|
||||
LLLoadHistoryThread* LLLogChat::getLoadHistoryThread(LLUUID session_id)
|
||||
{
|
||||
LLMutexLock lock(historyThreadsMutex());
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::iterator it = sLoadHistoryThreads.find(session_id);
|
||||
if (it != sLoadHistoryThreads.end())
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::iterator it = mLoadHistoryThreads.find(session_id);
|
||||
if (it != mLoadHistoryThreads.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
LLDeleteHistoryThread* LLLogChat::getDeleteHistoryThread(LLUUID session_id)
|
||||
{
|
||||
LLMutexLock lock(historyThreadsMutex());
|
||||
std::map<LLUUID,LLDeleteHistoryThread *>::iterator it = sDeleteHistoryThreads.find(session_id);
|
||||
if (it != sDeleteHistoryThreads.end())
|
||||
std::map<LLUUID,LLDeleteHistoryThread *>::iterator it = mDeleteHistoryThreads.find(session_id);
|
||||
if (it != mDeleteHistoryThreads.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLLogChat::addLoadHistoryThread(LLUUID& session_id, LLLoadHistoryThread* lthread)
|
||||
{
|
||||
LLMutexLock lock(historyThreadsMutex());
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::const_iterator it = sLoadHistoryThreads.find(session_id);
|
||||
if (it != sLoadHistoryThreads.end())
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::const_iterator it = mLoadHistoryThreads.find(session_id);
|
||||
if (it != mLoadHistoryThreads.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sLoadHistoryThreads[session_id] = lthread;
|
||||
mLoadHistoryThreads[session_id] = lthread;
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
bool LLLogChat::addDeleteHistoryThread(LLUUID& session_id, LLDeleteHistoryThread* dthread)
|
||||
{
|
||||
LLMutexLock lock(historyThreadsMutex());
|
||||
std::map<LLUUID,LLDeleteHistoryThread *>::const_iterator it = sDeleteHistoryThreads.find(session_id);
|
||||
if (it != sDeleteHistoryThreads.end())
|
||||
std::map<LLUUID,LLDeleteHistoryThread *>::const_iterator it = mDeleteHistoryThreads.find(session_id);
|
||||
if (it != mDeleteHistoryThreads.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sDeleteHistoryThreads[session_id] = dthread;
|
||||
mDeleteHistoryThreads[session_id] = dthread;
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
void LLLogChat::cleanupHistoryThreads()
|
||||
{
|
||||
LLMutexLock lock(historyThreadsMutex());
|
||||
std::vector<LLUUID> uuids;
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::iterator lit = sLoadHistoryThreads.begin();
|
||||
for (; lit != sLoadHistoryThreads.end(); lit++)
|
||||
std::map<LLUUID,LLLoadHistoryThread *>::iterator lit = mLoadHistoryThreads.begin();
|
||||
for (; lit != mLoadHistoryThreads.end(); lit++)
|
||||
{
|
||||
if (lit->second->isFinished() && sDeleteHistoryThreads[lit->first]->isFinished())
|
||||
if (lit->second->isFinished() && mDeleteHistoryThreads[lit->first]->isFinished())
|
||||
{
|
||||
delete lit->second;
|
||||
delete sDeleteHistoryThreads[lit->first];
|
||||
delete mDeleteHistoryThreads[lit->first];
|
||||
uuids.push_back(lit->first);
|
||||
}
|
||||
}
|
||||
std::vector<LLUUID>::iterator uuid_it = uuids.begin();
|
||||
for ( ;uuid_it != uuids.end(); uuid_it++)
|
||||
{
|
||||
sLoadHistoryThreads.erase(*uuid_it);
|
||||
sDeleteHistoryThreads.erase(*uuid_it);
|
||||
mLoadHistoryThreads.erase(*uuid_it);
|
||||
mDeleteHistoryThreads.erase(*uuid_it);
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
LLMutex* LLLogChat::historyThreadsMutex()
|
||||
{
|
||||
if (sHistoryThreadsMutex == NULL)
|
||||
{
|
||||
sHistoryThreadsMutex = new LLMutex();
|
||||
}
|
||||
return sHistoryThreadsMutex;
|
||||
return mHistoryThreadsMutex;
|
||||
}
|
||||
|
||||
void LLLogChat::triggerHistorySignal()
|
||||
{
|
||||
if (NULL != mSaveHistorySignal)
|
||||
{
|
||||
(*mSaveHistorySignal)();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
@ -596,15 +603,14 @@ void LLLogChat::getListOfTranscriptBackupFiles(std::vector<std::string>& list_of
|
|||
findTranscriptFiles(pattern, list_of_transcriptions);
|
||||
}
|
||||
|
||||
//static
|
||||
boost::signals2::connection LLLogChat::setSaveHistorySignal(const save_history_signal_t::slot_type& cb)
|
||||
{
|
||||
if (NULL == sSaveHistorySignal)
|
||||
if (NULL == mSaveHistorySignal)
|
||||
{
|
||||
sSaveHistorySignal = new save_history_signal_t();
|
||||
mSaveHistorySignal = new save_history_signal_t();
|
||||
}
|
||||
|
||||
return sSaveHistorySignal->connect(cb);
|
||||
return mSaveHistorySignal->connect(cb);
|
||||
}
|
||||
|
||||
//static
|
||||
|
|
|
|||
|
|
@ -79,8 +79,10 @@ public:
|
|||
static void deleteHistory();
|
||||
};
|
||||
|
||||
class LLLogChat
|
||||
class LLLogChat : public LLSingleton<LLLogChat>
|
||||
{
|
||||
LLSINGLETON(LLLogChat);
|
||||
~LLLogChat();
|
||||
public:
|
||||
// status values for callback function
|
||||
enum ELogLineType {
|
||||
|
|
@ -107,7 +109,7 @@ public:
|
|||
static void loadChatHistory(const std::string& file_name, std::list<LLSD>& messages, const LLSD& load_params = LLSD());
|
||||
|
||||
typedef boost::signals2::signal<void ()> save_history_signal_t;
|
||||
static boost::signals2::connection setSaveHistorySignal(const save_history_signal_t::slot_type& cb);
|
||||
boost::signals2::connection setSaveHistorySignal(const save_history_signal_t::slot_type& cb);
|
||||
|
||||
static bool moveTranscripts(const std::string currentDirectory,
|
||||
const std::string newDirectory,
|
||||
|
|
@ -123,21 +125,23 @@ public:
|
|||
static bool isAdHocTranscriptExist(std::string file_name);
|
||||
static bool isTranscriptFileFound(std::string fullname);
|
||||
|
||||
static bool historyThreadsFinished(LLUUID session_id);
|
||||
static LLLoadHistoryThread* getLoadHistoryThread(LLUUID session_id);
|
||||
static LLDeleteHistoryThread* getDeleteHistoryThread(LLUUID session_id);
|
||||
static bool addLoadHistoryThread(LLUUID& session_id, LLLoadHistoryThread* lthread);
|
||||
static bool addDeleteHistoryThread(LLUUID& session_id, LLDeleteHistoryThread* dthread);
|
||||
static void cleanupHistoryThreads();
|
||||
bool historyThreadsFinished(LLUUID session_id);
|
||||
LLLoadHistoryThread* getLoadHistoryThread(LLUUID session_id);
|
||||
LLDeleteHistoryThread* getDeleteHistoryThread(LLUUID session_id);
|
||||
bool addLoadHistoryThread(LLUUID& session_id, LLLoadHistoryThread* lthread);
|
||||
bool addDeleteHistoryThread(LLUUID& session_id, LLDeleteHistoryThread* dthread);
|
||||
void cleanupHistoryThreads();
|
||||
|
||||
private:
|
||||
static std::string cleanFileName(std::string filename);
|
||||
static save_history_signal_t * sSaveHistorySignal;
|
||||
|
||||
static std::map<LLUUID,LLLoadHistoryThread *> sLoadHistoryThreads;
|
||||
static std::map<LLUUID,LLDeleteHistoryThread *> sDeleteHistoryThreads;
|
||||
static LLMutex* sHistoryThreadsMutex;
|
||||
static LLMutex* historyThreadsMutex();
|
||||
LLMutex* historyThreadsMutex();
|
||||
void triggerHistorySignal();
|
||||
|
||||
save_history_signal_t * mSaveHistorySignal;
|
||||
std::map<LLUUID,LLLoadHistoryThread *> mLoadHistoryThreads;
|
||||
std::map<LLUUID,LLDeleteHistoryThread *> mDeleteHistoryThreads;
|
||||
LLMutex* mHistoryThreadsMutex;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue