mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
debugged basic chat lobby communication
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-ChatLobby@4708 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
46f1e2b562
commit
a0e3522273
@ -134,6 +134,7 @@ class ChatInfo
|
||||
{
|
||||
public:
|
||||
std::string rsid;
|
||||
std::string peer_nickname;
|
||||
unsigned int chatflags;
|
||||
uint32_t sendTime;
|
||||
uint32_t recvTime;
|
||||
@ -206,7 +207,6 @@ virtual bool resetMessageStandardTagTypes(MsgTagType& tags) = 0;
|
||||
/****************************************/
|
||||
/* Chat */
|
||||
virtual bool sendPublicChat(const std::wstring& msg) = 0;
|
||||
virtual bool sendLobbyChat(const std::wstring& msg,const ChatLobbyId& lid) = 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;
|
||||
@ -228,6 +228,7 @@ virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& siz
|
||||
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
|
||||
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
|
||||
|
||||
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) = 0;
|
||||
virtual void getChatLobbyList(std::list<ChatLobbyInfo>& cl_info) = 0;
|
||||
virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const std::string& peer_id) = 0;
|
||||
virtual bool acceptLobbyInvite(const ChatLobbyId& id) = 0 ;
|
||||
|
@ -260,10 +260,11 @@ void p3Msgs::setCustomStateString(const std::string& state_string)
|
||||
mChatSrv->setOwnCustomStateString(state_string) ;
|
||||
}
|
||||
|
||||
bool p3Msgs::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& id)
|
||||
bool p3Msgs::isLobbyId(const std::string& peer_id,ChatLobbyId& id)
|
||||
{
|
||||
return mChatSrv->sendLobbyChat(msg,id) ;
|
||||
return mChatSrv->isLobbyId(peer_id,id) ;
|
||||
}
|
||||
|
||||
void p3Msgs::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
|
||||
{
|
||||
mChatSrv->getChatLobbyList(linfos) ;
|
||||
|
@ -167,7 +167,8 @@ class p3Msgs: public RsMsgs
|
||||
|
||||
/****************************************/
|
||||
|
||||
virtual bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
|
||||
|
||||
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) ;
|
||||
virtual void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
|
||||
virtual void invitePeerToLobby(const ChatLobbyId&, const std::string&) ;
|
||||
virtual bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
||||
|
@ -97,6 +97,8 @@ class RsChatMsgItem: public RsChatItem
|
||||
virtual void clear() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual RsChatMsgItem *duplicate() const { return new RsChatMsgItem(*this) ; }
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
|
||||
@ -116,6 +118,7 @@ class RsChatLobbyMsgItem: public RsChatMsgItem
|
||||
|
||||
virtual ~RsChatLobbyMsgItem() {}
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual RsChatMsgItem *duplicate() const { return new RsChatLobbyMsgItem(*this) ; }
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) ; // Isn't it better that items can serialize themselves ?
|
||||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
|
@ -208,7 +208,7 @@ void p3ChatService::checkSizeAndSendMessage(RsChatMsgItem *msg)
|
||||
{
|
||||
// chop off the first 15000 wchars
|
||||
|
||||
RsChatMsgItem *item = new RsChatMsgItem(*msg) ;
|
||||
RsChatMsgItem *item = msg->duplicate() ;
|
||||
|
||||
item->message = item->message.substr(0,MAX_STRING_SIZE) ;
|
||||
msg->message = msg->message.substr(MAX_STRING_SIZE,msg->message.size()-MAX_STRING_SIZE) ;
|
||||
@ -216,7 +216,7 @@ void p3ChatService::checkSizeAndSendMessage(RsChatMsgItem *msg)
|
||||
// Clear out any one time flags that should not be copied into multiple objects. This is
|
||||
// a precaution, in case the receivign peer does not yet handle split messages transparently.
|
||||
//
|
||||
item->chatFlags &= (RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_PUBLIC) ;
|
||||
item->chatFlags &= (RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_PUBLIC | RS_CHAT_FLAG_LOBBY) ;
|
||||
|
||||
// Indicate that the message is to be continued.
|
||||
//
|
||||
@ -226,8 +226,63 @@ void p3ChatService::checkSizeAndSendMessage(RsChatMsgItem *msg)
|
||||
sendItem(msg) ;
|
||||
}
|
||||
|
||||
void p3ChatService::locked_printDebugInfo() const
|
||||
{
|
||||
std::cerr << "Recorded lobbies: " << std::endl;
|
||||
|
||||
for( std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin()) ;it!=_chat_lobbys.end();++it)
|
||||
{
|
||||
std::cerr << " Lobby id\t: " << it->first << std::endl;
|
||||
std::cerr << " Lobby name\t: " << it->second.lobby_name << std::endl;
|
||||
std::cerr << " nick name\t: " << it->second.nick_name << std::endl;
|
||||
std::cerr << " Lobby peer id\t: " << it->second.virtual_peer_id << std::endl;
|
||||
std::cerr << " Participating friends: " << std::endl;
|
||||
|
||||
for(std::set<std::string>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
||||
std::cerr << " " << *it2 << std::endl;
|
||||
|
||||
std::cerr << " Participating nick names: " << std::endl;
|
||||
|
||||
for(std::set<std::string>::const_iterator it2(it->second.nick_names.begin());it2!=it->second.nick_names.end();++it2)
|
||||
std::cerr << " " << *it2 << std::endl;
|
||||
|
||||
}
|
||||
|
||||
std::cerr << "Recorded lobby names: " << std::endl;
|
||||
|
||||
for( std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.begin()) ;it!=_lobby_ids.end();++it)
|
||||
std::cerr << " \"" << it->first << "\" id = " << it->second << std::endl;
|
||||
}
|
||||
|
||||
bool p3ChatService::isLobbyId(const std::string& id,ChatLobbyId& lobby_id)
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
locked_printDebugInfo() ; // debug
|
||||
|
||||
for( std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.begin()) ;it!=_lobby_ids.end();++it)
|
||||
std::cerr << "Testing \"" << id << "\" against \"" << it->first << "\" result=" << (it->first == id) << std::endl;
|
||||
|
||||
std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.find(id)) ;
|
||||
|
||||
if(it != _lobby_ids.end())
|
||||
{
|
||||
lobby_id = it->second ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
bool p3ChatService::sendPrivateChat(const std::string &id, const std::wstring &msg)
|
||||
{
|
||||
// look into ID. Is it a peer, or a chat lobby?
|
||||
|
||||
ChatLobbyId lobby_id ;
|
||||
|
||||
if(isLobbyId(id,lobby_id))
|
||||
return sendLobbyChat(msg,lobby_id) ;
|
||||
|
||||
// make chat item....
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendPrivateChat()";
|
||||
@ -364,6 +419,42 @@ bool p3ChatService::checkAndRebuildPartialMessage(RsChatMsgItem *ci)
|
||||
}
|
||||
}
|
||||
|
||||
void p3ChatService::checkAndRedirectMsgToLobby(RsChatMsgItem *ci)
|
||||
{
|
||||
std::cerr << "Checking msg..." << std::endl;
|
||||
|
||||
if(!(ci->chatFlags & RS_CHAT_FLAG_LOBBY))
|
||||
{
|
||||
std::cerr << " normal chat!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
else
|
||||
std::cerr << " lobby chat!" << std::endl;
|
||||
|
||||
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;
|
||||
return ;
|
||||
}
|
||||
vpeer_id = it->second.virtual_peer_id ;
|
||||
}
|
||||
|
||||
recvLobbyChat(lobbyItem) ; // needs the proper peerId
|
||||
ci->PeerId(vpeer_id) ; // thenthe peer Id is changed to the lobby id (virtual peer id).
|
||||
}
|
||||
|
||||
|
||||
|
||||
void p3ChatService::receiveChatQueue()
|
||||
{
|
||||
@ -382,6 +473,10 @@ void p3ChatService::receiveChatQueue()
|
||||
|
||||
if(ci != NULL) // real chat message
|
||||
{
|
||||
// check if it's a lobby msg, in which case we replace the peer id by the lobby's virtual peer id.
|
||||
//
|
||||
checkAndRedirectMsgToLobby(ci) ;
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::receiveChatQueue() Item:";
|
||||
std::cerr << std::endl;
|
||||
@ -434,9 +529,11 @@ void p3ChatService::receiveChatQueue()
|
||||
ci->recvTime = now;
|
||||
|
||||
if (ci->chatFlags & RS_CHAT_FLAG_PRIVATE) {
|
||||
std::cerr << "Adding msg 0x" << std::hex << (void*)ci << std::dec << " to private chat incoming list." << std::endl;
|
||||
privateChanged = true;
|
||||
privateIncomingList.push_back(ci); // don't delete the item !!
|
||||
} else {
|
||||
std::cerr << "Adding msg 0x" << std::hex << (void*)ci << std::dec << " to public chat incoming list." << std::endl;
|
||||
publicChanged = true;
|
||||
publicList.push_back(ci); // don't delete the item !!
|
||||
|
||||
@ -447,6 +544,7 @@ void p3ChatService::receiveChatQueue()
|
||||
}
|
||||
} /* UNLOCK */
|
||||
}
|
||||
continue ;
|
||||
}
|
||||
|
||||
RsChatStatusItem *cs = dynamic_cast<RsChatStatusItem*>(item) ;
|
||||
@ -508,7 +606,6 @@ void p3ChatService::receiveChatQueue()
|
||||
|
||||
std::cerr << "Received ChatItem of unhandled type: " << std::endl;
|
||||
item->print(std::cerr,0) ;
|
||||
delete item ;
|
||||
}
|
||||
|
||||
if (publicChanged) {
|
||||
@ -695,16 +792,15 @@ void p3ChatService::initRsChatInfo(RsChatMsgItem *c, ChatInfo &i)
|
||||
i.recvTime = c->recvTime;
|
||||
i.msg = c->message;
|
||||
|
||||
RsChatLobbyMsgItem *lobbyItem = dynamic_cast<RsChatLobbyMsgItem*>(c) ;
|
||||
|
||||
if(lobbyItem != NULL)
|
||||
i.peer_nickname = lobbyItem->nick;
|
||||
|
||||
if (c -> chatFlags & RS_CHAT_FLAG_PRIVATE)
|
||||
{
|
||||
i.chatflags |= RS_CHAT_PRIVATE;
|
||||
//std::cerr << "RsServer::initRsChatInfo() Chat Private!!!";
|
||||
}
|
||||
else
|
||||
{
|
||||
i.chatflags |= RS_CHAT_PUBLIC;
|
||||
//std::cerr << "RsServer::initRsChatInfo() Chat Public!!!";
|
||||
}
|
||||
}
|
||||
|
||||
void p3ChatService::setOwnCustomStateString(const std::string& s)
|
||||
@ -1231,7 +1327,7 @@ bool p3ChatService::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& lo
|
||||
|
||||
// chat msg stuff
|
||||
//
|
||||
item.chatFlags = RS_CHAT_FLAG_LOBBY;
|
||||
item.chatFlags = RS_CHAT_FLAG_LOBBY | RS_CHAT_FLAG_PRIVATE;
|
||||
item.sendTime = time(NULL);
|
||||
item.recvTime = item.sendTime;
|
||||
item.message = msg;
|
||||
@ -1327,40 +1423,69 @@ void p3ChatService::getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invit
|
||||
|
||||
bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::cerr << "Accepting chat lobby "<< lobby_id << std::endl;
|
||||
|
||||
std::map<ChatLobbyId,ChatLobbyInvite>::iterator it = _lobby_invites_queue.find(lobby_id) ;
|
||||
|
||||
if(it == _lobby_invites_queue.end())
|
||||
{
|
||||
std::cerr << " (EE) lobby invite not in cache!!" << std::endl;
|
||||
return false;
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::cerr << "Accepting chat lobby "<< lobby_id << std::endl;
|
||||
|
||||
std::map<ChatLobbyId,ChatLobbyInvite>::iterator it = _lobby_invites_queue.find(lobby_id) ;
|
||||
|
||||
if(it == _lobby_invites_queue.end())
|
||||
{
|
||||
std::cerr << " (EE) lobby invite not in cache!!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_chat_lobbys.find(lobby_id) != _chat_lobbys.end())
|
||||
{
|
||||
std::cerr << " (II) Lobby already exists. Weird." << std::endl;
|
||||
return true ;
|
||||
}
|
||||
|
||||
std::cerr << " Creating new Lobby entry." << std::endl;
|
||||
|
||||
ChatLobbyEntry entry ;
|
||||
entry.participating_friends.insert(it->second.peer_id) ;
|
||||
entry.nick_name = mLinkMgr->getOwnId() ; // to be changed. For debug only!!
|
||||
entry.lobby_id = lobby_id ;
|
||||
entry.lobby_name = it->second.lobby_name ;
|
||||
entry.virtual_peer_id = makeVirtualPeerId(lobby_id) ;
|
||||
|
||||
_lobby_ids[entry.virtual_peer_id] = lobby_id ;
|
||||
_chat_lobbys[lobby_id] = entry ;
|
||||
|
||||
_lobby_invites_queue.erase(it) ; // remove the invite from cache.
|
||||
|
||||
// we should also send a message to the lobby to tell we're here.
|
||||
|
||||
std::cerr << " Pushing new msg item to incoming msgs." << std::endl;
|
||||
|
||||
RsChatLobbyMsgItem *item = new RsChatLobbyMsgItem;
|
||||
item->lobby_id = entry.lobby_id ;
|
||||
item->msg_id = 0 ;
|
||||
item->nick = "" ;
|
||||
item->message = std::wstring(L"Welcome to chat lobby") ;
|
||||
item->PeerId(entry.virtual_peer_id) ;
|
||||
item->chatFlags = RS_CHAT_FLAG_PRIVATE | RS_CHAT_FLAG_LOBBY ;
|
||||
|
||||
privateIncomingList.push_back(item) ;
|
||||
}
|
||||
std::cerr << " Notifying of new recvd msg." << std::endl ;
|
||||
|
||||
if(_chat_lobbys.find(lobby_id) != _chat_lobbys.end())
|
||||
{
|
||||
std::cerr << " (II) Lobby already exists. Weird." << std::endl;
|
||||
return true ;
|
||||
}
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PRIVATE_INCOMING_CHAT, NOTIFY_TYPE_ADD);
|
||||
|
||||
std::cerr << " Creating new Lobby entry." << std::endl;
|
||||
|
||||
ChatLobbyEntry entry ;
|
||||
entry.participating_friends.insert(it->second.peer_id) ;
|
||||
entry.nick_name = mLinkMgr->getOwnId() ; // to be changed. For debug only!!
|
||||
entry.lobby_id = lobby_id ;
|
||||
entry.lobby_name = it->second.lobby_name ;
|
||||
|
||||
_chat_lobbys[lobby_id] = entry ;
|
||||
|
||||
_lobby_invites_queue.erase(it) ; // remove the invite from cache.
|
||||
|
||||
// we should also send a message to the lobby to tell we're here.
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
std::string p3ChatService::makeVirtualPeerId(ChatLobbyId lobby_id)
|
||||
{
|
||||
std::ostringstream os ;
|
||||
os << "Chat Lobby 0x" << std::hex << lobby_id << std::dec ;
|
||||
|
||||
return os.str() ;
|
||||
}
|
||||
|
||||
|
||||
void p3ChatService::denyLobbyInvite(const ChatLobbyId& lobby_id)
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
@ -1395,7 +1520,9 @@ ChatLobbyId p3ChatService::createChatLobby(const std::string& lobby_name,const s
|
||||
entry.nick_name = mLinkMgr->getOwnId() ; // to be changed. For debug only!!
|
||||
entry.lobby_id = lobby_id ;
|
||||
entry.lobby_name = lobby_name ;
|
||||
entry.virtual_peer_id = makeVirtualPeerId(lobby_id) ;
|
||||
|
||||
_lobby_ids[entry.virtual_peer_id] = lobby_id ;
|
||||
_chat_lobbys[lobby_id] = entry ;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
*/
|
||||
bool clearPrivateChatQueue(bool incoming, const std::string &id);
|
||||
|
||||
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
|
||||
bool isLobbyId(const std::string&, ChatLobbyId&) ;
|
||||
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
|
||||
bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
||||
void denyLobbyInvite(const ChatLobbyId& id) ;
|
||||
@ -211,7 +211,11 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
|
||||
/// receive and handle chat lobby item
|
||||
bool recvLobbyChat(RsChatLobbyMsgItem*) ;
|
||||
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
|
||||
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
||||
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
||||
static std::string makeVirtualPeerId(ChatLobbyId) ;
|
||||
void locked_printDebugInfo() const ;
|
||||
|
||||
RsChatAvatarItem *makeOwnAvatarItem() ;
|
||||
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
||||
@ -235,6 +239,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
public:
|
||||
std::map<ChatLobbyMsgId,time_t> msg_cache ;
|
||||
std::map<std::string,time_t> invitations_sent ;
|
||||
std::string virtual_peer_id ;
|
||||
|
||||
static const time_t MAX_KEEP_MSG_RECORD = 240 ; // keep msg record for 240 secs max.
|
||||
void cleanCache() ;
|
||||
@ -242,6 +247,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
|
||||
std::map<ChatLobbyId,ChatLobbyEntry> _chat_lobbys ;
|
||||
std::map<ChatLobbyId,ChatLobbyInvite> _lobby_invites_queue ;
|
||||
std::map<std::string,ChatLobbyId> _lobby_ids ;
|
||||
};
|
||||
|
||||
class p3ChatService::StateStringInfo
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsstatus.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
@ -45,12 +46,13 @@
|
||||
#include "ChatLobbyDialog.h"
|
||||
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, const QString &name, QWidget *parent, Qt::WFlags flags)
|
||||
: PopupChatDialog(("Chat lobby 0x"+QString::number(lobby_id,16)).toStdString(),name,parent,flags),lobby_id(lid)
|
||||
ChatLobbyDialog::ChatLobbyDialog(const std::string& dialog_id,const ChatLobbyId& lid, const QString &name, QWidget *parent, Qt::WFlags flags)
|
||||
: PopupChatDialog(dialog_id,name,parent,flags),lobby_id(lid)
|
||||
{
|
||||
// remove the avatar widget. Replace it with a friends list.
|
||||
|
||||
ui.avatarWidget->hide() ;
|
||||
PopupChatDialog::updateStatus(QString::fromStdString(getPeerId()),RS_STATUS_ONLINE) ;
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
@ -66,8 +68,9 @@ void ChatLobbyDialog::setNickName(const QString& nick)
|
||||
rsMsgs->setNickNameForChatLobby(lobby_id,nick.toStdString()) ;
|
||||
}
|
||||
|
||||
bool ChatLobbyDialog::sendPrivateChat(const std::wstring& msg)
|
||||
void ChatLobbyDialog::updateStatus(const QString &peer_id, int status)
|
||||
{
|
||||
return rsMsgs->sendLobbyChat(msg,lobby_id) ;
|
||||
// For now. We need something more efficient to tell when the lobby is disconnected.
|
||||
//
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class ChatLobbyDialog: public PopupChatDialog
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog(const ChatLobbyId& lobbyid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
ChatLobbyDialog(const std::string& id,const ChatLobbyId& lid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
/** Default destructor */
|
||||
virtual ~ChatLobbyDialog();
|
||||
@ -50,7 +50,11 @@ class ChatLobbyDialog: public PopupChatDialog
|
||||
// virtual void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType);
|
||||
// virtual void sendChat();
|
||||
|
||||
virtual bool sendPrivateChat(const std::wstring& msg) ; // derived to send chat to the chat lobby
|
||||
friend class PopupChatDialog ;
|
||||
|
||||
// The following methods are differentfrom those of the parent:
|
||||
//
|
||||
virtual void updateStatus(const QString &peer_id, int status) ; // needs grouped status. Not yet implemented.
|
||||
|
||||
protected slots:
|
||||
void setNickName(const QString&) ;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "PopupChatDialog.h"
|
||||
#include "ChatLobbyDialog.h"
|
||||
#include "PopupChatWindow.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "util/misc.h"
|
||||
@ -129,7 +130,7 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
||||
connect(ui.actionSave_Chat_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
|
||||
connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages()));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus_slot(const QString&, int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
|
||||
|
||||
connect(ui.chattextEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
|
||||
@ -263,13 +264,25 @@ void PopupChatDialog::processSettings(bool bLoad)
|
||||
{
|
||||
/* see if it exists already */
|
||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||
|
||||
if (popupchatdialog == NULL) {
|
||||
if (chatflags & RS_CHAT_OPEN) {
|
||||
RsPeerDetails sslDetails;
|
||||
if (rsPeers->getPeerDetails(id, sslDetails)) {
|
||||
ChatLobbyId lobby_id ;
|
||||
|
||||
if (rsPeers->getPeerDetails(id, sslDetails))
|
||||
{
|
||||
popupchatdialog = new PopupChatDialog(id, PeerDefs::nameWithLocation(sslDetails));
|
||||
chatDialogs[id] = popupchatdialog;
|
||||
|
||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||
window->addDialog(popupchatdialog);
|
||||
}
|
||||
else if (rsMsgs->isLobbyId(id, lobby_id))
|
||||
{
|
||||
popupchatdialog = new ChatLobbyDialog(id,lobby_id,QString::fromStdString(id));
|
||||
chatDialogs[id] = popupchatdialog;
|
||||
|
||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||
window->addDialog(popupchatdialog);
|
||||
}
|
||||
@ -1055,6 +1068,11 @@ void PopupChatDialog::clearOfflineMessages()
|
||||
manualDelete = false;
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateStatus_slot(const QString &peer_id, int status)
|
||||
{
|
||||
updateStatus(peer_id,status) ;
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
{
|
||||
std::string stdPeerId = peer_id.toStdString();
|
||||
|
@ -59,9 +59,10 @@ public:
|
||||
void activate();
|
||||
bool setStyle();
|
||||
const RSStyle &getStyle();
|
||||
virtual void updateStatus(const QString &peer_id, int status);
|
||||
|
||||
public slots:
|
||||
void updateStatus(const QString &peer_id, int status);
|
||||
void updateStatus_slot(const QString &peer_id, int status);
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
|
Loading…
Reference in New Issue
Block a user