mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-08 22:32:34 -04:00
Splitted queue of chat messages in chat service into public and private queue.
Reworked the interface of the chat service. So full recomile is needed. With disabled flags for private chat (RS_CHAT_OPEN_NEW and RS_CHAT_REOPEN), the incoming private chat messages are queued (only for the runtime) until the user shows the private chat dialog. When a new chat message is available, the icon of the gpg and ssl contact changed in MessengerWindow and PeersDialog and a new tray icon is shown. Fixed compiler warning. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3421 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7dd99a0c35
commit
7f837e9778
17 changed files with 597 additions and 329 deletions
|
@ -227,7 +227,8 @@ const int NOTIFY_LIST_DIRLIST_LOCAL = 9;
|
|||
const int NOTIFY_LIST_DIRLIST_FRIENDS = 10;
|
||||
const int NOTIFY_LIST_FORUMLIST_LOCKED = 11; // use connect with Qt::QueuedConnection
|
||||
const int NOTIFY_LIST_MESSAGE_TAGS = 12;
|
||||
const int NOTIFY_LIST_CHAT = 13;
|
||||
const int NOTIFY_LIST_PUBLIC_CHAT = 13;
|
||||
const int NOTIFY_LIST_PRIVATE_CHAT = 14;
|
||||
|
||||
const int NOTIFY_TYPE_SAME = 0x01;
|
||||
const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */
|
||||
|
|
|
@ -174,8 +174,12 @@ virtual bool resetMessageStandardTagTypes(MsgTagType& tags) = 0;
|
|||
|
||||
/****************************************/
|
||||
/* Chat */
|
||||
virtual bool ChatSend(ChatInfo &ci) = 0;
|
||||
virtual bool getNewChat(std::list<ChatInfo> &chats) = 0;
|
||||
virtual bool sendPublicChat(std::wstring msg) = 0;
|
||||
virtual bool sendPrivateChat(std::string id, std::wstring msg) = 0;
|
||||
virtual int getChatQueueCount(bool privateQueue) = 0;
|
||||
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
|
||||
virtual bool getPrivateChatQueueIds(std::list<std::string> &ids) = 0;
|
||||
virtual bool getPrivateChatQueue(std::string id, std::list<ChatInfo> &chats) = 0;
|
||||
virtual void sendStatusString(const std::string& id,const std::string& status_string) = 0 ;
|
||||
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
|
||||
|
||||
|
|
|
@ -135,19 +135,16 @@ bool p3Msgs::resetMessageStandardTagTypes(MsgTagType& tags)
|
|||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
bool p3Msgs::ChatSend(ChatInfo &ci)
|
||||
bool p3Msgs::sendPublicChat(std::wstring msg)
|
||||
{
|
||||
/* send a message to all for now */
|
||||
if (ci.chatflags & RS_CHAT_PRIVATE)
|
||||
{
|
||||
mChatSrv -> sendPrivateChat(ci.msg, ci.rsid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* global */
|
||||
mChatSrv -> sendChat(ci.msg);
|
||||
}
|
||||
return true;
|
||||
return mChatSrv -> sendPublicChat(msg);
|
||||
}
|
||||
|
||||
bool p3Msgs::sendPrivateChat(std::string id, std::wstring msg)
|
||||
{
|
||||
/* send a message to peer */
|
||||
return mChatSrv -> sendPrivateChat(id, msg);
|
||||
}
|
||||
|
||||
void p3Msgs::sendGroupChatStatusString(const std::string& status_string)
|
||||
|
@ -159,9 +156,24 @@ void p3Msgs::sendStatusString(const std::string& peer_id,const std::string& stat
|
|||
mChatSrv->sendStatusString(peer_id,status_string);
|
||||
}
|
||||
|
||||
bool p3Msgs::getNewChat(std::list<ChatInfo> &chats)
|
||||
int p3Msgs::getChatQueueCount(bool privateQueue)
|
||||
{
|
||||
return mChatSrv->getChatQueue(chats);
|
||||
return mChatSrv->getChatQueueCount(privateQueue);
|
||||
}
|
||||
|
||||
bool p3Msgs::getPublicChatQueue(std::list<ChatInfo> &chats)
|
||||
{
|
||||
return mChatSrv->getPublicChatQueue(chats);
|
||||
}
|
||||
|
||||
bool p3Msgs::getPrivateChatQueueIds(std::list<std::string> &ids)
|
||||
{
|
||||
return mChatSrv->getPrivateChatQueueIds(ids);
|
||||
}
|
||||
|
||||
bool p3Msgs::getPrivateChatQueue(std::string id, std::list<ChatInfo> &chats)
|
||||
{
|
||||
return mChatSrv->getPrivateChatQueue(id, chats);
|
||||
}
|
||||
|
||||
void p3Msgs::getOwnAvatarData(unsigned char *& data,int& size)
|
||||
|
|
|
@ -104,19 +104,38 @@ class p3Msgs: public RsMsgs
|
|||
virtual std::string getCustomStateString(const std::string& peer_id) ;
|
||||
|
||||
|
||||
/****************************************/
|
||||
/* Chat */
|
||||
/*!
|
||||
* sends chat (public and private)
|
||||
* @param ci chat info
|
||||
* public chat sent to all peers
|
||||
*/
|
||||
virtual bool ChatSend(ChatInfo &ci);
|
||||
virtual bool sendPublicChat(std::wstring msg);
|
||||
|
||||
/*!
|
||||
* @param chats ref to list of received chats is stored here
|
||||
* chat is sent to specifc peer
|
||||
* @param id peer to send chat msg to
|
||||
*/
|
||||
virtual bool getNewChat(std::list<ChatInfo> &chats);
|
||||
virtual bool sendPrivateChat(std::string id, std::wstring msg);
|
||||
|
||||
/*!
|
||||
* returns the count of messages in public or private queue
|
||||
* @param public or private queue
|
||||
*/
|
||||
virtual int getChatQueueCount(bool privateQueue);
|
||||
|
||||
/*!
|
||||
* @param chats ref to list of received public chats is stored here
|
||||
*/
|
||||
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats);
|
||||
|
||||
/*!
|
||||
* @param id's of available private chat messages
|
||||
*/
|
||||
virtual bool getPrivateChatQueueIds(std::list<std::string> &ids);
|
||||
|
||||
|
||||
/*!
|
||||
* @param chats ref to list of received private chats is stored here
|
||||
*/
|
||||
virtual bool getPrivateChatQueue(std::string id, std::list<ChatInfo> &chats);
|
||||
/*!
|
||||
* sends immediate status string to a specific peer, e.g. in a private chat
|
||||
* @param peer_id peer to send status string to
|
||||
|
|
|
@ -66,7 +66,7 @@ int p3ChatService::status()
|
|||
|
||||
/***************** Chat Stuff **********************/
|
||||
|
||||
int p3ChatService::sendChat(std::wstring msg)
|
||||
int p3ChatService::sendPublicChat(std::wstring &msg)
|
||||
{
|
||||
/* go through all the peers */
|
||||
|
||||
|
@ -203,7 +203,7 @@ void p3ChatService::sendStatusString( const std::string& id , const std::string&
|
|||
sendItem(cs);
|
||||
}
|
||||
|
||||
int p3ChatService::sendPrivateChat( std::wstring msg, std::string id)
|
||||
int p3ChatService::sendPrivateChat(std::string &id, std::wstring &msg)
|
||||
{
|
||||
// make chat item....
|
||||
#ifdef CHAT_DEBUG
|
||||
|
@ -283,7 +283,8 @@ int p3ChatService::sendPrivateChat( std::wstring msg, std::string id)
|
|||
|
||||
void p3ChatService::receiveChatQueue()
|
||||
{
|
||||
bool changed = false;
|
||||
bool publicChanged = false;
|
||||
bool privateChanged = false;
|
||||
|
||||
time_t now = time(NULL);
|
||||
RsItem *item ;
|
||||
|
@ -334,6 +335,7 @@ void p3ChatService::receiveChatQueue()
|
|||
}
|
||||
|
||||
if ((ci->chatFlags & RS_CHAT_FLAG_PRIVATE) == 0) {
|
||||
/* notify public chat message */
|
||||
std::string message;
|
||||
message.assign(ci->message.begin(), ci->message.end());
|
||||
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_CHAT_NEW, ci->PeerId(), message, "");
|
||||
|
@ -343,10 +345,15 @@ void p3ChatService::receiveChatQueue()
|
|||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
ci->recvTime = now;
|
||||
ilist.push_back(ci); // don't delete the item !!
|
||||
} /* UNLOCK */
|
||||
|
||||
changed = true;
|
||||
if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) {
|
||||
privateChanged = true;
|
||||
privateList.push_back(ci); // don't delete the item !!
|
||||
} else {
|
||||
publicChanged = true;
|
||||
publicList.push_back(ci); // don't delete the item !!
|
||||
}
|
||||
} /* UNLOCK */
|
||||
}
|
||||
|
||||
continue ;
|
||||
|
@ -402,35 +409,121 @@ void p3ChatService::receiveChatQueue()
|
|||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT, NOTIFY_TYPE_ADD);
|
||||
if (publicChanged) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PUBLIC_CHAT, NOTIFY_TYPE_ADD);
|
||||
}
|
||||
if (privateChanged) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PRIVATE_CHAT, NOTIFY_TYPE_ADD);
|
||||
}
|
||||
}
|
||||
|
||||
bool p3ChatService::getChatQueue(std::list<ChatInfo> &chats)
|
||||
int p3ChatService::getChatQueueCount(bool privateQueue)
|
||||
{
|
||||
/* get any messages and push them to iface */
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
if (privateQueue) {
|
||||
return privateList.size();
|
||||
}
|
||||
|
||||
return publicList.size();
|
||||
}
|
||||
|
||||
bool p3ChatService::getPublicChatQueue(std::list<ChatInfo> &chats)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// get the items from the public list.
|
||||
if (publicList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<RsChatMsgItem *>::iterator it;
|
||||
while (publicList.size()) {
|
||||
RsChatMsgItem *c = publicList.front();
|
||||
publicList.pop_front();
|
||||
|
||||
ChatInfo ci;
|
||||
initRsChatInfo(c, ci);
|
||||
chats.push_back(ci);
|
||||
|
||||
changed = true;
|
||||
|
||||
delete c;
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
if (changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PUBLIC_CHAT, NOTIFY_TYPE_DEL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3ChatService::getPrivateChatQueueIds(std::list<std::string> &ids)
|
||||
{
|
||||
ids.clear();
|
||||
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// get the items from the list.
|
||||
if (ilist.size() == 0)
|
||||
{
|
||||
// get the items from the private list.
|
||||
if (privateList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<RsChatMsgItem *>::iterator it;
|
||||
while (ilist.size())
|
||||
{
|
||||
RsChatMsgItem *c = ilist.front();
|
||||
ilist.pop_front();
|
||||
for (it = privateList.begin(); it != privateList.end(); it++) {
|
||||
RsChatMsgItem *c = *it;
|
||||
|
||||
ChatInfo ci;
|
||||
initRsChatInfo(c, ci);
|
||||
chats.push_back(ci);
|
||||
|
||||
delete c;
|
||||
if (std::find(ids.begin(), ids.end(), c->PeerId()) == ids.end()) {
|
||||
ids.push_back(c->PeerId());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3ChatService::getPrivateChatQueue(std::string id, std::list<ChatInfo> &chats)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// get the items from the private list.
|
||||
if (privateList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::list<RsChatMsgItem *>::iterator it = privateList.begin();
|
||||
while (it != privateList.end()) {
|
||||
RsChatMsgItem *c = *it;
|
||||
|
||||
if (c->PeerId() == id) {
|
||||
ChatInfo ci;
|
||||
initRsChatInfo(c, ci);
|
||||
chats.push_back(ci);
|
||||
|
||||
changed = true;
|
||||
|
||||
delete c;
|
||||
|
||||
std::list<RsChatMsgItem *>::iterator it1 = it;
|
||||
it++;
|
||||
privateList.erase(it1);
|
||||
continue;
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
if (changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PRIVATE_CHAT, NOTIFY_TYPE_DEL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,13 +61,13 @@ class p3ChatService: public p3Service, public p3Config
|
|||
/*!
|
||||
* public chat sent to all peers
|
||||
*/
|
||||
int sendChat(std::wstring msg);
|
||||
int sendPublicChat(std::wstring &msg);
|
||||
|
||||
/*!
|
||||
* chat is sent to specifc peer
|
||||
* @param id peer to send caht msg to
|
||||
* @param id peer to send chat msg to
|
||||
*/
|
||||
int sendPrivateChat(std::wstring msg, std::string id);
|
||||
int sendPrivateChat(std::string &id, 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)
|
||||
|
@ -117,9 +117,25 @@ class p3ChatService: public p3Service, public p3Config
|
|||
|
||||
|
||||
/*!
|
||||
* This retrieves all chat msg items
|
||||
* returns the count of messages in public or private queue
|
||||
* @param public or private queue
|
||||
*/
|
||||
bool getChatQueue(std::list<ChatInfo> &chats);
|
||||
int getChatQueueCount(bool privateQueue);
|
||||
|
||||
/*!
|
||||
* This retrieves all public chat msg items
|
||||
*/
|
||||
bool getPublicChatQueue(std::list<ChatInfo> &chats);
|
||||
|
||||
/*!
|
||||
* @param id's of available private chat messages
|
||||
*/
|
||||
bool getPrivateChatQueueIds(std::list<std::string> &ids);
|
||||
|
||||
/*!
|
||||
* This retrieves all private chat msg items for peer
|
||||
*/
|
||||
bool getPrivateChatQueue(std::string id, std::list<ChatInfo> &chats);
|
||||
|
||||
/************* from p3Config *******************/
|
||||
virtual RsSerialiser *setupSerialiser() ;
|
||||
|
@ -163,7 +179,8 @@ class p3ChatService: public p3Service, public p3Config
|
|||
|
||||
p3ConnectMgr *mConnMgr;
|
||||
|
||||
std::list<RsChatMsgItem *> ilist;
|
||||
std::list<RsChatMsgItem *> publicList;
|
||||
std::list<RsChatMsgItem *> privateList;
|
||||
|
||||
AvatarInfo *_own_avatar ;
|
||||
std::map<std::string,AvatarInfo *> _avatars ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue