1 /* 2 * %kadu copyright begin% 3 * Copyright 2014 Bartosz Brachaczek (b.brachaczek@gmail.com) 4 * Copyright 2011, 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 "html/normalized-html-string.h" 24 #include "message/message-common.h" 25 #include "storage/shared.h" 26 #include "exports.h" 27 28 #include <QtCore/QDateTime> 29 #include <QtCore/QPointer> 30 #include <QtCore/QSharedData> 31 32 class ChatManager; 33 class Chat; 34 class ContactManager; 35 class Contact; 36 class UnreadMessageRepository; 37 38 class KADUAPI MessageShared : public Shared 39 { 40 Q_OBJECT 41 42 public: 43 explicit MessageShared(const QUuid &uuid = QUuid()); 44 virtual ~MessageShared(); 45 46 virtual StorableObject * storageParent(); 47 virtual QString storageNodeName(); 48 49 void setStatus(MessageStatus status); 50 51 KaduShared_PropertyDeclCRW(Chat, messageChat, MessageChat) 52 KaduShared_PropertyDeclCRW(Contact, messageSender, MessageSender) 53 KaduShared_Property(const NormalizedHtmlString &, content, Content) 54 KaduShared_Property(const QDateTime &, receiveDate, ReceiveDate) 55 KaduShared_Property(const QDateTime &, sendDate, SendDate) 56 KaduShared_PropertyRead(MessageStatus, status, Status) 57 KaduShared_Property(MessageType, type, Type) 58 KaduShared_Property(const QString &, id, Id) 59 60 signals: 61 /** 62 * @short Signal emited when message status was changed. 63 * @param previousStatus status before change 64 * 65 * This signal is emited when message status changes. 66 */ 67 void statusChanged(MessageStatus previousStatus); 68 69 void updated(); 70 71 protected: 72 virtual void load(); 73 virtual void store(); 74 virtual bool shouldStore(); 75 76 private: 77 QPointer<ChatManager> m_chatManager; 78 QPointer<ContactManager> m_contactManager; 79 QPointer<UnreadMessageRepository> m_unreadMessageRepository; 80 81 Chat *MessageChat; 82 Contact *MessageSender; 83 NormalizedHtmlString Content; 84 QDateTime ReceiveDate; 85 QDateTime SendDate; 86 MessageStatus Status; 87 MessageType Type; 88 QString Id; 89 90 private slots: 91 INJEQT_SET void setChatManager(ChatManager *chatManager); 92 INJEQT_SET void setContactManager(ContactManager *contactManager); 93 INJEQT_SET void setUnreadMessageRepository(UnreadMessageRepository *unreadMessageRepository); 94 95 }; 96