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:
csoler 2011-12-04 14:31:48 +00:00
parent 46f1e2b562
commit a0e3522273
10 changed files with 217 additions and 52 deletions

View file

@ -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.
//
}

View file

@ -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&) ;

View file

@ -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();

View file

@ -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 */