1 /* 2 * %kadu copyright begin% 3 * Copyright 2012 Bartosz Brachaczek (b.brachaczek@gmail.com) 4 * Copyright 2012, 2013, 2014 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com) 5 * %kadu copyright end% 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #pragma once 22 23 #include "buddies/buddy-set.h" 24 #include "chat/chat-details.h" 25 #include "contacts/contact-set.h" 26 #include "contacts/contact.h" 27 #include "exports.h" 28 29 #include <QtCore/QPointer> 30 #include <injeqt/injeqt.h> 31 32 class ChatTypeManager; 33 34 /** 35 * @addtogroup Chat 36 * @{ 37 */ 38 39 /** 40 * @class ChatDetailsRoom 41 * @author Rafal 'Vogel' Malinowski 42 * @short Chat data specyfic to 'Room' chat type. 43 * 44 * Class contains dynamic set of Contact objects and a room's name. Chat name is set to this room's name. 45 */ 46 class KADUAPI ChatDetailsRoom : public ChatDetails 47 { 48 Q_OBJECT 49 50 protected: 51 virtual void load(); 52 virtual void store(); 53 virtual bool shouldStore(); 54 55 public: 56 explicit ChatDetailsRoom(ChatShared *chatData); 57 virtual ~ChatDetailsRoom(); 58 59 virtual ChatType * type() const; contacts()60 virtual ContactSet contacts() const { return m_contacts; } 61 virtual QString name() const; 62 63 /** 64 * @author Rafal 'Vogel' Malinowski 65 * @short Set value of Connected property. 66 * @param newConnected new value of Connected property 67 * 68 * This method sets value of Connected property only when protocol of this @link Chat @endlink is connected. If not, 69 * the value of Connected property will remain false. 70 * 71 * One of signals @link connected @endlink and @link disconnected @endlink may be emited after calling this method. 72 */ 73 void setConnected(bool newConnected); 74 virtual bool isConnected() const; 75 76 /** 77 * @author Rafal 'Vogel' Malinowski 78 * @short Set room for this chat. 79 * @param room new room for this chat 80 * 81 * Room can have different format depending on protocol. For example, for XMPP MUC it is JIS in form of 82 * room@server. 83 */ 84 void setRoom(const QString &room); 85 86 /** 87 * @author Rafal 'Vogel' Malinowski 88 * @short Get current room for this chat. 89 * @return current room for this chat 90 */ 91 QString room() const; 92 93 /** 94 * @author Rafal 'Vogel' Malinowski 95 * @short Set nick for this chat. 96 * @param nick new nick for this chat 97 */ 98 void setNick(const QString &nick); 99 100 /** 101 * @author Rafal 'Vogel' Malinowski 102 * @short Get current nick for this chat. 103 * @return current nick for this chat 104 */ 105 QString nick() const; 106 107 /** 108 * @author Rafal 'Vogel' Malinowski 109 * @short Set password for this chat. 110 * @param password new password for this chat 111 */ 112 void setPassword(const QString &password); 113 114 /** 115 * @author Rafal 'Vogel' Malinowski 116 * @short Get current password for this chat. 117 * @return current password for this chat 118 */ 119 QString password() const; 120 121 void setStayInRoomAfterClosingWindow(bool stayInRoomAfterClosingWindow); 122 bool stayInRoomAfterClosingWindow() const; 123 124 /** 125 * @author Rafal 'Vogel' Malinowski 126 * @short Add new contact to this chat. 127 * @param contact contact to add 128 * 129 * Calling this method may result in emiiting of @link contactAdded @endlink signal if contact was not already on chat. 130 */ 131 void addContact(const Contact &contact); 132 133 /** 134 * @author Rafal 'Vogel' Malinowski 135 * @short Remove contact from this chat. 136 * @param contact contact to remove 137 * 138 * Calling this method may result in emiiting of @link contactRemoved @endlink signal if contact was on chat. 139 */ 140 void removeContact(const Contact &contact); 141 142 private: 143 QPointer<ChatTypeManager> m_chatTypeManager; 144 145 QString m_room; 146 QString m_nick; 147 QString m_password; 148 bool m_stayInRoomAfterClosingWindow; 149 150 ContactSet m_contacts; 151 152 bool m_connected; 153 154 private slots: 155 INJEQT_SET void setChatTypeManager(ChatTypeManager *chatTypeManager); 156 157 /** 158 * @author Rafal 'Vogel' Malinowski 159 * @short Slot called when a protocol's connection state changes. 160 * 161 * This slot is called when a protocol's connection state changes. If protocol is disconnected then value of Connected property 162 * is set to false and @link disconnected @endlink may be emited. 163 */ 164 void updateConnected(); 165 166 }; 167 168 /** 169 * @} 170 */ 171