add changing state for Send button in chat when msg size exceeds allowed size (Patch from Phenom)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7438 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-07-06 11:33:04 +00:00
parent 24ad4b8880
commit 8667cf9f92
9 changed files with 56 additions and 3 deletions

View file

@ -384,6 +384,7 @@ virtual int getPrivateChatQueueCount(bool incoming) = 0;
virtual bool getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids) = 0;
virtual bool getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats) = 0;
virtual bool clearPrivateChatQueue(bool incoming, const RsPeerId& id) = 0;
virtual int getMaxMessageSecuritySize() = 0;
virtual void sendStatusString(const RsPeerId& id,const std::string& status_string) = 0 ;
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;

View file

@ -252,6 +252,11 @@ bool p3Msgs::clearPrivateChatQueue(bool incoming, const RsPeerId& id)
return mChatSrv->clearPrivateChatQueue(incoming, id);
}
int p3Msgs::getMaxMessageSecuritySize()
{
return mChatSrv->getMaxMessageSecuritySize();
}
void p3Msgs::getOwnAvatarData(unsigned char *& data,int& size)
{
mChatSrv->getOwnAvatarJpegData(data,size) ;

View file

@ -158,6 +158,11 @@ class p3Msgs: public RsMsgs
*/
virtual bool clearPrivateChatQueue(bool incoming, const RsPeerId& id);
/*!
* Return the max message size for security forwarding
*/
virtual int getMaxMessageSecuritySize();
/*!
* sends immediate status string to a specific peer, e.g. in a private chat
* @param peer_id peer to send status string to

View file

@ -82,6 +82,7 @@ static const uint32_t MAX_AVATAR_JPEG_SIZE = 32767; // Maximum size
static const uint32_t MAX_ALLOWED_LOBBIES_IN_LIST_WARNING = 50 ;
static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number of messages from a given peer in a window for duration below
static const uint32_t MAX_MESSAGES_PER_SECONDS_PERIOD = 10 ; // duration window for max number of messages before messages get dropped.
static const uint32_t MAX_MESSAGE_SECURITY_SIZE = 6000 ; // Max message size to forward other friends
p3ChatService::p3ChatService(p3ServiceControl *sc,p3IdService *pids, p3LinkMgr *lm, p3HistoryMgr *historyMgr)
:p3Service(), p3Config(), mChatMtx("p3ChatService"), mIdService(pids),mServiceCtrl(sc), mLinkMgr(lm) , mHistoryMgr(historyMgr)
@ -1141,12 +1142,22 @@ void p3ChatService::handleRecvChatAvatarItem(RsChatAvatarItem *ca)
RsServer::notify()->notifyPeerHasNewAvatar(ca->PeerId().toStdString()) ;
}
int p3ChatService::getMaxMessageSecuritySize()
{
return MAX_MESSAGE_SECURITY_SIZE;
}
bool p3ChatService::checkForMessageSecurity(RsChatMsgItem *ci)
{
// Remove too big messages
if (ci->message.length() > 6000 && (ci->chatFlags & RS_CHAT_FLAG_LOBBY))
if (ci->message.length() > MAX_MESSAGE_SECURITY_SIZE && (ci->chatFlags & RS_CHAT_FLAG_LOBBY))
{
ci->message = "**** Security warning: Message bigger than 6000 characters, forwarded to you by ";
std::ostringstream os;
os << getMaxMessageSecuritySize();
ci->message = "**** Security warning: Message bigger than ";
ci->message += os.str();
ci->message += " characters, forwarded to you by ";
ci->message += rsPeers->getPeerName(ci->PeerId());
ci->message += ", dropped. ****";
return false;

View file

@ -160,6 +160,11 @@ class p3ChatService: public p3Service, public p3Config, public pqiServiceMonitor
*/
bool getPrivateChatQueue(bool incoming, const RsPeerId &id, std::list<ChatInfo> &chats);
/*!
* Return the max message size for security forwarding
*/
static int getMaxMessageSecuritySize();
/*!
* Checks message security, especially remove billion laughs attacks
*/