/** * @author Rafal 'Vogel' Malinowski * @short Stored chat data to storage. * * Stores all chat data to storage. If details class is loaded it is stored too. */ void ChatShared::store() { ensureLoaded(); if (!isValidStorage()) return; Shared::store(); ConfigurationApi *configurationStorage = storage()->storage(); QDomElement parent = storage()->point(); storeValue("Account", ChatAccount->uuid().toString()); storeValue("Display", Display); // import from alias to new name of chat type ChatType *chatType = m_chatTypeManager->chatType(Type); if (chatType) Type = chatType->name(); storeValue("Type", Type); if (!Groups.isEmpty()) { QDomElement groupsNode = configurationStorage->getNode(parent, "ChatGroups", ConfigurationApi::ModeCreate); foreach (const Group &group, Groups) configurationStorage->appendTextNode(groupsNode, "Group", group.uuid().toString()); }
void EditTalkableAction::updateChatActionState(Action *action) { setChatActionTitleAndIcon(action); const Chat &chat = actionChat(action->context()); ChatType *chatType = ChatTypeManager::instance()->chatType(chat.type()); action->setEnabled(chat && (!chatType || (chatType->name() != "Contact" && !chat.display().isEmpty()))); }
/** * @author Rafal 'Vogel' Malinowski * @short Loads chat data from storage. * * This method is called when object is used at first time. It loads data from object's * storage point. After loading data chat type is known ('Type') so this method check * if the type is any of known chat types. If so, details class is created, assigned and * loaded - chat has full data available. If no, loading details class is deffered to * moment after good chat type is loaded. This mechanism is provided by * @link ChatTypeAvareObject @endlink class. */ void ChatShared::load() { if (!isValidStorage()) return; Shared::load(); ConfigurationApi *configurationStorage = storage()->storage(); QDomElement parent = storage()->point(); Groups.clear(); QDomElement groupsNode = configurationStorage->getNode(parent, "ChatGroups", ConfigurationApi::ModeFind); if (!groupsNode.isNull()) { QDomNodeList groupsList = groupsNode.elementsByTagName("Group"); int count = groupsList.count(); for (int i = 0; i < count; i++) { QDomElement groupElement = groupsList.at(i).toElement(); if (groupElement.isNull()) continue; doAddToGroup(m_groupManager->byUuid(groupElement.text())); } } *ChatAccount = m_accountManager->byUuid(QUuid(loadValue<QString>("Account"))); Display = loadValue<QString>("Display"); auto type = loadValue<QString>("Type"); // import from alias to new name of chat type ChatType *chatType = m_chatTypeManager->chatType(type); if (chatType) type = chatType->name(); // we should not have display names for Contact chats if (type == "Contact") Display.clear(); setType(type); }