[SCM] ktp-kded-integration-module packaging branch, master, updated. debian/15.12.1-2-382-gbd961c2
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:15:54 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=c26d40d
The following commit has been merged in the master branch:
commit c26d40d17f06a0e682b7284a2834bd14c1ca79f0
Author: Martin Klapetek <mklapetek at kde.org>
Date: Fri Feb 6 16:30:07 2015 +0100
Include the blocked state in offline cache
Otherwise the contact list is unable to filter blocked contacts out and
always displays all the contacts until it goes online (and then it gets
the value from Tp::Contact directly)
The database should be updated automatically, if it's not, just delete
your $XDG_DATA_HOME/ktp/cache.db and restart kded module
---
contact-cache.cpp | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/contact-cache.cpp b/contact-cache.cpp
index 3b3c500..5c72db5 100644
--- a/contact-cache.cpp
+++ b/contact-cache.cpp
@@ -66,13 +66,27 @@ ContactCache::ContactCache(QObject *parent):
qWarning() << "couldn't open database" << m_db.databaseName();
}
- if (!m_db.tables().contains(QLatin1String("groups"))) {
+ // This is the query that creates the contacts table,
+ // SQLite will store this within the sqlite_master table
+ QString createTableQuery = QStringLiteral("CREATE TABLE contacts (accountId VARCHAR NOT NULL, contactId VARCHAR NOT NULL, alias VARCHAR, avatarFileName VARCHAR, isBlocked INT, groupsIds VARCHAR);");
+
+ // Now let's verify that the table we currently have in the database
+ // is the same one as above - get the stored query and compare them,
+ // if they are different (for example when the table structure was
+ // changed), the table will be dropped and recreated
+ QSqlQuery verifyTableQuery(QStringLiteral("SELECT sql FROM sqlite_master WHERE tbl_name = 'contacts' AND type = 'table';"), m_db);
+ verifyTableQuery.exec();
+ verifyTableQuery.first();
+ bool match = verifyTableQuery.value(QStringLiteral("sql")).toString() == createTableQuery;
+ verifyTableQuery.finish();
+
+ if (!m_db.tables().contains(QLatin1String("groups")) || !match) {
QSqlQuery preparationsQuery(m_db);
if (m_db.tables().contains(QLatin1String("contacts"))) {
- preparationsQuery.exec(QLatin1String("DROP TABLE contacts;"));
+ preparationsQuery.exec(QStringLiteral("DROP TABLE 'contacts';"));
}
- preparationsQuery.exec(QLatin1String("CREATE TABLE contacts (accountId VARCHAR NOT NULL, contactId VARCHAR NOT NULL, alias VARCHAR, avatarFileName VARCHAR, groupsIds VARCHAR);"));
+ preparationsQuery.exec(createTableQuery);
preparationsQuery.exec(QLatin1String("CREATE TABLE groups (groupId INTEGER, groupName VARCHAR);"));
preparationsQuery.exec(QLatin1String("CREATE UNIQUE INDEX idIndex ON contacts (accountId, contactId);"));
}
@@ -204,7 +218,7 @@ void ContactCache::onAllKnownContactsChanged(const Tp::Contacts &added, const Tp
}
QSqlQuery insertQuery(m_db);
- insertQuery.prepare(QLatin1String("INSERT INTO contacts (accountId, contactId, alias, avatarFileName, groupsIds) VALUES (?, ?, ?, ?, ?);"));
+ insertQuery.prepare(QLatin1String("INSERT INTO contacts (accountId, contactId, alias, avatarFileName, isBlocked, groupsIds) VALUES (?, ?, ?, ?, ?, ?);"));
Q_FOREACH (const Tp::ContactPtr &c, added) {
if (c->manager()->connection()->protocolName() == QLatin1String("local-xmpp")) {
continue;
@@ -243,7 +257,7 @@ void ContactCache::syncContactsOfAccount(const Tp::AccountPtr &account)
purgeQuery.exec();
QSqlQuery insertQuery(m_db);
- insertQuery.prepare(QLatin1String("INSERT INTO contacts (accountId, contactId, alias, avatarFileName, groupsIds) VALUES (?, ?, ?, ?, ?);"));
+ insertQuery.prepare(QLatin1String("INSERT INTO contacts (accountId, contactId, alias, avatarFileName, isBlocked, groupsIds) VALUES (?, ?, ?, ?, ?, ?);"));
Q_FOREACH (const Tp::ContactPtr &c, account->connection()->contactManager()->allKnownContacts()) {
bindContactToQuery(&insertQuery, c);
insertQuery.exec();
@@ -305,6 +319,7 @@ void ContactCache::bindContactToQuery(QSqlQuery *query, const Tp::ContactPtr &co
query->bindValue(1, ktpContact->id());
query->bindValue(2, ktpContact->alias());
query->bindValue(3, ktpContact->avatarData().fileName);
+ query->bindValue(4, ktpContact->isBlocked());
QStringList groupsIds;
@@ -312,5 +327,5 @@ void ContactCache::bindContactToQuery(QSqlQuery *query, const Tp::ContactPtr &co
groupsIds.append(QString::number(askIdFromGroup(group)));
}
- query->bindValue(4, groupsIds.join(QLatin1String(",")));
+ query->bindValue(5, groupsIds.join(QLatin1String(",")));
}
--
ktp-kded-integration-module packaging
More information about the pkg-kde-commits
mailing list