Commit 0325bf50 authored by Rafał Malinowski's avatar Rafał Malinowski

message: split half of MessageManager into UnreadMessageRepository

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent af3267af
......@@ -25,7 +25,8 @@
#include "chat/chat-details-contact-set.h"
#include "chat/chat-details-contact.h"
#include "chat/type/chat-type-manager.h"
#include "message/message-manager.h"
#include "core/core.h"
#include "message/unread-message-repository.h"
#include "chat-manager.h"
......@@ -53,20 +54,20 @@ ChatManager::ChatManager()
ChatManager::~ChatManager()
{
disconnect(MessageManager::instance(), 0, this, 0);
disconnect(Core::instance()->unreadMessageRepository(), 0, this, 0);
foreach (const Message &message, MessageManager::instance()->allUnreadMessages())
foreach (const Message &message, Core::instance()->unreadMessageRepository()->allUnreadMessages())
unreadMessageRemoved(message);
}
void ChatManager::init()
{
foreach (const Message &message, MessageManager::instance()->allUnreadMessages())
foreach (const Message &message, Core::instance()->unreadMessageRepository()->allUnreadMessages())
unreadMessageAdded(message);
connect(MessageManager::instance(), SIGNAL(unreadMessageAdded(Message)),
connect(Core::instance()->unreadMessageRepository(), SIGNAL(unreadMessageAdded(Message)),
this, SLOT(unreadMessageAdded(Message)));
connect(MessageManager::instance(), SIGNAL(unreadMessageRemoved(Message)),
connect(Core::instance()->unreadMessageRepository(), SIGNAL(unreadMessageRemoved(Message)),
this, SLOT(unreadMessageRemoved(Message)));
}
......
......@@ -29,7 +29,7 @@
#include "configuration/configuration-manager.h"
#include "contacts/contact-parser-tags.h"
#include "core/core.h"
#include "message/message-manager.h"
#include "message/unread-message-repository.h"
#include "protocols/protocol-factory.h"
#include "protocols/protocol.h"
#include "protocols/services/roster/roster-entry.h"
......@@ -62,9 +62,9 @@ ContactManager::ContactManager()
ContactManager::~ContactManager()
{
disconnect(MessageManager::instance(), 0, this, 0);
disconnect(Core::instance()->unreadMessageRepository(), 0, this, 0);
foreach (const Message &message, MessageManager::instance()->allUnreadMessages())
foreach (const Message &message, Core::instance()->unreadMessageRepository()->allUnreadMessages())
unreadMessageRemoved(message);
ContactParserTags::unregisterParserTags();
......@@ -77,12 +77,12 @@ void ContactManager::init()
ContactParserTags::registerParserTags();
foreach (const Message &message, MessageManager::instance()->allUnreadMessages())
foreach (const Message &message, Core::instance()->unreadMessageRepository()->allUnreadMessages())
unreadMessageAdded(message);
connect(MessageManager::instance(), SIGNAL(unreadMessageAdded(Message)),
connect(Core::instance()->unreadMessageRepository(), SIGNAL(unreadMessageAdded(Message)),
this, SLOT(unreadMessageAdded(Message)));
connect(MessageManager::instance(), SIGNAL(unreadMessageRemoved(Message)),
connect(Core::instance()->unreadMessageRepository(), SIGNAL(unreadMessageRemoved(Message)),
this, SLOT(unreadMessageRemoved(Message)));
}
......
......@@ -63,6 +63,7 @@
#include "icons/kadu-icon.h"
#include "message/message-html-renderer-service.h"
#include "message/message-manager.h"
#include "message/unread-message-repository.h"
#include "misc/date-time-parser-tags.h"
#include "misc/kadu-paths.h"
#include "notify/notification-manager.h"
......@@ -440,10 +441,10 @@ void Core::init()
AccountManager::instance()->ensureLoaded();
BuddyManager::instance()->ensureLoaded();
ContactManager::instance()->ensureLoaded();
// Without that MessageManager is loaded while filtering buddies list for the first time.
// It has to happen earlier because MessageManager::loaded() might add buddies to the BuddyManager
// Without that UnreadMessageRepository is loaded while filtering buddies list for the first time.
// It has to happen earlier because UnreadMessageRepository::loaded() might add buddies to the BuddyManager
// which (the buddies) otherwise will not be taken into account by buddies list before its next update.
MessageManager::instance()->ensureLoaded();
CurrentUnreadMessageRepository->ensureLoaded();
AvatarManager::instance(); // initialize that
#if WITH_LIBINDICATE_QT
......@@ -563,6 +564,7 @@ void Core::runServices()
CurrentBuddyConfigurationWidgetFactoryRepository = new BuddyConfigurationWidgetFactoryRepository(this);
CurrentChatConfigurationWidgetFactoryRepository = new ChatConfigurationWidgetFactoryRepository(this);
CurrentChatTopBarWidgetFactoryRepository = new ChatTopBarWidgetFactoryRepository(this);
CurrentUnreadMessageRepository = new UnreadMessageRepository(this);
// this instance lives forever
// TODO: maybe make it QObject and make CurrentChatImageRequestService its parent
......@@ -582,6 +584,8 @@ void Core::runServices()
ChatStylesManager::instance()->setFormattedStringFactory(CurrentFormattedStringFactory);
CurrentMessageHtmlRendererService->setDomProcessorService(CurrentDomProcessorService);
connect(MessageManager::instance(), SIGNAL(messageReceived(Message)), CurrentUnreadMessageRepository, SLOT(addUnreadMessage(Message)));
}
void Core::runGuiServices()
......@@ -669,6 +673,11 @@ ChatTopBarWidgetFactoryRepository * Core::chatTopBarWidgetFactoryRepository() co
return CurrentChatTopBarWidgetFactoryRepository;
}
UnreadMessageRepository * Core::unreadMessageRepository() const
{
return CurrentUnreadMessageRepository;
}
void Core::showMainWindow()
{
if (ShowMainWindowOnStart)
......
......@@ -69,6 +69,7 @@ class MessageHtmlRendererService;
class MessageTransformerService;
class NotificationService;
class RawMessageTransformerService;
class UnreadMessageRepository;
class KADUAPI Core : public QObject, private AccountsAwareObject, public ConfigurationAwareObject
{
......@@ -96,6 +97,7 @@ class KADUAPI Core : public QObject, private AccountsAwareObject, public Configu
BuddyConfigurationWidgetFactoryRepository *CurrentBuddyConfigurationWidgetFactoryRepository;
ChatConfigurationWidgetFactoryRepository *CurrentChatConfigurationWidgetFactoryRepository;
ChatTopBarWidgetFactoryRepository *CurrentChatTopBarWidgetFactoryRepository;
UnreadMessageRepository *CurrentUnreadMessageRepository;
KaduWindow *Window;
......@@ -162,6 +164,7 @@ public:
BuddyConfigurationWidgetFactoryRepository * buddyConfigurationWidgetFactoryRepository() const;
ChatConfigurationWidgetFactoryRepository * chatConfigurationWidgetFactoryRepository() const;
ChatTopBarWidgetFactoryRepository * chatTopBarWidgetFactoryRepository() const;
UnreadMessageRepository * unreadMessageRepository() const;
void setShowMainWindowOnStart(bool show);
void setMainWindow(QWidget *window);
......
......@@ -40,6 +40,7 @@
#include "icons/icons-manager.h"
#include "message/message-manager.h"
#include "message/message-render-info.h"
#include "message/unread-message-repository.h"
#include "protocols/protocol-factory.h"
#include "services/notification-service.h"
#include "activate.h"
......@@ -238,7 +239,7 @@ QList<Message> ChatWidgetManager::loadUnreadMessages(const Chat &chat)
{
const Chat &buddyChat = BuddyChatManager::instance()->buddyChat(chat);
const Chat &unreadChat = buddyChat ? buddyChat : chat;
const QList<Message> &unreadMessages = MessageManager::instance()->chatUnreadMessages(unreadChat);
const QList<Message> &unreadMessages = Core::instance()->unreadMessageRepository()->chatUnreadMessages(unreadChat);
foreach (const Message &message, unreadMessages)
{
......
......@@ -31,8 +31,9 @@
#include "accounts/account.h"
#include "buddies/buddy-preferred-manager.h"
#include "contacts/contact-manager.h"
#include "core/core.h"
#include "gui/widgets/talkable-painter.h"
#include "message/message-manager.h"
#include "message/unread-message-repository.h"
#include "model/kadu-abstract-model.h"
#include "model/model-chain.h"
......@@ -43,15 +44,15 @@ TalkableDelegate::TalkableDelegate(TalkableTreeView *parent) :
{
connect(ContactManager::instance(), SIGNAL(contactUpdated(Contact)), this, SLOT(contactUpdated(Contact)));
connect(BuddyPreferredManager::instance(), SIGNAL(buddyUpdated(Buddy)), this, SLOT(buddyUpdated(Buddy)));
connect(MessageManager::instance(), SIGNAL(unreadMessageAdded(Message)), this, SLOT(messageStatusChanged(Message)));
connect(MessageManager::instance(), SIGNAL(unreadMessageRemoved(Message)), this, SLOT(messageStatusChanged(Message)));
connect(Core::instance()->unreadMessageRepository(), SIGNAL(unreadMessageAdded(Message)), this, SLOT(messageStatusChanged(Message)));
connect(Core::instance()->unreadMessageRepository(), SIGNAL(unreadMessageRemoved(Message)), this, SLOT(messageStatusChanged(Message)));
}
TalkableDelegate::~TalkableDelegate()
{
disconnect(ContactManager::instance(), 0, this, 0);
disconnect(BuddyPreferredManager::instance(), 0, this, 0);
disconnect(MessageManager::instance(), 0, this, 0);
disconnect(Core::instance()->unreadMessageRepository(), 0, this, 0);
}
void TalkableDelegate::setChain(ModelChain *chain)
......
......@@ -36,11 +36,12 @@
#include "chat/type/chat-type.h"
#include "configuration/configuration-file.h"
#include "contacts/contact-set.h"
#include "core/core.h"
#include "gui/widgets/chat-widget-manager.h"
#include "gui/widgets/chat-widget.h"
#include "gui/widgets/custom-input.h"
#include "gui/windows/message-dialog.h"
#include "message/message-manager.h"
#include "message/unread-message-repository.h"
#include "os/generic/window-geometry-manager.h"
#include "storage/custom-properties-variant-wrapper.h"
......@@ -48,6 +49,7 @@
#include "debug.h"
#include "chat-window.h"
#include <core/core.h>
ChatWindow::ChatWindow(ChatWidget *chatWidget, QWidget *parent) :
QWidget(parent), DesktopAwareObject(this), currentChatWidget(chatWidget),
......@@ -225,7 +227,7 @@ void ChatWindow::changeEvent(QEvent *event)
if (_isActiveWindow(this))
{
MessageManager::instance()->markAllMessagesAsRead(currentChatWidget->chat());
Core::instance()->unreadMessageRepository()->markAllMessagesAsRead(currentChatWidget->chat());
setWindowTitle(currentChatWidget->title());
title_timer->stop();
}
......@@ -256,7 +258,7 @@ void ChatWindow::alertChatWidget(ChatWidget *chatWidget)
if (isChatWidgetActive(chatWidget))
{
MessageManager::instance()->markAllMessagesAsRead(currentChatWidget->chat());
Core::instance()->unreadMessageRepository()->markAllMessagesAsRead(currentChatWidget->chat());
return;
}
......
......@@ -5,6 +5,7 @@ set (message_SRCS
message-manager.cpp
message-render-info.cpp
message-shared.cpp
unread-message-repository.cpp
)
set (message_MOC_SRCS
......
......@@ -19,15 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "accounts/account.h"
#include "buddies/buddy-manager.h"
#include "chat/chat-details-buddy.h"
#include "configuration/xml-configuration-file.h"
#include "core/core.h"
#include "formatted-string/composite-formatted-string.h"
#include "formatted-string/formatted-string-factory.h"
#include "gui/widgets/chat-widget-manager.h"
#include "gui/widgets/chat-widget.h"
#include "protocols/protocol.h"
#include "protocols/services/chat-service.h"
#include "services/message-filter-service.h"
......@@ -40,100 +33,21 @@ MessageManager * MessageManager::Instance = 0;
MessageManager * MessageManager::instance()
{
if (0 == Instance)
{
Instance = new MessageManager();
Instance->init();
}
return Instance;
}
MessageManager::MessageManager()
{
triggerAllAccountsRegistered();
}
MessageManager::~MessageManager()
{
ConfigurationManager::instance()->unregisterStorableObject(this);
triggerAllAccountsUnregistered();
}
void MessageManager::init()
{
setState(StateNotLoaded);
ConfigurationManager::instance()->registerStorableObject(this);
triggerAllAccountsRegistered();
}
bool MessageManager::importFromPendingMessages()
{
QDomElement pendingMessagesNode = xml_config_file->getNode("PendingMessages", XmlConfigFile::ModeFind);
if (pendingMessagesNode.isNull())
return false;
QVector<QDomElement> messageElements = xml_config_file->getNodes(pendingMessagesNode, "Message");
foreach (const QDomElement &messageElement, messageElements)
{
QSharedPointer<StoragePoint> storagePoint(new StoragePoint(storage()->storage(), messageElement));
QUuid uuid = storagePoint->point().attribute("uuid");
if (!uuid.isNull())
{
Message message = Message::loadStubFromStorage(storagePoint);
addUnreadMessage(message);
// reset storage for message as it will be stored in other place
message.data()->setStorage(QSharedPointer<StoragePoint>());
message.data()->setState(StateNew);
}
}
// PendingMessages is no longer needed
pendingMessagesNode.parentNode().removeChild(pendingMessagesNode);
return true;
}
void MessageManager::load()
{
StorableObject::load();
if (importFromPendingMessages())
{
loaded();
return;
}
QDomElement itemsNode = storage()->point();
if (itemsNode.isNull())
return;
QVector<QDomElement> itemElements = storage()->storage()->getNodes(itemsNode, "Message");
UnreadMessages.reserve(itemElements.count());
foreach (const QDomElement &itemElement, itemElements)
{
QSharedPointer<StoragePoint> storagePoint(new StoragePoint(storage()->storage(), itemElement));
QUuid uuid = storagePoint->point().attribute("uuid");
if (!uuid.isNull())
{
Message item = Message::loadStubFromStorage(storagePoint);
addUnreadMessage(item);
}
}
loaded();
}
void MessageManager::store()
{
ensureLoaded();
foreach (Message message, UnreadMessages)
message.ensureStored();
}
void MessageManager::accountRegistered(Account account)
{
Protocol *protocol = account.protocolHandler();
......@@ -173,7 +87,6 @@ void MessageManager::messageReceivedSlot(const Message &message)
if (!CurrentMessageFilterService.data()->acceptMessage(transformedMessage))
return;
addUnreadMessage(transformedMessage);
emit messageReceived(transformedMessage);
}
......@@ -246,110 +159,4 @@ bool MessageManager::sendRawMessage(const Chat &chat, const QByteArray &content)
return protocol->chatService()->sendRawMessage(chat, content);
}
void MessageManager::addUnreadMessage(const Message &message)
{
// just ensure that owner buddy is managed - we need it to be shown on contact list
// todo: rethink this one
BuddyManager::instance()->byContact(message.messageSender(), ActionCreateAndAdd);
ChatWidget *chatWidget = ChatWidgetManager::instance()->byChat(message.messageChat(), false);
// message is pending if chat widget is not open
if (!chatWidget)
message.setPending(true);
else if (chatWidget->isActive())
return;
UnreadMessages.append(message);
emit unreadMessageAdded(message);
}
void MessageManager::removeUnreadMessage(const Message &message)
{
UnreadMessages.removeAll(message);
message.setPending(false);
message.data()->removeFromStorage();
emit unreadMessageRemoved(message);
}
const QList<Message> & MessageManager::allUnreadMessages() const
{
return UnreadMessages;
}
QList<Message> MessageManager::chatUnreadMessages(const Chat &chat) const
{
QList<Message> result;
QSet<Chat> chats;
ChatDetails *details = chat.details();
ChatDetailsBuddy *chatDetailsBuddy = qobject_cast<ChatDetailsBuddy *>(details);
if (chatDetailsBuddy)
foreach (const Chat &ch, chatDetailsBuddy->chats())
chats.insert(ch);
else
chats.insert(chat);
foreach (const Message &message, UnreadMessages)
if (chats.contains(message.messageChat()))
result.append(message);
return result;
}
bool MessageManager::hasUnreadMessages() const
{
return !UnreadMessages.isEmpty();
}
quint16 MessageManager::unreadMessagesCount() const
{
return UnreadMessages.count();
}
void MessageManager::markAllMessagesAsRead(const Chat &chat)
{
const QList<Message> &messages = chatUnreadMessages(chat);
foreach (const Message &message, messages)
{
UnreadMessages.removeAll(message);
message.setStatus(MessageStatusRead);
message.setPending(false);
message.data()->removeFromStorage();
emit unreadMessageRemoved(message);
}
}
Message MessageManager::unreadMessage() const
{
if (UnreadMessages.empty())
return Message::null;
else
return UnreadMessages.at(0);
}
Message MessageManager::unreadMessageForBuddy(const Buddy &buddy) const
{
const QList<Contact> &contacts = buddy.contacts();
foreach (const Message &message, UnreadMessages)
if (contacts.contains(message.messageSender()))
return message;
return Message::null;
}
Message MessageManager::unreadMessageForContact(const Contact &contact) const
{
foreach (const Message &message, UnreadMessages)
if (contact == message.messageSender())
return message;
return Message::null;
}
#include "moc_message-manager.cpp"
......@@ -25,11 +25,9 @@
#include "accounts/accounts-aware-object.h"
#include "message/message.h"
#include "storage/simple-manager.h"
#include "exports.h"
class Buddy;
class FormattedStringFactory;
class MessageFilterService;
class MessageTransformerService;
......@@ -47,7 +45,7 @@ class MessageTransformerService;
* This singleton class manages messages that go trought Kadu. It also stores all pending messages in permanent storage.
* Pending message is an incoming message that have not ever been displayed to user.
*/
class KADUAPI MessageManager : public QObject, public StorableObject, AccountsAwareObject
class KADUAPI MessageManager : public QObject, public AccountsAwareObject
{
Q_OBJECT
Q_DISABLE_COPY(MessageManager)
......@@ -58,13 +56,9 @@ class KADUAPI MessageManager : public QObject, public StorableObject, AccountsAw
QWeakPointer<MessageTransformerService> CurrentMessageTransformerService;
QWeakPointer<FormattedStringFactory> CurrentFormattedStringFactory;
QList<Message> UnreadMessages;
MessageManager();
virtual ~MessageManager();
void init();
/**
* @short Create outoing message for given chat and given content.
* @author Rafał 'Vogel' Malinowski
......@@ -73,16 +67,6 @@ class KADUAPI MessageManager : public QObject, public StorableObject, AccountsAw
*/
Message createOutgoingMessage(const Chat &chat, FormattedString *content);
/**
* @short Imports list of pending messages from < 0.10.0 configurations.
* @author Rafał 'Vogel' Malinowski
* @return true if there was something to import
*
* This methods import list of pending messages from < 0.10.0 configurations. If there was no such
* list false is returned.
*/
bool importFromPendingMessages();
private slots:
/**
* @short Slot called every time a new message was received from any of registered accounts.
......@@ -98,9 +82,6 @@ private slots:
void messageReceivedSlot(const Message &message);
protected:
virtual void load();
virtual void store();
virtual void accountRegistered(Account account);
virtual void accountUnregistered(Account account);
......@@ -174,54 +155,6 @@ public:
*/
bool sendRawMessage(const Chat &chat, const QByteArray &content);
/**
* @short Adds new unread message to the list.
* @author Rafał 'Vogel' Malinowski
* @param message new unread message
*
* Adds new unread message to the list. Message's pending status is set to true if no applicable
* chat widget is found. Signal unreadMessageAdded is emited.
*/
void addUnreadMessage(const Message &message);
/**
* @short Remove unread message to the list.
* @author Rafał 'Vogel' Malinowski
* @param message unread message to remove
*
* Removes unread message to the list. Message's pending status is set to false.
* Signal unreadMessageRemoved is emited.
*/
void removeUnreadMessage(const Message &message);
/**
* @short Returns list of all unread messages.
* @author Rafał 'Vogel' Malinowski
* @return list of all unread messages
*
* Returns list of all unread messages.
*/
const QList<Message> & allUnreadMessages() const;
/**
* @short Returns list of all unread messages for given chat.
* @author Rafał 'Vogel' Malinowski
* @param chat chat to get unread messages for
* @return list of all unread messages for given chat
*
* Returns list of all unread messages for given chat.
*/
QList<Message> chatUnreadMessages(const Chat &chat) const;
/**
* @short Returns true if there is any unread message in manager.
* @author Rafał 'Vogel' Malinowski
* @return true if there is any unread message in manager
*
* Returns true if there is any unread message in manager.
*/
bool hasUnreadMessages() const;
/**
* @short Returns count of unread messages in manager.
* @author Rafał 'Vogel' Malinowski
......@@ -231,46 +164,6 @@ public:
*/
quint16 unreadMessagesCount() const;
/**
* @short Marks all unread messages of given chat as read.
* @author Rafał 'Vogel' Malinowski
* @param chat chat to operate on
*
* Marks all unread messages of given chat as read. Messages are removed from unread list, its statuses
* are updated to MessageStatusRead and its pending statues are set to false.
* Signal unreadMessageRemoved is emited for each changed message.
*/
void markAllMessagesAsRead(const Chat &chat);
/**
* @short Returns one of unread messages.
* @author Rafał 'Vogel' Malinowski
* @return one of unread messages
*
* Returns one of unread messages. If no unread messages are available, returns null message.
*/
Message unreadMessage() const;
/**
* @short Returns one of unread messages sent by given buddy.
* @author Rafał 'Vogel' Malinowski
* @param buddy sender of message
* @return one of unread messages sent by given buddy
*
* Returns one of unread messages sent by given buddy. If no applicable messages are available, returns null message.
*/
Message unreadMessageForBuddy(const Buddy &buddy) const;
/**
* @short Returns one of unread messages sent by given contact.
* @author Rafał 'Vogel' Malinowski
* @param contact sender of message
* @return one of unread messages sent by given contact
*
* Returns one of unread messages sent by given contact. If no applicable messages are available, returns null message.
*/
Message unreadMessageForContact(const Contact &contact) const;
signals:
/**
* @short Signal emited every time a message is received from one of registered acocunts.
......
......@@ -34,6 +34,7 @@
#include "formatted-string/formatted-string.h"
#include "message/message-manager.h"
#include "message/message.h"
#include "message/unread-message-repository.h"
#include "misc/change-notifier.h"
#include "message-shared.h"
......@@ -78,7 +79,7 @@ void MessageShared::setFormattedStringFactory(FormattedStringFactory *formattedS
StorableObject * MessageShared::storageParent()
{
return MessageManager::instance();
return Core::instance()->unreadMessageRepository();
}
QString MessageShared::storageNodeName()
......
/*
* %kadu copyright begin%
* Copyright 2013 Rafał Malinowski (rafal.przemyslaw.malinowski@gmail.com)
* %kadu copyright end%
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "buddies/buddy-manager.h"
#include "chat/chat-details-buddy.h"
#include "gui/widgets/chat-widget-manager.h"
#include "gui/widgets/chat-widget.h"
#include "unread-message-repository.h"
UnreadMessageRepository::UnreadMessageRepository(QObject *parent) :
QObject(parent)
{
setState(StateNotLoaded);
ConfigurationManager::instance()->registerStorableObject(this);
}
UnreadMessageRepository::~UnreadMessageRepository()
{
ConfigurationManager::instance()->unregisterStorableObject(this);
}
bool UnreadMessageRepository::importFromPendingMessages()
{
auto pendingMessagesNode = xml_config_file->getNode("PendingMessages", XmlConfigFile::ModeFind);
if (pendingMessagesNode.isNull())
return false;
auto messageElements = xml_config_file->getNodes(pendingMessagesNode, "Message");
foreach (const auto &messageElement, messageElements)
{
auto storagePoint = QSharedPointer<StoragePoint>(new StoragePoint(storage()->storage(), messageElement));
auto uuid = QUuid(storagePoint->point().attribute("uuid"));
if (!uuid.isNull())
{
auto message = Message::loadStubFromStorage(storagePoint);
addUnreadMessage(message);
// reset storage for message as it will be stored in other place
message.data()->setStorage(QSharedPointer<StoragePoint>());
message.data()->setState(StateNew);
}
}
// PendingMessages is no longer needed
pendingMessagesNode.parentNode().removeChild(pendingMessagesNode);
return true;
}
void UnreadMessageRepository::load()
{
StorableObject::load();
if (importFromPendingMessages())