Commit b544efe5 authored by Rafał Malinowski's avatar Rafał Malinowski

buddy: remove old configuration entries

Signed-off-by: Rafał Malinowski's avatarRafał Malinowski <rafal.przemyslaw.malinowski@gmail.com>
parent 1242c116
......@@ -122,39 +122,6 @@ QString BuddyShared::storageNodeName()
return QStringLiteral("Buddy");
}
#define ImportProperty(name, old_name) \
set##name(CustomData.value(#old_name)); \
CustomData.remove(#old_name);
void BuddyShared::importConfiguration(const QDomElement &parent)
{
QDomNamedNodeMap attributes = parent.attributes();
int count = attributes.count();
for (int i = 0; i < count; i++)
{
QDomAttr attribute = attributes.item(i).toAttr();
CustomData.insert(attribute.name(), attribute.value());
}
Anonymous = false;
importConfiguration();
}
void BuddyShared::importConfiguration()
{
QStringList groups = CustomData["groups"].split(',', QString::SkipEmptyParts);
for (auto &&group : groups)
doAddToGroup(m_groupManager->byName(group));
CustomData.remove("groups");
ImportProperty(Display, altnick) ImportProperty(FirstName, first_name) ImportProperty(LastName, last_name)
ImportProperty(NickName, nick_name) ImportProperty(HomePhone, home_phone) ImportProperty(Mobile, mobile)
ImportProperty(Email, email)
}
void BuddyShared::load()
{
if (!isValidStorage())
......@@ -164,23 +131,7 @@ void BuddyShared::load()
ConfigurationApi *configurationStorage = storage()->storage();
QDomElement parent = storage()->point();
QDomElement customDataValues =
configurationStorage->getNode(parent, "CustomDataValues", ConfigurationApi::ModeFind);
QDomNodeList customDataValuesList = customDataValues.elementsByTagName("CustomDataValue");
int count = customDataValuesList.count();
for (int i = 0; i < count; i++)
{
QDomNode customDataNode = customDataValuesList.at(i);
QDomElement customDataElement = customDataNode.toElement();
if (customDataElement.isNull())
continue;
QString name = customDataElement.attribute("name");
if (!name.isEmpty())
CustomData[name] = customDataElement.text();
}
configurationStorage->removeNode(parent, "CustomDataValues");
Groups.clear();
QDomElement groupsNode = configurationStorage->getNode(parent, "ContactGroups", ConfigurationApi::ModeFind);
......@@ -188,7 +139,7 @@ void BuddyShared::load()
{
QDomNodeList groupsList = groupsNode.elementsByTagName("Group");
count = groupsList.count();
auto count = groupsList.count();
for (int i = 0; i < count; i++)
{
QDomElement groupElement = groupsList.at(i).toElement();
......@@ -236,16 +187,6 @@ void BuddyShared::store()
Shared::store();
ConfigurationApi *configurationStorage = storage()->storage();
QDomElement parent = storage()->point();
QDomElement customDataValues =
configurationStorage->getNode(parent, "CustomDataValues", ConfigurationApi::ModeCreate);
for (QMap<QString, QString>::const_iterator it = CustomData.constBegin(), end = CustomData.constEnd(); it != end;
++it)
configurationStorage->createNamedTextNode(customDataValues, "CustomDataValue", it.key(), it.value());
// should not happen, but who knows...
if (Display.isEmpty())
Display = uuid().toString();
......@@ -268,6 +209,9 @@ void BuddyShared::store()
// TODO when we change configuration format (or just file name): remove it
storeValue("Anonymous", false);
ConfigurationApi *configurationStorage = storage()->storage();
QDomElement parent = storage()->point();
if (!Groups.isEmpty())
{
QDomElement groupsNode = configurationStorage->getNode(parent, "ContactGroups", ConfigurationApi::ModeCreate);
......
......@@ -112,7 +112,6 @@ class KADUAPI BuddyShared : public Shared
bool CollectingGarbage;
QMap<QString, QString> CustomData;
QList<Contact> Contacts;
QString Display;
......@@ -176,11 +175,6 @@ public:
QString id(const Account &account);
QMap<QString, QString> &customData()
{
return CustomData;
}
void addContact(const Contact &contact);
void removeContact(const Contact &contact);
QVector<Contact> contacts(const Account &account);
......
......@@ -68,35 +68,6 @@ Buddy::~Buddy()
data()->collectGarbage();
}
void Buddy::importConfiguration(const QDomElement &parent)
{
if (data())
data()->importConfiguration(parent);
}
void Buddy::importConfiguration()
{
if (data())
data()->importConfiguration();
}
QString Buddy::customData(const QString &key) const
{
return isNull() ? QString() : data()->customData()[key];
}
void Buddy::setCustomData(const QString &key, const QString &value)
{
if (!isNull())
data()->customData().insert(key, value);
}
void Buddy::removeCustomData(const QString &key)
{
if (!isNull())
data()->customData().remove(key);
}
void Buddy::sortContacts()
{
if (!isNull())
......
......@@ -64,13 +64,6 @@ public:
void mergeWith(Buddy buddy); // TODO: 0.10 refactor
void importConfiguration(const QDomElement &parent);
void importConfiguration(); // import configuration from customDataValues
QString customData(const QString &key) const;
void setCustomData(const QString &key, const QString &value);
void removeCustomData(const QString &key);
void sortContacts();
void normalizePriorities();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment