mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added list of participants in lobby, handled large messages using splitted display (cannot ensure rebuilt message yet.)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4745 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fb263f2fcc
commit
94608c8467
@ -423,7 +423,7 @@ bool p3ChatService::checkAndRebuildPartialMessage(RsChatMsgItem *ci)
|
||||
if(it != _pendingPartialMessages.end())
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Pending messahe found. Happending it." << std::endl;
|
||||
std::cerr << "Pending message found. Happending it." << std::endl;
|
||||
#endif
|
||||
// Yes, there is. Append the item to ci.
|
||||
|
||||
@ -455,52 +455,6 @@ bool p3ChatService::checkAndRebuildPartialMessage(RsChatMsgItem *ci)
|
||||
}
|
||||
}
|
||||
|
||||
void p3ChatService::checkAndRedirectMsgToLobby(RsChatMsgItem *ci)
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Checking msg..." << std::endl;
|
||||
#endif
|
||||
|
||||
if(!(ci->chatFlags & RS_CHAT_FLAG_LOBBY))
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << " normal chat!" << std::endl;
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
#ifdef CHAT_DEBUG
|
||||
else
|
||||
std::cerr << " lobby chat!" << std::endl;
|
||||
#endif
|
||||
|
||||
RsChatLobbyMsgItem *lobbyItem = dynamic_cast<RsChatLobbyMsgItem*>(ci) ;
|
||||
|
||||
if(ci == NULL)
|
||||
std::cerr << "Warning: chat message has lobby flag, but is not a chat lobby item!!" << std::endl;
|
||||
|
||||
std::string vpeer_id ;
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it = _chat_lobbys.find(lobbyItem->lobby_id) ;
|
||||
|
||||
if(it == _chat_lobbys.end())
|
||||
{
|
||||
std::cerr << "(EE) p3ChatService::checkAndRedirectMsgToLobby(): RsItem is a lobby item, but the id is not known!!" << std::endl;
|
||||
ci->PeerId(std::string()) ;
|
||||
return ;
|
||||
}
|
||||
vpeer_id = it->second.virtual_peer_id ;
|
||||
}
|
||||
|
||||
if(recvLobbyChat(lobbyItem))
|
||||
ci->PeerId(vpeer_id) ; // the peer Id is changed to the lobby id (virtual peer id).
|
||||
else
|
||||
ci->PeerId(std::string()) ; // reset the peer id to prevent display of message.
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3ChatService::receiveChatQueue()
|
||||
{
|
||||
bool publicChanged = false;
|
||||
@ -520,7 +474,18 @@ void p3ChatService::receiveChatQueue()
|
||||
{
|
||||
// check if it's a lobby msg, in which case we replace the peer id by the lobby's virtual peer id.
|
||||
//
|
||||
checkAndRedirectMsgToLobby(ci) ;
|
||||
RsChatLobbyMsgItem *cli = dynamic_cast<RsChatLobbyMsgItem*>(ci) ;
|
||||
|
||||
if(cli != NULL)
|
||||
{
|
||||
if(!recvLobbyChat(cli,cli->PeerId())) // forwards the message to friends, keeps track of subscribers, etc.
|
||||
{
|
||||
delete ci ;
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
else if(!checkAndRebuildPartialMessage(ci)) // Don't delete ! This function is not handled propoerly for chat lobby msgs, so
|
||||
continue ; // we don't use it in this case.
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::receiveChatQueue() Item:";
|
||||
@ -529,8 +494,6 @@ void p3ChatService::receiveChatQueue()
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Got msg. Flags = " << ci->chatFlags << std::endl ;
|
||||
#endif
|
||||
if(!checkAndRebuildPartialMessage(ci))
|
||||
continue ;
|
||||
|
||||
if(ci->chatFlags & RS_CHAT_FLAG_REQUESTS_AVATAR) // no msg here. Just an avatar request.
|
||||
{
|
||||
@ -1331,9 +1294,14 @@ void p3ChatService::statusChange(const std::list<pqipeer> &plist)
|
||||
|
||||
//********************** Chat Lobby Stuff ***********************//
|
||||
|
||||
bool p3ChatService::recvLobbyChat(RsChatLobbyMsgItem *item)
|
||||
// returns:
|
||||
// true: the message is not a duplicate and should be shown
|
||||
// false: the message is a duplicate or there is an error, and should be destroyed.
|
||||
//
|
||||
bool p3ChatService::recvLobbyChat(RsChatLobbyMsgItem *item,const std::string& peer_id)
|
||||
{
|
||||
bool send_challenge = false ;
|
||||
std::string lobby_virtual_peer_id ;
|
||||
ChatLobbyId send_challenge_lobby ;
|
||||
|
||||
{
|
||||
@ -1357,9 +1325,13 @@ bool p3ChatService::recvLobbyChat(RsChatLobbyMsgItem *item)
|
||||
|
||||
// Adds the peer id to the list of friend participants, even if it's not original msg source
|
||||
|
||||
lobby.participating_friends.insert(item->PeerId()) ;
|
||||
lobby.participating_friends.insert(peer_id) ;
|
||||
|
||||
if(item->nick != "Lobby management") // not nice ! We need a lobby management flag.
|
||||
lobby.nick_names.insert(item->nick) ;
|
||||
|
||||
lobby_virtual_peer_id = lobby.virtual_peer_id ;
|
||||
|
||||
// Checks wether the msg is already recorded or not
|
||||
|
||||
std::map<ChatLobbyMsgId,time_t>::const_iterator it2(lobby.msg_cache.find(item->msg_id)) ;
|
||||
@ -1378,11 +1350,11 @@ bool p3ChatService::recvLobbyChat(RsChatLobbyMsgItem *item)
|
||||
// Forward to allparticipating friends, except this peer.
|
||||
|
||||
for(std::set<std::string>::const_iterator it(lobby.participating_friends.begin());it!=lobby.participating_friends.end();++it)
|
||||
if((*it)!=item->PeerId() && mLinkMgr->isOnline(*it))
|
||||
if((*it)!=peer_id && mLinkMgr->isOnline(*it))
|
||||
{
|
||||
RsChatLobbyMsgItem *item2 = new RsChatLobbyMsgItem(*item) ; // copy almost everything
|
||||
|
||||
item2->PeerId(*it) ;
|
||||
item2->PeerId(*it) ; // replaces the virtual peer id with the actual destination.
|
||||
|
||||
sendItem(item2);
|
||||
}
|
||||
@ -1398,6 +1370,7 @@ bool p3ChatService::recvLobbyChat(RsChatLobbyMsgItem *item)
|
||||
if(send_challenge)
|
||||
sendConnectionChallenge(send_challenge_lobby) ;
|
||||
|
||||
item->PeerId(lobby_virtual_peer_id) ; // updates the peer id for proper display
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
bool checkAndRebuildPartialMessage(RsChatMsgItem*) ;
|
||||
|
||||
/// receive and handle chat lobby item
|
||||
bool recvLobbyChat(RsChatLobbyMsgItem*) ;
|
||||
bool recvLobbyChat(RsChatLobbyMsgItem*,const std::string& src_peer_id) ;
|
||||
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&,bool management = false) ;
|
||||
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
||||
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QDir>
|
||||
#include <QBuffer>
|
||||
#include <QTextCodec>
|
||||
#include <QListWidget>
|
||||
#include <QSound>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -55,6 +56,11 @@ ChatLobbyDialog::ChatLobbyDialog(const std::string& dialog_id,const ChatLobbyId&
|
||||
PopupChatDialog::updateStatus(QString::fromStdString(getPeerId()),RS_STATUS_ONLINE) ;
|
||||
|
||||
QObject::connect(this,SIGNAL(close()),this,SLOT(closeAndAsk())) ;
|
||||
|
||||
ui.avatarframe->layout()->addWidget(new QLabel(tr("Participants:"))) ;
|
||||
friendsListWidget = new QListWidget ;
|
||||
ui.avatarframe->layout()->addWidget(friendsListWidget) ;
|
||||
ui.avatarframe->layout()->addItem(new QSpacerItem(12, 335, QSizePolicy::Minimum, QSizePolicy::Expanding)) ;
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
@ -74,7 +80,6 @@ void ChatLobbyDialog::setNickName(const QString& nick)
|
||||
void ChatLobbyDialog::updateStatus(const QString &peer_id, int status)
|
||||
{
|
||||
// For now. We need something more efficient to tell when the lobby is disconnected.
|
||||
//
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
||||
@ -85,5 +90,31 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
||||
QString name = QString::fromUtf8(info.peer_nickname.c_str()) ;
|
||||
|
||||
addChatMsg(true, name, sendTime, recvTime, message, TYPE_NORMAL);
|
||||
|
||||
// also update peer list.
|
||||
|
||||
static time_t last = 0 ;
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
if(now > last)
|
||||
{
|
||||
last = now ;
|
||||
updateFriendsList() ;
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::updateFriendsList()
|
||||
{
|
||||
friendsListWidget->clear() ;
|
||||
|
||||
std::list<ChatLobbyInfo> linfos ;
|
||||
rsMsgs->getChatLobbyList(linfos);
|
||||
|
||||
std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());
|
||||
for(;it!=linfos.end() && (*it).lobby_id != lobby_id;++it) ;
|
||||
|
||||
if(it!=linfos.end())
|
||||
for(std::set<std::string>::const_iterator it2( (*it).nick_names.begin());it2!=(*it).nick_names.end();++it2)
|
||||
friendsListWidget->addItem(QString::fromUtf8((*it2).c_str())) ;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ class QTextEdit;
|
||||
class QTextCharFormat;
|
||||
class AttachFileItem;
|
||||
class ChatInfo;
|
||||
class QListWidget ;
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include "ChatStyle.h"
|
||||
@ -61,7 +62,10 @@ class ChatLobbyDialog: public PopupChatDialog
|
||||
void setNickName(const QString&) ;
|
||||
|
||||
private:
|
||||
void updateFriendsList() ;
|
||||
|
||||
ChatLobbyId lobby_id ;
|
||||
QListWidget *friendsListWidget ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -158,7 +158,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer>
|
||||
<spacer name="myspacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
@ -753,8 +753,8 @@ background: white;}</string>
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"></p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
|
Loading…
Reference in New Issue
Block a user