diff --git a/libresapi/src/api/ChatHandler.cpp b/libresapi/src/api/ChatHandler.cpp index 97967f10a..149a14ccf 100644 --- a/libresapi/src/api/ChatHandler.cpp +++ b/libresapi/src/api/ChatHandler.cpp @@ -71,13 +71,17 @@ StreamBase& operator <<(StreamBase& left, KeyValueReference 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 unsubscribed_lobbies; mRsMsgs->getListOfNearbyChatLobbies(unsubscribed_lobbies); for(std::vector::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 >::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(); diff --git a/libresapi/src/api/ChatHandler.h b/libresapi/src/api/ChatHandler.h index fd8bda8ae..257192d29 100644 --- a/libresapi/src/api/ChatHandler.h +++ b/libresapi/src/api/ChatHandler.h @@ -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; } };