(irc) Public room directory/list support
This commit is contained in:
parent
10b63e4138
commit
5dbbb3a8ad
|
@ -262,8 +262,8 @@ enum im_what_code {
|
||||||
|
|
||||||
/*! Quietly add user(s) to the chat →App
|
/*! Quietly add user(s) to the chat →App
|
||||||
Shouldn't be sent automatically on joining a room.
|
Shouldn't be sent automatically on joining a room.
|
||||||
Requires: String "chat_id", StringList "user_id"
|
Requires: String "chat_id", Strings "user_id"
|
||||||
Accepts: StringList "user_name" */
|
Accepts: Strings "user_name" */
|
||||||
IM_ROOM_PARTICIPANTS = 159,
|
IM_ROOM_PARTICIPANTS = 159,
|
||||||
|
|
||||||
/*! User has explicitly joined →App
|
/*! User has explicitly joined →App
|
||||||
|
@ -405,6 +405,28 @@ enum im_what_code {
|
||||||
IM_ROOM_PARTICIPANT_STOPPED_TYPING = 211,
|
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
|
* Misc. UI messages
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -118,6 +118,8 @@ IrcProtocol::Process(BMessage* msg)
|
||||||
fWhoIsRequested = true;
|
fWhoIsRequested = true;
|
||||||
else if (command.ICompare("WHO") == 0)
|
else if (command.ICompare("WHO") == 0)
|
||||||
fWhoRequested = true;
|
fWhoRequested = true;
|
||||||
|
else if (command.ICompare("LIST") == 0)
|
||||||
|
fListRequested = true;
|
||||||
|
|
||||||
_SendIrc(line);
|
_SendIrc(line);
|
||||||
break;
|
break;
|
||||||
|
@ -352,6 +354,12 @@ IrcProtocol::Process(BMessage* msg)
|
||||||
_SendMsg(&info);
|
_SendMsg(&info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case IM_GET_ROOM_DIRECTORY:
|
||||||
|
{
|
||||||
|
BString cmd("LIST");
|
||||||
|
_SendIrc(cmd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case IM_SET_ROOM_SUBJECT:
|
case IM_SET_ROOM_SUBJECT:
|
||||||
{
|
{
|
||||||
BString chat_id;
|
BString chat_id;
|
||||||
|
@ -441,6 +449,7 @@ IrcProtocol::Connect()
|
||||||
status_t
|
status_t
|
||||||
IrcProtocol::Loop()
|
IrcProtocol::Loop()
|
||||||
{
|
{
|
||||||
|
fListRequested = false;
|
||||||
fWhoIsRequested = false;
|
fWhoIsRequested = false;
|
||||||
fWhoRequested = false;
|
fWhoRequested = false;
|
||||||
while (fSocket != NULL && fSocket->IsConnected() == true)
|
while (fSocket != NULL && fSocket->IsConnected() == true)
|
||||||
|
@ -597,6 +606,20 @@ IrcProtocol::_ProcessNumeric(int32 numeric, BString sender, BStringList params,
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case RPL_TOPIC:
|
||||||
{
|
{
|
||||||
BString chat_id = params.StringAt(1);
|
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
|
// Now, to determine if the line should be sent to system buffer
|
||||||
switch (numeric) {
|
switch (numeric) {
|
||||||
|
case RPL_LISTEND:
|
||||||
|
fListRequested = false;
|
||||||
|
break;
|
||||||
case RPL_ENDOFWHO:
|
case RPL_ENDOFWHO:
|
||||||
fWhoRequested = false;
|
fWhoRequested = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -138,6 +138,7 @@ private:
|
||||||
// user might also use the /who command― if the user does, this is true
|
// user might also use the /who command― if the user does, this is true
|
||||||
bool fWhoRequested;
|
bool fWhoRequested;
|
||||||
bool fWhoIsRequested;
|
bool fWhoIsRequested;
|
||||||
|
bool fListRequested;
|
||||||
BString fWhoIm;
|
BString fWhoIm;
|
||||||
|
|
||||||
bool fWriteLocked;
|
bool fWriteLocked;
|
||||||
|
|
Ŝarĝante…
Reference in New Issue