[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:07:26 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=6be69e6
The following commit has been merged in the master branch:
commit 6be69e660a2e018626b70aa3a26f1819b19f7650
Author: Vishesh Handa <handa.vish at gmail.com>
Date: Thu Feb 16 16:14:05 2012 +0530
Update local account properties asynchronously
They are done together with the contact properties in 200 msec
increments.
---
kpeople/nepomuk-feeder/nepomuk-storage.cpp | 112 ++++++++++++++---------------
kpeople/nepomuk-feeder/nepomuk-storage.h | 11 ++-
2 files changed, 64 insertions(+), 59 deletions(-)
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index 4919020..d4373ee 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -131,6 +131,11 @@ bool AccountResources::operator!=(const QUrl &other) const
return !(*this == other);
}
+bool AccountResources::isEmpty() const
+{
+ return d->account.isEmpty() && d->protocol.isEmpty();
+}
+
class ContactIdentifier::Data : public QSharedData {
public:
@@ -284,8 +289,8 @@ NepomukStorage::NepomukStorage(QObject *parent)
QTimer::singleShot(0, this, SLOT(init()));
- m_contactsTimer.setSingleShot( true );
- connect( &m_contactsTimer, SIGNAL(timeout()), this, SLOT(onContactTimer()) );
+ m_graphTimer.setSingleShot( true );
+ connect( &m_graphTimer, SIGNAL(timeout()), this, SLOT(onContactTimer()) );
}
NepomukStorage::~NepomukStorage()
@@ -643,52 +648,47 @@ void NepomukStorage::destroyAccount(const QString &path)
setAccountCurrentPresence(path, presence);
}
+AccountResources NepomukStorage::findAccount(const QString& path)
+{
+ QHash<QString, AccountResources>::const_iterator it = m_accounts.constFind(path);
+ if( it == m_accounts.constEnd() ) {
+ kWarning() << "Account not found: " << path;
+ return AccountResources();
+ }
+
+ return it.value();
+}
+
void NepomukStorage::setAccountNickname(const QString &path, const QString &nickname)
{
- // Check the account exists
- QHash<QString, AccountResources>::const_iterator it = m_accounts.find(path);
- const bool found = (m_accounts.constEnd() != it);
- Q_ASSERT(found);
- if (!found) {
- kWarning() << "Account not found.";
+ AccountResources account = findAccount(path);
+ if( account.isEmpty() )
return;
- }
- QUrl accountUri = it.value().account();
+ QUrl accountUri = account.account();
- KJob *job = Nepomuk::setProperty(QList<QUrl>() << accountUri, NCO::imNickname(), QVariantList() << nickname);
- job->exec();
- if( job->error() ) {
- kWarning() << job->errorString();
- }
+ Nepomuk::SimpleResource &accountRes = m_graph[accountUri];
+ accountRes.setUri( accountUri );
+ accountRes.setProperty( NCO::imNickname(), nickname );
+
+ fireGraphTimer();
}
void NepomukStorage::setAccountCurrentPresence(const QString &path, const Tp::SimplePresence &presence)
{
- // Check the account exists
- QHash<QString, AccountResources>::const_iterator it = m_accounts.find(path);
- const bool found = (m_accounts.constEnd() != it);
- Q_ASSERT(found);
- if (!found) {
- kWarning() << "Account not found.";
+ AccountResources account = findAccount(path);
+ if( account.isEmpty() )
return;
- }
-
- QUrl accountUri = it.value().account();
- Nepomuk::SimpleResource account( accountUri );
+ QUrl accountUri = account.account();
- // Update the Presence properties.
- account.setProperty(Nepomuk::Vocabulary::NCO::imStatus(), presence.status);
- account.setProperty(Nepomuk::Vocabulary::NCO::imStatusMessage(), presence.statusMessage);
- account.setProperty(Nepomuk::Vocabulary::Telepathy::statusType(), presence.type);
+ Nepomuk::SimpleResource &accountRes = m_graph[accountUri];
+ accountRes.setUri( accountUri );
+ accountRes.setProperty(NCO::imStatus(), presence.status);
+ accountRes.setProperty(NCO::imStatusMessage(), presence.statusMessage);
+ accountRes.setProperty(Telepathy::statusType(), presence.type);
- KJob *job = Nepomuk::storeResources(Nepomuk::SimpleResourceGraph() << account,
- Nepomuk::IdentifyNew, Nepomuk::OverwriteProperties );
- job->exec();
- if( job->error() ) {
- kWarning() << job->errorString();
- }
+ fireGraphTimer();
}
//
@@ -710,10 +710,10 @@ ContactResources NepomukStorage::findContact(const QString& path, const QString&
return it.value();
}
-void NepomukStorage::fireContactTimer()
+void NepomukStorage::fireGraphTimer()
{
- if( !m_contactsTimer.isActive() )
- m_contactsTimer.start( 500 );
+ if( !m_graphTimer.isActive() )
+ m_graphTimer.start( 500 );
}
@@ -790,14 +790,14 @@ void NepomukStorage::createContact(const QString &path, const QString &id)
newPersonContact.addProperty(Nepomuk::Vocabulary::NCO::hasIMAccount(), newImAccount);
newPimoPerson.addProperty(Nepomuk::Vocabulary::PIMO::groundingOccurrence(), newPersonContact);
- m_contactGraph << newPersonContact << newImAccount << newPimoPerson;
+ m_graph << newPersonContact << newImAccount << newPimoPerson;
m_contacts.insert( identifier, ContactResources(newPimoPerson.uri(),
newPersonContact.uri(),
newImAccount.uri()) );
// Insert into a list so that their real uri can be set later on
m_unresolvedContacts.append( identifier );
- fireContactTimer();
+ fireGraphTimer();
}
void NepomukStorage::destroyContact(const QString &path, const QString &id)
@@ -817,11 +817,11 @@ void NepomukStorage::setContactAlias(const QString &path, const QString &id, con
QUrl imAccountUri = contact.imAccount();
- Nepomuk::SimpleResource &res = m_contactGraph[imAccountUri];
+ Nepomuk::SimpleResource &res = m_graph[imAccountUri];
res.setUri( imAccountUri );
res.setProperty( NCO::imNickname(), alias );
- fireContactTimer();
+ fireGraphTimer();
// vHanda; WTF!! This is not good.
/*if (!Nepomuk::Resource(resources.person()).hasProperty(Soprano::Vocabulary::NAO::prefLabel())) {
@@ -846,14 +846,14 @@ void NepomukStorage::setContactPresence(const QString &path,
QUrl imAccountUri = contact.imAccount();
hasInvalidResources();
- Nepomuk::SimpleResource &imAccount = m_contactGraph[imAccountUri];
+ Nepomuk::SimpleResource &imAccount = m_graph[imAccountUri];
imAccount.setUri( imAccountUri );
imAccount.setProperty(NCO::imStatus(), presence.status);
imAccount.setProperty(NCO::imStatusMessage(), presence.statusMessage);
imAccount.setProperty(Telepathy::statusType(), presence.type);
hasInvalidResources();
- fireContactTimer();
+ fireGraphTimer();
}
void NepomukStorage::setContactGroups(const QString &path,
@@ -881,16 +881,16 @@ void NepomukStorage::setContactGroups(const QString &path,
groupRes.setProperty( NCO::contactGroupName(), groupName );
groupUris << groupRes.uri();
- m_contactGraph << groupRes;
+ m_graph << groupRes;
}
QUrl contactUri = contact.personContact();
- Nepomuk::SimpleResource &contactRes = m_contactGraph[contactUri];
+ Nepomuk::SimpleResource &contactRes = m_graph[contactUri];
contactRes.setUri( contactUri );
contactRes.setProperty( NCO::belongsToGroup(), groupUris );
- fireContactTimer();
+ fireGraphTimer();
}
void NepomukStorage::setContactBlockStatus(const QString &path, const QString &id, bool blocked)
@@ -902,12 +902,12 @@ void NepomukStorage::setContactBlockStatus(const QString &path, const QString &i
QUrl imAccountUri = contact.imAccount();
hasInvalidResources();
- Nepomuk::SimpleResource &imAccount = m_contactGraph[imAccountUri];
+ Nepomuk::SimpleResource &imAccount = m_graph[imAccountUri];
imAccount.setUri( imAccountUri );
imAccount.setProperty( NCO::isBlocked(), blocked );
hasInvalidResources();
- fireContactTimer();
+ fireGraphTimer();
}
void NepomukStorage::setContactPublishState(const QString &path,
@@ -1052,12 +1052,12 @@ void NepomukStorage::setContactCapabilities(const QString &path,
capList << NCO::imCapabilityVideo();
hasInvalidResources();
- Nepomuk::SimpleResource &imAccount = m_contactGraph[imAccountUri];
+ Nepomuk::SimpleResource &imAccount = m_graph[imAccountUri];
imAccount.setUri( imAccountUri );
imAccount.setProperty( NCO::hasIMCapability(), capList );
hasInvalidResources();
- fireContactTimer();
+ fireGraphTimer();
}
void NepomukStorage::setContactAvatar(const QString &path,
@@ -1085,17 +1085,17 @@ void NepomukStorage::setContactAvatar(const QString &path,
fileUrl.setScheme(QLatin1String("file"));
hasInvalidResources();
- Nepomuk::SimpleResource& personContact = m_contactGraph[contact.personContact()];
+ Nepomuk::SimpleResource& personContact = m_graph[contact.personContact()];
personContact.setUri(contact.personContact());
personContact.setProperty( NCO::photo(), fileUrl );
hasInvalidResources();
- Nepomuk::SimpleResource& imAccount = m_contactGraph[contact.imAccount()];
+ Nepomuk::SimpleResource& imAccount = m_graph[contact.imAccount()];
imAccount.setUri(contact.imAccount());
imAccount.setProperty( Telepathy::avatar(), fileUrl );
hasInvalidResources();
- fireContactTimer();
+ fireGraphTimer();
//TODO: Find a way to index the file as well.
}
@@ -1103,10 +1103,10 @@ void NepomukStorage::onContactTimer()
{
// kDebug() << m_contactGraph;
hasInvalidResources();
- KJob *job = Nepomuk::storeResources( m_contactGraph, Nepomuk::IdentifyNew, Nepomuk::OverwriteProperties );
+ KJob *job = Nepomuk::storeResources( m_graph, Nepomuk::IdentifyNew, Nepomuk::OverwriteProperties );
connect( job, SIGNAL(finished(KJob*)), this, SLOT(onContactGraphJob(KJob*)) );
- m_contactGraph.clear();
+ m_graph.clear();
}
void NepomukStorage::onContactGraphJob(KJob* job)
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.h b/kpeople/nepomuk-feeder/nepomuk-storage.h
index 62c02df..778fa61 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.h
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.h
@@ -4,6 +4,8 @@
* Copyright (C) 2009-2011 Collabora Ltd. <info at collabora.co.uk>
* @author George Goldberg <george.goldberg at collabora.co.uk>
*
+ * Copyright (C) 2011-2012 Vishesh Handa <handa.vish at gmail.com>
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -60,6 +62,7 @@ public:
bool operator==(const QUrl &other) const;
bool operator!=(const QUrl &other) const;
+ bool isEmpty() const;
private:
class Data;
QSharedDataPointer<Data> d;
@@ -166,11 +169,13 @@ private:
QHash<ContactIdentifier, ContactResources> m_contacts;
QList<ContactIdentifier> m_unresolvedContacts;
- Nepomuk::SimpleResourceGraph m_contactGraph;
- QTimer m_contactsTimer;
+ Nepomuk::SimpleResourceGraph m_graph;
+ QTimer m_graphTimer;
ContactResources findContact(const QString& path, const QString& id);
- void fireContactTimer();
+ AccountResources findAccount(const QString& path);
+
+ void fireGraphTimer();
bool hasInvalidResources() const;
};
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list