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") // CayaProtocol::SettingsTemplate("room")
IM_CREATE_ROOM = 152, 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" // Requires: String "chat_id"
IM_ROOM_CREATED = 153, IM_ROOM_CREATED = 153,

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Copyright 2010, Pier Luigi Fiorini. 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. * Distributed under the terms of the GPL v2 License.
* *
* Authors: * Authors:
@ -148,6 +148,14 @@ JabberHandler::Process(BMessage* msg)
break; 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: { case IM_JOIN_ROOM: {
BString chat_id; BString chat_id;
if (msg->FindString("chat_id", &chat_id) == B_OK) 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 * gloox callbacks
**********************************************************************/ **********************************************************************/
@ -1454,8 +1476,12 @@ JabberHandler::handleMUCMessage(gloox::MUCRoom *room, const gloox::Message &m,
bool bool
JabberHandler::handleMUCRoomCreation(gloox::MUCRoom *room) 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; return true;
} }

View File

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

View File

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