diff --git a/application/CayaProtocolMessages.h b/application/CayaProtocolMessages.h index 4096dcc..6ba459a 100644 --- a/application/CayaProtocolMessages.h +++ b/application/CayaProtocolMessages.h @@ -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, diff --git a/application/Server.cpp b/application/Server.cpp index cc4aa7c..266d0a4 100644 --- a/application/Server.cpp +++ b/application/Server.cpp @@ -310,6 +310,7 @@ Server::ImMessage(BMessage* msg) SendProtocolMessage(msg); break; } + case IM_ROOM_CREATED: case IM_ROOM_JOINED: { _EnsureConversation(msg); diff --git a/application/windows/MainWindow.cpp b/application/windows/MainWindow.cpp index af414c4..7f63a63 100644 --- a/application/windows/MainWindow.cpp +++ b/application/windows/MainWindow.cpp @@ -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; diff --git a/protocols/xmpp/JabberHandler.cpp b/protocols/xmpp/JabberHandler.cpp index d6671be..8783529 100644 --- a/protocols/xmpp/JabberHandler.cpp +++ b/protocols/xmpp/JabberHandler.cpp @@ -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 **********************************************************************/ @@ -1454,8 +1476,12 @@ JabberHandler::handleMUCMessage(gloox::MUCRoom *room, const gloox::Message &m, 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; } diff --git a/protocols/xmpp/JabberHandler.h b/protocols/xmpp/JabberHandler.h index feebb5f..4f78386 100644 --- a/protocols/xmpp/JabberHandler.h +++ b/protocols/xmpp/JabberHandler.h @@ -96,6 +96,8 @@ protected: BString fName; BMessage _SettingsTemplate(const char* username, bool serverOption); + BMessage _RoomTemplate(); + private: CayaProtocolMessengerInterface* fServerMessenger; diff --git a/protocols/xmpp/JabberProtocol.cpp b/protocols/xmpp/JabberProtocol.cpp index f8a5fae..532d98f 100644 --- a/protocols/xmpp/JabberProtocol.cpp +++ b/protocols/xmpp/JabberProtocol.cpp @@ -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(); }