mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-02 19:26:31 -04:00
Moved the chat history into the libretroshare.
Now the history is saved encrypted. Please delete all files with "chat*.xml" in your profile folder. Added new config p3HistoryMgr and interface p3History. Added new option to limit the count of the saved history items. Added new simple html optimizer "RsHtml::optimizeHtml" to reduce the size of the html strings. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4623 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c6a68fe05e
commit
29c090fb44
45 changed files with 1721 additions and 1406 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "pqi/pqinotify.h"
|
||||
#include "pqi/pqistore.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3historymgr.h"
|
||||
|
||||
#include "services/p3chatservice.h"
|
||||
|
||||
|
@ -42,8 +43,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
p3ChatService::p3ChatService(p3LinkMgr *lm)
|
||||
:p3Service(RS_SERVICE_TYPE_CHAT), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mLinkMgr(lm)
|
||||
p3ChatService::p3ChatService(p3LinkMgr *lm, p3HistoryMgr *historyMgr)
|
||||
:p3Service(RS_SERVICE_TYPE_CHAT), p3Config(CONFIG_TYPE_CHAT), mChatMtx("p3ChatService"), mLinkMgr(lm) , mHistoryMgr(historyMgr)
|
||||
{
|
||||
addSerialType(new RsChatSerialiser());
|
||||
|
||||
|
@ -67,7 +68,7 @@ int p3ChatService::status()
|
|||
|
||||
/***************** Chat Stuff **********************/
|
||||
|
||||
int p3ChatService::sendPublicChat(std::wstring &msg)
|
||||
int p3ChatService::sendPublicChat(const std::wstring &msg)
|
||||
{
|
||||
/* go through all the peers */
|
||||
|
||||
|
@ -76,7 +77,8 @@ int p3ChatService::sendPublicChat(std::wstring &msg)
|
|||
mLinkMgr->getOnlineList(ids);
|
||||
|
||||
/* add in own id -> so get reflection */
|
||||
ids.push_back(mLinkMgr->getOwnId());
|
||||
std::string ownId = mLinkMgr->getOwnId();
|
||||
ids.push_back(ownId);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat()";
|
||||
|
@ -92,7 +94,7 @@ int p3ChatService::sendPublicChat(std::wstring &msg)
|
|||
ci->sendTime = time(NULL);
|
||||
ci->recvTime = ci->sendTime;
|
||||
ci->message = msg;
|
||||
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat() Item:";
|
||||
std::cerr << std::endl;
|
||||
|
@ -100,6 +102,9 @@ int p3ChatService::sendPublicChat(std::wstring &msg)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (*it == ownId) {
|
||||
mHistoryMgr->addMessage(false, "", ownId, ci);
|
||||
}
|
||||
sendItem(ci);
|
||||
}
|
||||
|
||||
|
@ -220,7 +225,7 @@ void p3ChatService::checkSizeAndSendMessage(RsChatMsgItem *msg)
|
|||
sendItem(msg) ;
|
||||
}
|
||||
|
||||
bool p3ChatService::sendPrivateChat(std::string &id, std::wstring &msg)
|
||||
bool p3ChatService::sendPrivateChat(const std::string &id, const std::wstring &msg)
|
||||
{
|
||||
// make chat item....
|
||||
#ifdef CHAT_DEBUG
|
||||
|
@ -278,6 +283,8 @@ bool p3ChatService::sendPrivateChat(std::string &id, std::wstring &msg)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mHistoryMgr->addMessage(false, id, mLinkMgr->getOwnId(), ci);
|
||||
|
||||
checkSizeAndSendMessage(ci);
|
||||
|
||||
// Check if custom state string has changed, in which case it should be sent to the peer.
|
||||
|
@ -428,9 +435,16 @@ void p3ChatService::receiveChatQueue()
|
|||
if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) {
|
||||
privateChanged = true;
|
||||
privateIncomingList.push_back(ci); // don't delete the item !!
|
||||
|
||||
mHistoryMgr->addMessage(true, ci->PeerId(), ci->PeerId(), ci);
|
||||
} else {
|
||||
publicChanged = true;
|
||||
publicList.push_back(ci); // don't delete the item !!
|
||||
|
||||
if (ci->PeerId() != mLinkMgr->getOwnId()) {
|
||||
/* not from loop back */
|
||||
mHistoryMgr->addMessage(true, "", ci->PeerId(), ci);
|
||||
}
|
||||
}
|
||||
} /* UNLOCK */
|
||||
}
|
||||
|
@ -1088,12 +1102,16 @@ void p3ChatService::statusChange(const std::list<pqipeer> &plist)
|
|||
if (privateOutgoingList.size()) {
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::string ownId = mLinkMgr->getOwnId();
|
||||
|
||||
std::list<RsChatMsgItem *>::iterator cit = privateOutgoingList.begin();
|
||||
while (cit != privateOutgoingList.end()) {
|
||||
RsChatMsgItem *c = *cit;
|
||||
|
||||
if (c->PeerId() == it->id) {
|
||||
sendItem(c); // delete item
|
||||
mHistoryMgr->addMessage(false, c->PeerId(), ownId, c);
|
||||
|
||||
checkSizeAndSendMessage(c); // delete item
|
||||
|
||||
changed = true;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "retroshare/rsmsgs.h"
|
||||
|
||||
class p3LinkMgr;
|
||||
class p3HistoryMgr;
|
||||
|
||||
//!The basic Chat service.
|
||||
/**
|
||||
|
@ -46,7 +47,7 @@ class p3LinkMgr;
|
|||
class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
{
|
||||
public:
|
||||
p3ChatService(p3LinkMgr *cm);
|
||||
p3ChatService(p3LinkMgr *cm, p3HistoryMgr *historyMgr);
|
||||
|
||||
/***** overloaded from p3Service *****/
|
||||
/*!
|
||||
|
@ -65,14 +66,14 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
|||
/*!
|
||||
* public chat sent to all peers
|
||||
*/
|
||||
int sendPublicChat(std::wstring &msg);
|
||||
int sendPublicChat(const std::wstring &msg);
|
||||
|
||||
/********* RsMsgs ***********/
|
||||
/*!
|
||||
* chat is sent to specifc peer
|
||||
* @param id peer to send chat msg to
|
||||
*/
|
||||
bool sendPrivateChat(std::string &id, std::wstring &msg);
|
||||
bool sendPrivateChat(const std::string &id, const std::wstring &msg);
|
||||
|
||||
/*!
|
||||
* can be used to send 'immediate' status msgs, these status updates are meant for immediate use by peer (not saved by rs)
|
||||
|
@ -201,6 +202,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
|||
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
p3HistoryMgr *mHistoryMgr;
|
||||
|
||||
std::list<RsChatMsgItem *> publicList;
|
||||
std::list<RsChatMsgItem *> privateIncomingList;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue