void BaseStatusContainer::setDefaultStatus(const QString &startupStatus, bool offlineToInvisible, const QString &startupDescription, bool StartupLastDescription) { if (!isValidStorage()) return; QString description; if (StartupLastDescription) description = loadValue<QString>("LastStatusDescription"); else description = startupDescription; QString name; if (startupStatus == "LastStatus") { name = loadValue<QString>("LastStatusName"); if (name.isEmpty()) name = "Online"; else if ("Offline" == name && offlineToInvisible) name = "Invisible"; } else name = startupStatus; if ("Offline" == name && offlineToInvisible) name = "Invisible"; Status status; status.setType(name); status.setDescription(description); setPrivateStatus(config_file.readBoolEntry("General", "PrivateStatus")); setStatus(status); }
void TabsManager::load() { if (!isValidStorage()) return; StorableObject::load(); QDomElement itemsNode = storage()->point(); if (itemsNode.isNull()) return; QVector<QDomElement> itemElements = storage()->storage()->getNodes(itemsNode, "Tab"); foreach (const QDomElement &element, itemElements) { QUuid chatId(element.attribute("chat")); if (chatId.isNull()) continue; Chat chat = m_chatManager->byUuid(chatId); if (!chat) continue; if (element.attribute("type") == "detachedChat") chat.addProperty("tabs:detached", true, CustomProperties::Storable); else if (element.attribute("type") == "tab") chat.addProperty("tabs:attached", true, CustomProperties::Storable); m_chatWidgetManager->openChat(chat, OpenChatActivation::DoNotActivate); }
void ContactShared::load() { if (!isValidStorage()) return; Shared::load(); Id = loadValue<QString>("Id"); Priority = loadValue<int>("Priority", -1); // TODO: remove after 01.05.2015 // It's an explicit hack for update path from 0.10.1-0.11.x to 0.12+. 0.10/0.11 didn't // have Detached property. But they did have an explicit hack for totally ignoring // what Facebook says about groups, thus allowing users to place their Facebook contacts // in groups in Kadu. And without below hack all this group information is overriden // by useless a Facebook-provided group until we try to upload something to roster // for the first time, we fail and only then we set Detached to true, when group // information is already lost. bool detached = hasValue("Detached") ? loadValue<bool>("Detached", false) : Id.endsWith(QStringLiteral("@chat.facebook.com")); bool dirty = loadValue<bool>("Dirty", true); if (detached) Entry->setDetached(); else if (dirty) Entry->setHasLocalChanges(); else Entry->setSynchronized(); *ContactAccount = m_accountManager->byUuid(loadValue<QString>("Account")); doSetOwnerBuddy(m_buddyManager->byUuid(loadValue<QString>("Buddy"))); protocolFactoryRegistered(m_protocolsManager->byName(ContactAccount->protocolName())); addToBuddy(); }
void ContactManager::load() { StorableObject::load(); if (xml_config_file->getNode("ContactsNew", XmlConfigFile::ModeFind).isNull()) { importConfiguration(xml_config_file); return; } if (!isValidStorage()) return; QDomElement contactsNewNode = storage()->point(); QDomNodeList contactsNodes = contactsNewNode.elementsByTagName("Contact"); int count = contactsNodes.count(); for (int i = 0; i < count; i++) { QDomNode contactNode = contactsNodes.at(i); QDomElement contactElement = contactNode.toElement(); if (contactElement.isNull()) continue; StoragePoint *contactStoragePoint = new StoragePoint(storage()->storage(), contactElement); addContact(Contact::loadFromStorage(contactStoragePoint)); } }
void AccountShared::store() { if (!isValidStorage()) return; Shared::store(); storeValue("Identity", AccountIdentity.uuid().toString()); storeValue("Protocol", ProtocolName); storeValue("Id", id()); storeValue("RememberPassword", RememberPassword); if (RememberPassword && HasPassword) storeValue("Password", pwHash(password())); else removeValue("Password"); storeValue("UseProxy", ProxySettings.enabled()); storeValue("ProxyHost", ProxySettings.address()); storeValue("ProxyPort", ProxySettings.port()); storeValue("ProxyRequiresAuthentication", ProxySettings.requiresAuthentication()); storeValue("ProxyUser", ProxySettings.user()); storeValue("ProxyPassword", ProxySettings.password()); storeValue("PrivateStatus", PrivateStatus); }
void BuddyKaduData::store() { if (!isValidStorage()) return; storeValue("HideDescription", HideDescription); }
/** * @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 AccountShared::load() { if (!isValidStorage()) return; Shared::load(); Identity identity = IdentityManager::instance()->byUuid(loadValue<QString>("Identity")); if (identity.isNull() && !IdentityManager::instance()->items().isEmpty()) identity = IdentityManager::instance()->items().at(0); setAccountIdentity(identity); ProtocolName = loadValue<QString>("Protocol"); setId(loadValue<QString>("Id")); RememberPassword = loadValue<bool>("RememberPassword", true); HasPassword = RememberPassword; if (RememberPassword) Password = pwHash(loadValue<QString>("Password")); ProxySettings.setEnabled(loadValue<bool>("UseProxy")); ProxySettings.setAddress(loadValue<QString>("ProxyHost")); ProxySettings.setPort(loadValue<int>("ProxyPort")); ProxySettings.setRequiresAuthentication(loadValue<bool>("ProxyRequiresAuthentication")); ProxySettings.setUser(loadValue<QString>("ProxyUser")); ProxySettings.setPassword(loadValue<QString>("ProxyPassword")); PrivateStatus = loadValue<bool>("PrivateStatus", true); triggerAllProtocolsRegistered(); }
void EncryptionChatData::store() { if (!isValidStorage()) return; storeValue("Encrypt", Encrypt); }
/** * @author Rafal 'Vogel' Malinowski * @short Loads object from storage. * * Loads obejct from storage. Loads only uuid from uuid attribute. Superclass method * is not called (storage status remaining unchanged - access to each other property will * fire load method). You must call this method in loadStub methods of derivered class. */ void Shared::loadStub() { if (!isValidStorage()) return; setUuid(QUuid(loadAttribute<QString>("uuid"))); setState(StateNotLoaded); }
/** * @author Rafal 'Vogel' Malinowski * @short Loads object from storage. * * Loads the object from storage. Loads uuid from uuid attribute. Superclass method * is also called. You must call this method in load methods of derivered class. * * When reimplementing this method, avoid calling any methods or emitting signals. * It could lead to big trouble as the object is in an unstable state where State * is set to StateLoaded while actually it may be not fully loaded yet. */ void Shared::load() { if (!isValidStorage()) return; UuidStorableObject::load(); setUuid(QUuid(loadAttribute<QString>("uuid"))); }
/** * @author Rafal 'Vogel' Malinowski * @short Store string list to storagePoint XML node. * * Store string list to storagePoint XML node. Each item is stored to subnode * with name given by methos @link<storageItemNodeName> storageItemNodeName @endlink. */ void StorableStringList::store() { if (!isValidStorage()) return; auto stringListStorage = StringListStorage(storage().get(), storageItemNodeName()); stringListStorage.store(content()); }
/** * @author Rafal 'Vogel' Malinowski * @short Stores object to storage. * * Storeas obejct to storage. Stored uuid to uuid attribute. * You must call this method in load methods of derivered class. */ void Shared::store() { if (!isValidStorage()) return; UuidStorableObject::store(); storeAttribute("uuid", uuid().toString()); }
void ConferenceChat::store() { if (!isValidStorage()) return; Chat::store(); storeValue("Type", "Conference"); ContactSetConfigurationHelper::saveToConfiguration(this, "Contacts", CurrentContacts); }
void BuddyKaduData::load() { if (!isValidStorage()) return; StorableObject::load(); HideDescription = loadValue<bool>("HideDescription"); }
/** * @author Rafal 'Vogel' Malinowski * @short Stores ChatDetailsConference object to storage. * * Stores ChatDetailsConference object to the same storage assigned Chat object is * using. This stores set of contacts into 'Contacts' subnode. */ void ChatDetailsConference::store() { if (!isValidStorage()) return; ensureLoaded(); ContactSetConfigurationHelper::saveToConfiguration(this, "Contacts", Contacts); }
/** * @author Rafal 'Vogel' Malinowski * @short Loads ChatDetailsConference object from storage. * * Loads ChatDetailsConference object from the same storage assigned Chat object is * using. This loads set of contacts from 'Contacts' subnode. */ void ChatDetailsConference::load() { if (!isValidStorage()) return; ChatDetails::load(); Contacts = ContactSetConfigurationHelper::loadFromConfiguration(this, "Contacts"); }
void ConferenceChat::load() { if (!isValidStorage()) return; Chat::load(); CurrentContacts = ContactSetConfigurationHelper::loadFromConfiguration(this, "Contacts"); refreshTitle(); }
/** * @author Rafal 'Vogel' Malinowski * @short Load string list from storagePoint XML node. * * Load string list from storagePoint XML node. Each item is loaded from subnode * with name given by methos @link<storageItemNodeName> storageItemNodeName @endlink. * If storagePoint is invalid no data is loaded (and no data is removed from this * string list). */ void StorableStringList::load() { if (!isValidStorage()) return; StorableObject::load(); auto stringListStorage = StringListStorage(storage().get(), storageItemNodeName()); StringList = stringListStorage.load(); }
void ContactManager::store() { if (!isValidStorage()) return; ensureLoaded(); foreach (Contact contact, Contacts) contact.store(); }
void EncryptionChatData::load() { if (!isValidStorage()) return; StorableObject::load(); Encrypt = hasValue("Encrypt") ? loadValue<bool>("Encrypt") : importEncrypt(); }
/** * @author Rafal 'Vogel' Malinowski * @short Store string list to storagePoint XML node. * * Store string list to storagePoint XML node. Each item is stored to subnode * with name given by methos @link<storageItemNodeName> storageItemNodeName @endlink. */ void StorableStringList::store() { if (!isValidStorage()) return; XmlConfigFile *storageFile = storage()->storage(); QDomElement point = storage()->point(); storageFile->removeChildren(point); foreach (const QString &value, content()) storageFile->appendTextNode(point, storageItemNodeName(), value); }
/** * @author Rafal 'Vogel' Malinowski * @short Load string list from storagePoint XML node. * * Load string list from storagePoint XML node. Each item is loaded from subnode * with name given by methos @link<storageItemNodeName> storageItemNodeName @endlink. * If storagePoint is invalid no data is loaded (and no data is removed from this * string list). */ void StorableStringList::load() { if (!isValidStorage()) return; StorableObject::load(); StringList.clear(); XmlConfigFile *storageFile = storage()->storage(); QDomElement point = storage()->point(); QList<QDomElement> elements = storageFile->getNodes(point, storageItemNodeName()); foreach (const QDomElement &element, elements) StringList.append(element.text()); }
/** * @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); }
void ChatWidgetManager::load() { if (!isValidStorage()) return; StorableStringList::load(); foreach (const QString &uuid, content()) { QUuid chatId(uuid); if (chatId.isNull()) continue; Chat chat = ChatManager::instance()->byUuid(chatId); if (!chat) continue; openPendingMessages(chat, true); }
void ContactShared::store() { if (!isValidStorage()) return; ensureLoaded(); Shared::store(); storeValue("Id", Id); storeValue("Priority", Priority); storeValue("Dirty", RosterEntryState::Synchronized != Entry->state()); // Detached property needs to be always stored, see the load() method. storeValue("Detached", RosterEntryState::Detached == Entry->state()); storeValue("Account", ContactAccount->uuid().toString()); storeValue("Buddy", !isAnonymous() ? OwnerBuddy->uuid().toString() : QString()); removeValue("Avatar"); removeValue("Contact"); }
void BaseStatusContainer::disconnectAndStoreLastStatus(bool disconnectWithCurrentDescription, const QString &disconnectDescription) { if (!isValidStorage()) return; storeValue("LastStatusDescription", status().description()); storeValue("LastStatusName", statusName()); if (status().type() == "Offline") return; Status disconnectStatus; disconnectStatus.setType("Offline"); QString description; if (disconnectWithCurrentDescription) description = status().description(); else description = disconnectDescription; disconnectStatus.setDescription(description); setStatus(disconnectStatus); }