Add Broadcast in list of lobbies.

Before you can only write text on it if unread messages are in.
This commit is contained in:
Phenom 2015-10-01 18:49:39 +02:00
parent b055500245
commit 986853d058
2 changed files with 31 additions and 4 deletions

View File

@ -71,13 +71,17 @@ StreamBase& operator <<(StreamBase& left, KeyValueReference<ChatLobbyId> kv)
StreamBase& operator << (StreamBase& left, ChatHandler::Lobby& l)
{
ChatId chatId(l.id);
if (l.is_broadcast)
chatId = ChatId::makeBroadcastId();
left << makeKeyValueReference("id", l.id)
<< makeKeyValue("chat_id", ChatId(l.id).toStdString())
<< makeKeyValue("chat_id", chatId.toStdString())
<< makeKeyValueReference("name",l.name)
<< makeKeyValueReference("topic", l.topic)
<< makeKeyValueReference("subscribed", l.subscribed)
<< makeKeyValueReference("auto_subscribe", l.auto_subscribe)
<< makeKeyValueReference("is_private", l.is_private)
<< makeKeyValueReference("is_broadcast", l.is_broadcast)
<< makeKeyValueReference("gxs_id", l.gxs_id);
return left;
}
@ -163,11 +167,26 @@ void ChatHandler::tick()
l.subscribed = true;
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
l.is_broadcast = false;
l.gxs_id = info.gxs_id;
lobbies.push_back(l);
}
}
ChatId id = ChatId::makeBroadcastId();
{
Lobby l;
l.id = id.toLobbyId();
l.name = "BroadCast";
l.topic = "Retroshare broadcast chat: messages are sent to all connected friends.";
l.subscribed = true;
l.auto_subscribe = false;
l.is_private = false;
l.is_broadcast = true;
l.gxs_id = id.toGxsId();
lobbies.push_back(l);
}
std::vector<VisibleChatLobbyRecord> unsubscribed_lobbies;
mRsMsgs->getListOfNearbyChatLobbies(unsubscribed_lobbies);
for(std::vector<VisibleChatLobbyRecord>::iterator vit = unsubscribed_lobbies.begin(); vit != unsubscribed_lobbies.end(); ++vit)
@ -182,6 +201,7 @@ void ChatHandler::tick()
l.subscribed = false;
l.auto_subscribe = info.lobby_flags & RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE;
l.is_private = !(info.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC);
l.is_broadcast = false;
l.gxs_id = RsGxsId();
lobbies.push_back(l);
}
@ -413,6 +433,7 @@ void ChatHandler::getPlainText(const std::string& in, std::string &out, std::vec
void ChatHandler::handleWildcard(Request &req, Response &resp)
{
(void) req;
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
resp.mDataStream.getStreamToMember();
for(std::map<ChatId, std::list<Msg> >::iterator mit = mMsgs.begin(); mit != mMsgs.end(); ++mit)
@ -470,6 +491,7 @@ void ChatHandler::handleSubscribeLobby(Request &req, Response &resp)
void ChatHandler::handleUnsubscribeLobby(Request &req, Response &resp)
{
(void) resp;
ChatLobbyId id = 0;
req.mStream << makeKeyValueReference("id", id);
mRsMsgs->unsubscribeChatLobby(id);
@ -649,16 +671,19 @@ void ChatHandler::handleInfo(Request &req, Response &resp)
void ChatHandler::handleTypingLabel(Request &req, Response &resp)
{
(void) req;
(void) resp;
}
void ChatHandler::handleSendStatus(Request &req, Response &resp)
{
(void) req;
(void) resp;
}
void ChatHandler::handleUnreadMsgs(Request &req, Response &resp)
{
(void) req;
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
resp.mDataStream.getStreamToMember();

View File

@ -57,13 +57,14 @@ public:
class Lobby{
public:
Lobby(): id(0), subscribed(false), auto_subscribe(false), is_private(false){}
Lobby(): id(0), subscribed(false), auto_subscribe(false), is_private(false), is_broadcast(false){}
ChatLobbyId id;
std::string name;
std::string topic;
bool subscribed;
bool auto_subscribe;
bool is_private;
bool is_broadcast;
RsGxsId gxs_id;// for subscribed lobbies: the id we use to write messages
@ -75,6 +76,7 @@ public:
&& subscribed == l.subscribed
&& auto_subscribe == l.auto_subscribe
&& is_private == l.is_private
&& is_broadcast == l.is_broadcast
&& gxs_id == l.gxs_id;
}
};