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:
thunder2 2011-09-29 09:20:09 +00:00
parent c6a68fe05e
commit 29c090fb44
45 changed files with 1721 additions and 1406 deletions

View file

@ -0,0 +1,83 @@
#ifndef RS_HISTORY_INTERFACE_H
#define RS_HISTORY_INTERFACE_H
/*
* libretroshare/src/retroshare: rshistory.h
*
* RetroShare C++ .
*
* Copyright 2011 by Thunder.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
class RsHistory;
extern RsHistory *rsHistory;
#include <string>
#include <inttypes.h>
#include <list>
//! data object for message history
/*!
* data object used for message history
*/
class HistoryMsg
{
public:
HistoryMsg()
{
msgId = 0;
incoming = false;
sendTime = 0;
recvTime = 0;
}
public:
uint32_t msgId;
std::string chatPeerId;
bool incoming;
std::string peerId;
std::string peerName;
uint32_t sendTime;
uint32_t recvTime;
std::string message;
};
//! Interface to retroshare for message history
/*!
* Provides an interface for retroshare's message history functionality
*/
class RsHistory
{
public:
virtual bool getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
virtual void clear(const std::string &chatPeerId) = 0;
virtual bool getEnable(bool ofPublic) = 0;
virtual void setEnable(bool forPublic, bool enable) = 0;
// 0 = no limit, >0 count of saved messages
virtual uint32_t getSaveCount(bool ofPublic) = 0;
virtual void setSaveCount(bool forPublic, uint32_t count) = 0;
};
#endif

View file

@ -185,7 +185,6 @@ class NotifyBase
virtual void notifyListPreChange(int list, int type) { (void) list; (void) type; return; }
virtual void notifyListChange(int list, int type) { (void) list; (void) type; return; }
virtual void notifyErrorMsg(int list, int sev, std::string msg) { (void) list; (void) sev; (void) msg; return; }
virtual void notifyChat() { return; }
virtual void notifyChatStatus(const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) {}
virtual void notifyCustomState(const std::string& /* peer_id */, const std::string& /* status_string */) {}
virtual void notifyHashingInfo(uint32_t type, const std::string& fileinfo) { (void) type; (void)fileinfo; }
@ -202,6 +201,7 @@ class NotifyBase
virtual void notifyDiscInfoChanged() {}
virtual void notifyDownloadComplete(const std::string& /* fileHash */) {};
virtual void notifyDownloadCompleteCount(uint32_t /* count */) {};
virtual void notifyHistoryChanged(uint32_t /* msgId */, int /* type */) {}
virtual bool askForPassword(const std::string& /* key_details */, bool /* prev_is_bad */, std::string& /* password */ ) { return false ;}
};

View file

@ -125,7 +125,7 @@ public:
#define RS_CHAT_PRIVATE 0x0002
#define RS_CHAT_AVATAR_AVAILABLE 0x0004
class ChatInfo
class ChatInfo
{
public:
std::string rsid;
@ -140,6 +140,7 @@ std::ostream &operator<<(std::ostream &out, const ChatInfo &info);
//std::ostream &operator<<(std::ostream &out, const MsgTagInfo);
//std::ostream &operator<<(std::ostream &out, const MsgTagType);
bool operator==(const ChatInfo&, const ChatInfo&);
class RsMsgs;
extern RsMsgs *rsMsgs;
@ -183,14 +184,14 @@ virtual bool resetMessageStandardTagTypes(MsgTagType& tags) = 0;
/****************************************/
/* Chat */
virtual bool sendPublicChat(std::wstring msg) = 0;
virtual bool sendPrivateChat(std::string id, std::wstring msg) = 0;
virtual bool sendPublicChat(const std::wstring& msg) = 0;
virtual bool sendPrivateChat(const std::string& id, const std::wstring& msg) = 0;
virtual int getPublicChatQueueCount() = 0;
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
virtual int getPrivateChatQueueCount(bool incoming) = 0;
virtual bool getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids) = 0;
virtual bool getPrivateChatQueue(bool incoming, std::string id, std::list<ChatInfo> &chats) = 0;
virtual bool clearPrivateChatQueue(bool incoming, std::string id) = 0;
virtual bool getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats) = 0;
virtual bool clearPrivateChatQueue(bool incoming, const std::string& id) = 0;
virtual void sendStatusString(const std::string& id,const std::string& status_string) = 0 ;
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
@ -199,7 +200,7 @@ virtual std::string getCustomStateString() = 0 ;
virtual std::string getCustomStateString(const std::string& peer_id) = 0 ;
// get avatar data for peer pid
virtual void getAvatarData(std::string pid,unsigned char *& data,int& size) = 0 ;
virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& size) = 0 ;
// set own avatar data
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;