From 2f1aee32200aee3dd28b5f588e5941f7904659c9 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Fri, 4 Jun 2021 16:34:25 -0500 Subject: [PATCH] XMPP support for IM_ROOM_LEAVE/IM_ROOM_LEFT --- protocols/xmpp/JabberHandler.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/protocols/xmpp/JabberHandler.cpp b/protocols/xmpp/JabberHandler.cpp index 76a32c7..7640977 100644 --- a/protocols/xmpp/JabberHandler.cpp +++ b/protocols/xmpp/JabberHandler.cpp @@ -158,6 +158,22 @@ JabberHandler::Process(BMessage* msg) break; } + case IM_LEAVE_ROOM: { + BString chat_id = msg->FindString("chat_id"); + gloox::MUCRoom* room = fRooms.ValueFor(chat_id); + + // MUCs are special, one-on-ones we can just drop + if (room != NULL) + room->leave(); + + // We've gotta let Caya know! + BMessage left(IM_MESSAGE); + left.AddInt32("im_what", IM_ROOM_LEFT); + left.AddString("chat_id", chat_id); + _SendMessage(&left); + break; + } + default: return B_ERROR; } @@ -1126,8 +1142,12 @@ JabberHandler::handleMUCParticipantPresence(gloox::MUCRoom *room, return; if (isSelf == true) { + int im_what = IM_ROOM_JOINED; + if (presence.presence() == 5) + im_what = IM_ROOM_LEFT; + BMessage joinedMsg(IM_MESSAGE); - joinedMsg.AddInt32("im_what", IM_ROOM_JOINED); + joinedMsg.AddInt32("im_what", im_what); joinedMsg.AddString("chat_id", chat_id); _SendMessage(&joinedMsg); return;