diff --git a/application/ChatProtocolMessages.h b/application/ChatProtocolMessages.h index ec2d657..14b0d23 100644 --- a/application/ChatProtocolMessages.h +++ b/application/ChatProtocolMessages.h @@ -262,8 +262,8 @@ enum im_what_code { /*! Quietly add user(s) to the chat →App Shouldn't be sent automatically on joining a room. - Requires: String "chat_id", StringList "user_id" - Accepts: StringList "user_name" */ + Requires: String "chat_id", Strings "user_id" + Accepts: Strings "user_name" */ IM_ROOM_PARTICIPANTS = 159, /*! User has explicitly joined →App @@ -405,6 +405,28 @@ enum im_what_code { IM_ROOM_PARTICIPANT_STOPPED_TYPING = 211, + /* + * Room directory messages + */ + + /*! Request a list of rooms →Protocol */ + IM_GET_ROOM_DIRECTORY = 230, + + /*! Send a room in the directory →App + This can be used to send either a list of publically available rooms + or a list of "hidden"/"disabled" rooms, one-by-one. + + A room listed thanks to this message might be joined through + IM_JOIN_ROOM. Since IM_JOIN_ROOM accepts slots from the template, you + must fill in IM_ROOM_DIRECTORY messages with any required custom slots + you use for room-joining― the message you send will be actually be + copied and sent back verbatim (with im_what changed to IM_JOIN_ROOM) + to join. + Requires: Strings "chat_id" + Allows: String "chat_name", String "subject", int32 "user_count"*/ + IM_ROOM_DIRECTORY = 231, + + /* * Misc. UI messages */ diff --git a/protocols/irc/IrcProtocol.cpp b/protocols/irc/IrcProtocol.cpp index 8a1d62b..10b01bb 100644 --- a/protocols/irc/IrcProtocol.cpp +++ b/protocols/irc/IrcProtocol.cpp @@ -118,6 +118,8 @@ IrcProtocol::Process(BMessage* msg) fWhoIsRequested = true; else if (command.ICompare("WHO") == 0) fWhoRequested = true; + else if (command.ICompare("LIST") == 0) + fListRequested = true; _SendIrc(line); break; @@ -352,6 +354,12 @@ IrcProtocol::Process(BMessage* msg) _SendMsg(&info); break; } + case IM_GET_ROOM_DIRECTORY: + { + BString cmd("LIST"); + _SendIrc(cmd); + break; + } case IM_SET_ROOM_SUBJECT: { BString chat_id; @@ -441,6 +449,7 @@ IrcProtocol::Connect() status_t IrcProtocol::Loop() { + fListRequested = false; fWhoIsRequested = false; fWhoRequested = false; while (fSocket != NULL && fSocket->IsConnected() == true) @@ -597,6 +606,20 @@ IrcProtocol::_ProcessNumeric(int32 numeric, BString sender, BStringList params, } break; } + case RPL_LIST: + { + BString chat_id = params.StringAt(1); + BString subject = params.Last(); + int32 count = atoi(params.StringAt(2)); + + BMessage dir(IM_MESSAGE); + dir.AddInt32("im_what", IM_ROOM_DIRECTORY); + dir.AddString("chat_id", chat_id); + dir.AddString("subject", subject); + dir.AddInt32("user_count", count); + _SendMsg(&dir); + break; + } case RPL_TOPIC: { BString chat_id = params.StringAt(1); @@ -613,6 +636,9 @@ IrcProtocol::_ProcessNumeric(int32 numeric, BString sender, BStringList params, // Now, to determine if the line should be sent to system buffer switch (numeric) { + case RPL_LISTEND: + fListRequested = false; + break; case RPL_ENDOFWHO: fWhoRequested = false; break; diff --git a/protocols/irc/IrcProtocol.h b/protocols/irc/IrcProtocol.h index 89139fb..aee40c6 100644 --- a/protocols/irc/IrcProtocol.h +++ b/protocols/irc/IrcProtocol.h @@ -138,6 +138,7 @@ private: // user might also use the /who command― if the user does, this is true bool fWhoRequested; bool fWhoIsRequested; + bool fListRequested; BString fWhoIm; bool fWriteLocked;