mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-15 01:49:35 -04:00
Improvements to chat lobbies:
- added generic methods and items for bouncing generic objects through lobbies - added handling of peer typing status - proper handling of peer join/leave lobby - added sub item ids to lobby messages to allow proper message splitting - made 2 different message splitting methods for normal chat vs. lobbies. In v0.6, we'll have to handle all messages the same way. - added parent id to RsChatLobbyMsgItem, to allow threaded chat. - added possibility to make a lobby public/private (not yet fully working) - added items for requesting/exchanging list of public lobbies at friends' (not yet fully working) - major cleaning of p3chatservice.cc Next move: - gui for listing friend public lobbies, joining them, etc. - load/save of persistent lobbies. - autoremove of inactive lobbies Warning: lobby message items of this version are incompatible with previous versions. It won't crash, but messages will not pass through. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4755 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e430612714
commit
e9d6940b09
20 changed files with 965 additions and 296 deletions
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "channels/CreateChannel.h"
|
||||
#include "chat/PopupChatDialog.h"
|
||||
#include "chat/ChatLobbyDialog.h"
|
||||
#include "common/Emoticons.h"
|
||||
#include "common/vmessagebox.h"
|
||||
#include "connect/ConfCertDialog.h"
|
||||
|
@ -297,6 +298,16 @@ void FriendsDialog::updateStatusTyping()
|
|||
}
|
||||
}
|
||||
|
||||
void FriendsDialog::displayChatLobbyEvent(qulonglong lobby_id,int event_type,const QString& nickname,const QString& str)
|
||||
{
|
||||
std::cerr << "Received displayChatLobbyEvent()!" << std::endl;
|
||||
|
||||
std::string vpid ;
|
||||
if(rsMsgs->getVirtualPeerId(lobby_id,vpid))
|
||||
if( ChatLobbyDialog *cld = dynamic_cast<ChatLobbyDialog*>(PopupChatDialog::getExistingInstance(vpid)))
|
||||
cld->displayLobbyEvent(event_type,nickname,str) ;
|
||||
}
|
||||
|
||||
// Called by libretroshare through notifyQt to display the peer's status
|
||||
//
|
||||
void FriendsDialog::updateStatusString(const QString& peer_id, const QString& status_string)
|
||||
|
@ -317,7 +328,7 @@ void FriendsDialog::readChatLobbyInvites()
|
|||
rsMsgs->getPendingChatLobbyInvites(invites) ;
|
||||
|
||||
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it)
|
||||
if(QMessageBox::Ok == QMessageBox::question(NULL,tr("Invitation to chat lobby"),QString::fromStdString((*it).peer_id)+QString(" invites you to chat lobby named ")+QString::fromUtf8((*it).lobby_name.c_str()),QMessageBox::Ok,QMessageBox::Ignore))
|
||||
if(QMessageBox::Ok == QMessageBox::question(NULL,tr("Invitation to chat lobby"),QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())+QString(" invites you to chat lobby named ")+QString::fromUtf8((*it).lobby_name.c_str()),QMessageBox::Ok,QMessageBox::Ignore))
|
||||
{
|
||||
std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl;
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public slots:
|
|||
|
||||
void insertChat();
|
||||
void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
||||
void displayChatLobbyEvent(qulonglong,int,const QString&,const QString&) ;
|
||||
void resetStatusBar() ;
|
||||
void readChatLobbyInvites() ;
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@ ChatLobbyDialog::~ChatLobbyDialog()
|
|||
{
|
||||
// announce leaving of lobby
|
||||
|
||||
// check that the lobby still exists.
|
||||
ChatLobbyId lid ;
|
||||
if(!rsMsgs->isLobbyId(getPeerId(),lid))
|
||||
return ;
|
||||
|
||||
if(QMessageBox::Yes == QMessageBox::question(NULL,tr("Unsubscribe to lobby?"),tr("Do you want to unsubscribe to this chat lobby?"),QMessageBox::Yes | QMessageBox::No))
|
||||
rsMsgs->unsubscribeChatLobby(lobby_id) ;
|
||||
}
|
||||
|
@ -77,11 +82,6 @@ void ChatLobbyDialog::setNickName(const QString& nick)
|
|||
rsMsgs->setNickNameForChatLobby(lobby_id,nick.toUtf8().constData()) ;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
||||
|
@ -118,3 +118,25 @@ void ChatLobbyDialog::updateFriendsList()
|
|||
friendsListWidget->addItem(QString::fromUtf8((*it2).c_str())) ;
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::displayLobbyEvent(int event_type,const QString& nickname,const QString& str)
|
||||
{
|
||||
switch(event_type)
|
||||
{
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_LEFT: addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), str + tr(" has left the lobby."), TYPE_NORMAL);
|
||||
break ;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_JOINED:
|
||||
addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), str + tr(" joined the lobby."), TYPE_NORMAL);
|
||||
break ;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
||||
updateStatusString(nickname,str) ;
|
||||
break ;
|
||||
default:
|
||||
std::cerr << "ChatLobbyDialog::displayLobbyEvent() Unhandled lobby event type " << event_type << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
QString ChatLobbyDialog::makeStatusString(const QString& peer_id, const QString& status_string) const
|
||||
{
|
||||
return QString::fromUtf8(peer_id.toStdString().c_str()) + " " + tr(status_string.toAscii());
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ class ChatLobbyDialog: public PopupChatDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void displayLobbyEvent(int event_type,const QString& nickname,const QString& str) ;
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog(const std::string& id,const ChatLobbyId& lid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
@ -55,8 +58,8 @@ class ChatLobbyDialog: public 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.
|
||||
virtual void addIncomingChatMsg(const ChatInfo& info) ; //
|
||||
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
||||
|
||||
protected slots:
|
||||
void setNickName(const QString&) ;
|
||||
|
|
|
@ -101,7 +101,10 @@ void CreateLobbyDialog::createLobby()
|
|||
std::string lobby_name = ui->lobbyName_LE->text().toUtf8().constData() ;
|
||||
|
||||
// add to group
|
||||
ChatLobbyId id = rsMsgs->createChatLobby(lobby_name, mShareList);
|
||||
|
||||
int lobby_privacy_type = (ui->security_CB->currentIndex() == 0)?RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC:RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE ;
|
||||
|
||||
ChatLobbyId id = rsMsgs->createChatLobby(lobby_name, mShareList, lobby_privacy_type);
|
||||
|
||||
std::cerr << "gui: Created chat lobby " << std::hex << id << std::endl ;
|
||||
|
||||
|
|
|
@ -133,6 +133,16 @@ p, li { white-space: pre-wrap; }
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Security policy:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -143,6 +153,20 @@ p, li { white-space: pre-wrap; }
|
|||
<item>
|
||||
<widget class="QLineEdit" name="nickName_LE"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="security_CB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Public (Visible by friends)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Private (Works on invitation only)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -473,11 +473,15 @@ void PopupChatDialog::updateStatusTyping()
|
|||
}
|
||||
}
|
||||
|
||||
QString PopupChatDialog::makeStatusString(const QString& peer_id,const QString& status_string) const
|
||||
{
|
||||
return QString::fromUtf8(rsPeers->getPeerName(peer_id.toStdString()).c_str()) + " " + tr(status_string.toAscii());
|
||||
}
|
||||
// Called by libretroshare through notifyQt to display the peer's status
|
||||
//
|
||||
void PopupChatDialog::updateStatusString(const QString& peer_id, const QString& status_string)
|
||||
{
|
||||
QString status = QString::fromUtf8(rsPeers->getPeerName(peer_id.toStdString()).c_str()) + " " + tr(status_string.toAscii());
|
||||
QString status = makeStatusString(peer_id,status_string) ;
|
||||
ui.statusLabel->setText(status); // displays info for 5 secs.
|
||||
ui.typingpixmapLabel->setPixmap(QPixmap(":images/typing.png") );
|
||||
|
||||
|
|
|
@ -76,7 +76,11 @@ protected:
|
|||
|
||||
void insertChatMsgs();
|
||||
void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType);
|
||||
virtual void addIncomingChatMsg(const ChatInfo& info) ; // derived in ChatLobbyDialog.
|
||||
|
||||
// derived in ChatLobbyDialog.
|
||||
//
|
||||
virtual void addIncomingChatMsg(const ChatInfo& info) ;
|
||||
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
||||
|
||||
private slots:
|
||||
void pasteLink() ;
|
||||
|
|
|
@ -228,6 +228,14 @@ void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string&
|
|||
emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromUtf8(status_string.c_str())) ;
|
||||
}
|
||||
|
||||
void NotifyQt::notifyChatLobbyEvent(uint64_t lobby_id,uint32_t event_type,const std::string& nickname,const std::string& str)
|
||||
{
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "notifyQt: Received chat lobby event message: lobby #" << std::hex << lobby_id << std::dec << ", event=" << event_type << ", str=\"" << str << "\"" << std::endl ;
|
||||
#endif
|
||||
emit chatLobbyEvent(lobby_id,event_type,QString::fromUtf8(nickname.c_str()),QString::fromUtf8(str.c_str())) ;
|
||||
}
|
||||
|
||||
void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private)
|
||||
{
|
||||
#ifdef NOTIFY_DEBUG
|
||||
|
|
|
@ -41,6 +41,7 @@ class NotifyQt: public QObject, public NotifyBase
|
|||
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleFileInfo>& found_files);
|
||||
virtual void notifyPeerHasNewAvatar(std::string peer_id) ;
|
||||
virtual void notifyOwnAvatarChanged() ;
|
||||
virtual void notifyChatLobbyEvent(uint64_t /* lobby id */,uint32_t /* event type */,const std::string& /*nickname*/,const std::string& /* any string */) ;
|
||||
virtual void notifyOwnStatusMessageChanged() ;
|
||||
virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ;
|
||||
/* peer has changed the state */
|
||||
|
@ -67,6 +68,7 @@ class NotifyQt: public QObject, public NotifyBase
|
|||
void filesPostModChanged(bool) const ;
|
||||
void transfersChanged() const ;
|
||||
void friendsChanged() const ;
|
||||
void chatLobbyEvent(qulonglong,int,const QString&,const QString&) ;
|
||||
void neighboursChanged() const ;
|
||||
void messagesChanged() const ;
|
||||
void messagesTagsChanged() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue