mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added invitation system
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-ChatLobby@4696 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b01470c639
commit
46f1e2b562
@ -230,6 +230,9 @@ virtual void getOwnAvatarData(unsigned char *& data,int& size) = 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 ;
|
||||
virtual void denyLobbyInvite(const ChatLobbyId& id) = 0 ;
|
||||
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) = 0;
|
||||
virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) = 0;
|
||||
virtual bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string& nick) = 0;
|
||||
virtual bool getNickNameForChatLobby(const ChatLobbyId& lobby_id,std::string& nick) = 0 ;
|
||||
|
@ -290,4 +290,17 @@ ChatLobbyId p3Msgs::createChatLobby(const std::string& lobby_name,const std::lis
|
||||
return mChatSrv->createChatLobby(lobby_name,invited_friends) ;
|
||||
}
|
||||
|
||||
bool p3Msgs::acceptLobbyInvite(const ChatLobbyId& id)
|
||||
{
|
||||
return mChatSrv->acceptLobbyInvite(id) ;
|
||||
}
|
||||
void p3Msgs::denyLobbyInvite(const ChatLobbyId& id)
|
||||
{
|
||||
mChatSrv->denyLobbyInvite(id) ;
|
||||
}
|
||||
void p3Msgs::getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites)
|
||||
{
|
||||
mChatSrv->getPendingChatLobbyInvites(invites) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,6 +170,9 @@ class p3Msgs: public RsMsgs
|
||||
virtual bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
|
||||
virtual void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
|
||||
virtual void invitePeerToLobby(const ChatLobbyId&, const std::string&) ;
|
||||
virtual bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
||||
virtual void denyLobbyInvite(const ChatLobbyId& id) ;
|
||||
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
||||
virtual void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ;
|
||||
virtual bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string&) ;
|
||||
virtual bool getNickNameForChatLobby(const ChatLobbyId&,std::string& nick) ;
|
||||
|
@ -496,6 +496,19 @@ void p3ChatService::receiveChatQueue()
|
||||
delete item ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
RsChatLobbyInviteItem *cl = dynamic_cast<RsChatLobbyInviteItem*>(item) ;
|
||||
|
||||
if(cl != NULL)
|
||||
{
|
||||
handleRecvLobbyInvite(cl) ;
|
||||
delete item ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
std::cerr << "Received ChatItem of unhandled type: " << std::endl;
|
||||
item->print(std::cerr,0) ;
|
||||
delete item ;
|
||||
}
|
||||
|
||||
if (publicChanged) {
|
||||
@ -1249,7 +1262,7 @@ void p3ChatService::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
|
||||
}
|
||||
void p3ChatService::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id)
|
||||
{
|
||||
std::cerr << "Sending invitation to peer " << peer_id << " to lobby "<< lobby_id << std::endl;
|
||||
std::cerr << "Sending invitation to peer " << peer_id << " to lobby "<< std::hex << lobby_id << std::dec << std::endl;
|
||||
|
||||
RsChatLobbyInviteItem *item = new RsChatLobbyInviteItem ;
|
||||
|
||||
@ -1302,6 +1315,15 @@ void p3ChatService::handleRecvLobbyInvite(RsChatLobbyInviteItem *item)
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT_LOBBY_INVITATION, NOTIFY_TYPE_ADD);
|
||||
}
|
||||
|
||||
void p3ChatService::getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites)
|
||||
{
|
||||
invites.clear() ;
|
||||
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
for(std::map<ChatLobbyId,ChatLobbyInvite>::const_iterator it(_lobby_invites_queue.begin());it!=_lobby_invites_queue.end();++it)
|
||||
invites.push_back(it->second) ;
|
||||
}
|
||||
|
||||
bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
|
||||
{
|
||||
@ -1334,6 +1356,9 @@ bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& 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.
|
||||
|
||||
return true ;
|
||||
}
|
||||
void p3ChatService::denyLobbyInvite(const ChatLobbyId& lobby_id)
|
||||
|
@ -155,6 +155,9 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
|
||||
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
|
||||
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
|
||||
bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
||||
void denyLobbyInvite(const ChatLobbyId& id) ;
|
||||
void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
||||
void invitePeerToLobby(const ChatLobbyId&, const std::string&) ;
|
||||
bool setNickNameForChatLobby(const ChatLobbyId& lobby_id,const std::string& nick) ;
|
||||
void unsubscribeChatLobby(const ChatLobbyId& lobby_id) ;
|
||||
@ -209,8 +212,6 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||
/// receive and handle chat lobby item
|
||||
bool recvLobbyChat(RsChatLobbyMsgItem*) ;
|
||||
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
||||
bool acceptLobbyInvite(const ChatLobbyId&) ;
|
||||
void denyLobbyInvite(const ChatLobbyId&) ;
|
||||
|
||||
RsChatAvatarItem *makeOwnAvatarItem() ;
|
||||
RsChatStatusItem *makeOwnCustomStateStringItem() ;
|
||||
|
@ -308,6 +308,22 @@ void FriendsDialog::updateStatusString(const QString& peer_id, const QString& st
|
||||
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
|
||||
}
|
||||
|
||||
void FriendsDialog::readChatLobbyInvites()
|
||||
{
|
||||
std::list<ChatLobbyInvite> invites ;
|
||||
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))
|
||||
{
|
||||
std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl;
|
||||
|
||||
rsMsgs->acceptLobbyInvite( (*it).lobby_id ) ;
|
||||
}
|
||||
else
|
||||
rsMsgs->denyLobbyInvite( (*it).lobby_id ) ;
|
||||
}
|
||||
|
||||
void FriendsDialog::updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat)
|
||||
{
|
||||
if(is_private_chat)
|
||||
|
@ -58,6 +58,7 @@ public slots:
|
||||
void insertChat();
|
||||
void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
||||
void resetStatusBar() ;
|
||||
void readChatLobbyInvites() ;
|
||||
|
||||
void fileHashingFinished(AttachFileItem* file);
|
||||
|
||||
|
@ -343,8 +343,10 @@ void FriendList::peerTreeWidgetCostumPopupMenu()
|
||||
|
||||
for(std::list<ChatLobbyInfo>::const_iterator it(cl_infos.begin());it!=cl_infos.end();++it)
|
||||
{
|
||||
QAction* inviteToLobbyAction = new QAction(QString::fromUtf8((*it).nick_name.c_str()), mnu);
|
||||
inviteToLobbyAction->setData(QString::number((*it).lobby_id,16));
|
||||
std::cerr << "Adding meny entry with lobby id " << std::hex << (*it).lobby_id << std::dec << std::endl;
|
||||
|
||||
QAction* inviteToLobbyAction = new QAction(QString::fromUtf8((*it).lobby_name.c_str()), mnu);
|
||||
inviteToLobbyAction->setData(QString::number((*it).lobby_id));
|
||||
connect(inviteToLobbyAction, SIGNAL(triggered()), this, SLOT(inviteToLobby()));
|
||||
mnu->addAction(inviteToLobbyAction);
|
||||
}
|
||||
@ -1426,7 +1428,10 @@ void FriendList::createchatlobby()
|
||||
std::string peer_id = getRsId(c) ;
|
||||
friend_list.push_back(peer_id) ;
|
||||
|
||||
std::string lobby_name = "New lobby (Plz add the code to select this name at creation time)" ;
|
||||
static int number=0 ;
|
||||
|
||||
++number ;
|
||||
std::string lobby_name = "my cool lobby #"+QString::number(number).toStdString()+" (Plz add proper code to dynamically set this name in FriendList::createChatLobby())" ;
|
||||
|
||||
// add to group
|
||||
ChatLobbyId id = rsMsgs->createChatLobby(lobby_name, friend_list);
|
||||
|
@ -307,6 +307,12 @@ void NotifyQt::notifyListChange(int list, int type)
|
||||
#endif
|
||||
emit filesPostModChanged(true) ; /* Local */
|
||||
break;
|
||||
case NOTIFY_LIST_CHAT_LOBBY_INVITATION:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received files changed" << std::endl ;
|
||||
#endif
|
||||
emit chatLobbyInviteReceived() ; /* Local */
|
||||
break;
|
||||
case NOTIFY_LIST_DIRLIST_FRIENDS:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received files changed" << std::endl ;
|
||||
|
@ -92,6 +92,7 @@ class NotifyQt: public QObject, public NotifyBase
|
||||
void downloadCompleteCountChanged(int /* count */);
|
||||
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
|
||||
void historyChanged(uint msgId, int type);
|
||||
void chatLobbyInviteReceived() ;
|
||||
|
||||
/* Notify from GUI */
|
||||
void chatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||
|
@ -281,6 +281,7 @@ int main(int argc, char *argv[])
|
||||
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
||||
QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ;
|
||||
QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ;
|
||||
QObject::connect(notify,SIGNAL(chatLobbyInviteReceived()) ,w->friendsDialog ,SLOT(readChatLobbyInvites() )) ;
|
||||
QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection);
|
||||
QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection);
|
||||
QObject::connect(notify,SIGNAL(downloadCompleteCountChanged(int)) ,w ,SLOT(updateTransfers(int) ));
|
||||
|
Loading…
Reference in New Issue
Block a user