1 /* 2 * %kadu copyright begin% 3 * Copyright 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com) 4 * %kadu copyright end% 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #pragma once 21 22 #include "protocols/services/account-service.h" 23 24 #include <QtCore/QPointer> 25 #include <injeqt/injeqt.h> 26 27 class JabberPresenceService; 28 class JabberRoomChat; 29 30 class BuddyManager; 31 class Chat; 32 class ChatDetailsRoom; 33 class ChatManager; 34 class ContactManager; 35 class MessageStorage; 36 class Message; 37 38 class QXmppClient; 39 class QXmppMessage; 40 class QXmppMucManager; 41 42 class JabberRoomChatService : public AccountService 43 { 44 Q_OBJECT 45 46 public: 47 explicit JabberRoomChatService(QXmppClient *client, QXmppMucManager *muc, Account account, QObject *parent = nullptr); 48 virtual ~JabberRoomChatService(); 49 50 void setPresenceService(JabberPresenceService *presenceService); 51 52 Message handleReceivedMessage(const QXmppMessage &xmppMessage) const; 53 54 void joinOpenedRoomChats(); 55 bool isRoomChat(const Chat &chat) const; 56 void leaveChat(const Chat &chat); 57 58 private: 59 QPointer<QXmppClient> m_client; 60 QPointer<QXmppMucManager> m_muc; 61 QPointer<BuddyManager> m_buddyManager; 62 QPointer<ChatManager> m_chatManager; 63 QPointer<ContactManager> m_contactManager; 64 QPointer<JabberPresenceService> m_presenceService; 65 QPointer<MessageStorage> m_messageStorage; 66 67 QMap<Chat, JabberRoomChat *> m_chats; 68 69 JabberRoomChat * getRoomChat(const QString &id) const; 70 JabberRoomChat * getRoomChat(const Chat &chat) const; 71 JabberRoomChat * getOrCreateRoomChat(const Chat &chat); 72 ChatDetailsRoom * myRoomChatDetails(const Chat &chat) const; 73 74 private slots: 75 INJEQT_SET void setBuddyManager(BuddyManager *buddyManager); 76 INJEQT_SET void setChatManager(ChatManager *chatManager); 77 INJEQT_SET void setContactManager(ContactManager *contactManager); 78 INJEQT_SET void setMessageStorage(MessageStorage *messageStorage); 79 INJEQT_INIT void init(); 80 81 void connected(); 82 83 void chatOpened(const Chat &chat); 84 void chatClosed(const Chat &chat); 85 86 }; 87