Changeset - c0687aba7478
[Not reviewed]
0 2 0
HanzZ - 12 years ago 2013-02-17 17:13:14
hanzz.k@gmail.com
Libtransport: Move message caching to one method
2 files changed with 14 insertions and 16 deletions:
0 comments (0 inline, 0 general)
include/transport/conversation.h
Show inline comments
 
@@ -153,6 +153,7 @@ class Conversation {
 

	
 
	private:
 
		Swift::Presence::ref generatePresence(const std::string &nick, int flag, int status, const std::string &statusMessage, const std::string &newname = "");
 
		void cacheMessage(boost::shared_ptr<Swift::Message> &message);
 

	
 
	private:
 
		ConversationManager *m_conversationManager;
src/conversation.cpp
Show inline comments
 
@@ -86,17 +86,21 @@ void Conversation::setRoom(const std::string &room) {
 
	m_legacyName = m_room + "/" + m_legacyName;
 
}
 

	
 
void Conversation::cacheMessage(boost::shared_ptr<Swift::Message> &message) {
 
	boost::posix_time::ptime timestamp = boost::posix_time::second_clock::universal_time();
 
	boost::shared_ptr<Swift::Delay> delay(boost::make_shared<Swift::Delay>());
 
	delay->setStamp(timestamp);
 
	message->addPayload(delay);
 
	m_cachedMessages.push_back(message);
 
	if (m_cachedMessages.size() > 100) {
 
		m_cachedMessages.pop_front();
 
	}
 
}
 

	
 
void Conversation::handleRawMessage(boost::shared_ptr<Swift::Message> &message) {
 
	if (message->getType() != Swift::Message::Groupchat) {
 
		if (m_conversationManager->getComponent()->inServerMode() && m_conversationManager->getUser()->shouldCacheMessages()) {
 
			boost::posix_time::ptime timestamp = boost::posix_time::second_clock::universal_time();
 
			boost::shared_ptr<Swift::Delay> delay(boost::make_shared<Swift::Delay>());
 
			delay->setStamp(timestamp);
 
			message->addPayload(delay);
 
			m_cachedMessages.push_back(message);
 
			if (m_cachedMessages.size() > 100) {
 
				m_cachedMessages.pop_front();
 
			}
 
			cacheMessage(message);
 
		}
 
		else {
 
			m_conversationManager->getComponent()->getStanzaChannel()->sendMessage(message);
 
@@ -104,14 +108,7 @@ void Conversation::handleRawMessage(boost::shared_ptr<Swift::Message> &message)
 
	}
 
	else {
 
		if (m_jids.empty()) {
 
			boost::posix_time::ptime timestamp = boost::posix_time::second_clock::universal_time();
 
			boost::shared_ptr<Swift::Delay> delay(boost::make_shared<Swift::Delay>());
 
			delay->setStamp(timestamp);
 
			message->addPayload(delay);
 
			m_cachedMessages.push_back(message);
 
			if (m_cachedMessages.size() > 100) {
 
				m_cachedMessages.pop_front();
 
			}
 
			cacheMessage(message);
 
		}
 
		else {
 
			BOOST_FOREACH(const Swift::JID &jid, m_jids) {
0 comments (0 inline, 0 general)