Room-creation for XMPP

This commit is contained in:
Jaidyn Ann 2021-06-18 01:30:59 -05:00
parent 7c002d8fcc
commit 48f84377fc
6 changed files with 37 additions and 4 deletions

View File

@ -215,7 +215,8 @@ enum im_what_code {
// CayaProtocol::SettingsTemplate("room")
IM_CREATE_ROOM = 152,
//! Create a room →Caya
//! Inform Caya room was created →Caya
// Just a semantically-dressed IM_ROOM_JOINED
// Requires: String "chat_id"
IM_ROOM_CREATED = 153,

View File

@ -310,6 +310,7 @@ Server::ImMessage(BMessage* msg)
SendProtocolMessage(msg);
break;
}
case IM_ROOM_CREATED:
case IM_ROOM_JOINED:
{
_EnsureConversation(msg);

View File

@ -248,9 +248,10 @@ MainWindow::ImMessage(BMessage* msg)
}
case IM_ROOM_JOINED:
case IM_ROOM_PARTICIPANTS:
case IM_ROOM_CREATED:
case IM_CHAT_CREATED:
case IM_MESSAGE_RECEIVED:
case IM_MESSAGE_SENT:
case IM_CHAT_CREATED:
{
_EnsureConversationItem(msg);
break;

View File

@ -1,6 +1,6 @@
/*
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the GPL v2 License.
*
* Authors:
@ -148,6 +148,14 @@ JabberHandler::Process(BMessage* msg)
break;
}
case IM_CREATE_ROOM: {
BString chat_id;
if (msg->FindString("chat_id", &chat_id) != B_OK)
break;
_JoinRoom(chat_id);
break;
}
case IM_JOIN_ROOM: {
BString chat_id;
if (msg->FindString("chat_id", &chat_id) == B_OK)
@ -1162,6 +1170,20 @@ JabberHandler::_SettingsTemplate(const char* username, bool serverOption)
}
BMessage
JabberHandler::_RoomTemplate()
{
BMessage stemplate('IMst');
BMessage roomIdentifier;
roomIdentifier.AddString("name", "chat_id");
roomIdentifier.AddString("description", "JID");
roomIdentifier.AddInt32("type", 'CSTR');
stemplate.AddMessage("setting", &roomIdentifier);
return stemplate;
}
/***********************************************************************
* gloox callbacks
**********************************************************************/
@ -1456,6 +1478,10 @@ JabberHandler::handleMUCMessage(gloox::MUCRoom *room, const gloox::Message &m,
bool
JabberHandler::handleMUCRoomCreation(gloox::MUCRoom* room)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_ROOM_CREATED);
msg.AddString("chat_id", _MUCChatId(room));
_SendMessage(&msg);
return true;
}

View File

@ -96,6 +96,8 @@ protected:
BString fName;
BMessage _SettingsTemplate(const char* username, bool serverOption);
BMessage _RoomTemplate();
private:
CayaProtocolMessengerInterface*
fServerMessenger;

View File

@ -50,6 +50,8 @@ JabberProtocol::SettingsTemplate(const char* name)
{
if (name == BString("account"))
return JabberHandler::_SettingsTemplate("Jabber identifier", true);
if (name == BString("room"))
return JabberHandler::_RoomTemplate();
else
return BMessage();
}