[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=3c3aa5a
The following commit has been merged in the master branch:
commit 3c3aa5abf58e666e1d07c691735eab92264da4fa
Author: Vishesh Handa <handa.vish at gmail.com>
Date: Thu Feb 16 16:20:53 2012 +0530
Implement Contact publish status
---
kpeople/nepomuk-feeder/nepomuk-storage.cpp | 199 ++++++++++++++++-------------
kpeople/nepomuk-feeder/nepomuk-storage.h | 1 +
2 files changed, 111 insertions(+), 89 deletions(-)
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index d4373ee..acc24cf 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -868,7 +868,7 @@ void NepomukStorage::setContactGroups(const QString &path,
if( groups.isEmpty() ) {
KJob* job = Nepomuk::removeProperties( QList<QUrl>() << contact.personContact(),
QList<QUrl>() << NCO::belongsToGroup() );
- //TODO: Add some error handling
+ connect( job, SIGNAL(finished(KJob*)), this, SLOT(onRemovePropertiesJob(KJob*)) );
//TODO: Maybe remove empty groups?
return;
}
@@ -914,121 +914,134 @@ void NepomukStorage::setContactPublishState(const QString &path,
const QString &id,
const Tp::Contact::PresenceState &state)
{
- /*
- ContactIdentifier identifier(path, id);
+ ContactResources contact = findContact(path, id);
+ if( contact.isEmpty() )
+ return;
- // Check if the Contact exists.
- QHash<ContactIdentifier, ContactResources>::const_iterator it = m_contacts.find(identifier);
- const bool found = (it != m_contacts.constEnd());
- Q_ASSERT(found);
- if (!found) {
- kWarning() << "Contact not found.";
+ AccountResources account = m_accounts.value(path);
+ if( account.isEmpty() )
return;
+
+ QUrl imAccountUri = contact.imAccount();
+ QUrl localAccountUri = account.account();
+
+ bool usRequest = false;
+ bool themPublish = false;
+
+ // Change the relationships based on the PresenceState value.
+ switch( state ) {
+ case Tp::Contact::PresenceStateYes:
+ themPublish = true;
+ break;
+
+ case Tp::Contact::PresenceStateAsk:
+ usRequest = true;
+ break;
+
+ case Tp::Contact::PresenceStateNo:
+ break;
+
+ default:
+ kWarning() << "Invalid Tp::Contact::PresenceState received.";
+ Q_ASSERT(false);
}
- ContactResources resources = it.value();
+ if( usRequest ) {
+ Nepomuk::SimpleResource &localAccountRes = m_graph[localAccountUri];
+ localAccountRes.setUri( localAccountUri );
+ localAccountRes.setProperty( NCO::requestedPresenceSubscriptionTo(), imAccountUri );
- // Get the local related account.
- Q_ASSERT(m_accounts.contains(path));
- if (!m_accounts.contains(path)) {
- kWarning() << "Account not found.";
- return;
+ fireGraphTimer();
+ }
+ else {
+ // Remove us from the requested-to-them list
+ KJob* job = Nepomuk::removeProperty( QList<QUrl>() << localAccountUri,
+ NCO::requestedPresenceSubscriptionTo(),
+ QVariantList() << imAccountUri );
+ connect( job, SIGNAL(finished(KJob*)), this, SLOT(onRemovePropertiesJob(KJob*)) );
}
- QUrl imAccountUri = resources.imAccount();
- QUrl localAccountUri = m_accounts.value(path).account();*/
+ if( themPublish ) {
+ Nepomuk::SimpleResource &imAccount = m_graph[imAccountUri];
+ imAccount.setUri( imAccountUri );
+ imAccount.setProperty( NCO::publishesPresenceTo(), localAccountUri );
- //FIXME: Implment me properly using Nepomuk::Resource (when it is ported to the DMS)
- // Change the relationships based on the PresenceState value.
-// if (state == Tp::Contact::PresenceStateYes) {
-// // Add publishes to us.
-//
-// KJob *job = Nepomuk::addProperty( NCO::publishesPresenceTo(), localAccountUri );
-// job->exec();
-// if( job->error() ) {
-// kWarning() << job->errorString();
-// }
-//
-// // Remove requested from us.
-// localAccount.remove(Nepomuk::Vocabulary::NCO::requestedPresenceSubscriptionTo(), imAccount.uri());
-//
-// } else if (state == Tp::Contact::PresenceStateAsk) {
-// // We request subscription to them
-// localAccount.addProperty(Nepomuk::Vocabulary::NCO::requestedPresenceSubscriptionTo(), localAccount.uri());
-//
-// // Remove us from their publish list.
-// imAccount.remove(Nepomuk::Vocabulary::NCO::publishesPresenceTo(), localAccount.uri());
-//
-// } else if (state == Tp::Contact::PresenceStateNo) {
-// // Remove us from the requested-to-them list
-// localAccount.remove(Nepomuk::Vocabulary::NCO::requestedPresenceSubscriptionTo(), imAccount.uri());
-//
-// // Remove us from their publish list
-// imAccount.remove(Nepomuk::Vocabulary::NCO::publishesPresenceTo(), localAccount.uri());
-//
-// } else {
-// kWarning() << "Invalid Tp::Contact::PresenceState received.";
-// Q_ASSERT(false);
-// }
+ fireGraphTimer();
+ }
+ else {
+ // Remove us from their publish list
+ KJob* job = Nepomuk::removeProperty( QList<QUrl>() << imAccountUri,
+ NCO::publishesPresenceTo(),
+ QVariantList() << localAccountUri );
+ connect( job, SIGNAL(finished(KJob*)), this, SLOT(onRemovePropertiesJob(KJob*)) );
+ }
}
void NepomukStorage::setContactSubscriptionState(const QString &path,
const QString &id,
const Tp::Contact::PresenceState &state)
{
-// kDebug() << "Not implemented";
-// kDebug() << path << id << state;
- /*
- ContactIdentifier identifier(path, id);
-
- // Check the Contact exists.
- Q_ASSERT(m_contacts.contains(identifier));
- if (!m_contacts.contains(identifier)) {
- kWarning() << "Contact not found.";
+ ContactResources contact = findContact(path, id);
+ if( contact.isEmpty() )
return;
- }
-
- ContactResources resources = m_contacts.value(identifier);
- Nepomuk::SimpleResource imAccount(resources.imAccount());
-
- // Get the local related account.
- Q_ASSERT(m_accounts.contains(path));
- if (!m_accounts.contains(path)) {
- kWarning() << "Account not found.";
+ AccountResources account = m_accounts.value(path);
+ if( account.isEmpty() )
return;
- }
- Nepomuk::SimpleResource localAccount(m_accounts.value(path).account());
+ QUrl imAccountUri = contact.imAccount();
+ QUrl localAccountUri = account.account();
+
+ bool usPublish = false;
+ bool themRequest = false;
// Change the relationships based on the PresenceState value.
- if (state == Tp::Contact::PresenceStateYes) {
- // Add we publishes to them.
- localAccount.addProperty(Nepomuk::Vocabulary::NCO::publishesPresenceTo(), imAccount.uri());
-
- // Remove requested from them.
- imAccount.remove(Nepomuk::Vocabulary::NCO::requestedPresenceSubscriptionTo(), localAccount.uri());
+ switch( state ) {
+ case Tp::Contact::PresenceStateYes:
+ usPublish = true;
+ break;
- } else if (state == Tp::Contact::PresenceStateAsk) {
- // They request subscription to us
- imAccount.addProperty(Nepomuk::Vocabulary::NCO::requestedPresenceSubscriptionTo(), localAccount.uri());
+ case Tp::Contact::PresenceStateAsk:
+ themRequest = true;
+ break;
- // Remove them from our publish list.
- localAccount.remove(Nepomuk::Vocabulary::NCO::publishesPresenceTo(), imAccount.uri());
+ case Tp::Contact::PresenceStateNo:
+ break;
- } else if (state == Tp::Contact::PresenceStateNo) {
- // Remove them from the requested-to-us list
- imAccount.remove(Nepomuk::Vocabulary::NCO::requestedPresenceSubscriptionTo(), localAccount.uri());
+ default:
+ kWarning() << "Invalid Tp::Contact::PresenceState received.";
+ Q_ASSERT(false);
+ }
- // Remove them from our publish list
- localAccount.remove(Nepomuk::Vocabulary::NCO::publishesPresenceTo(), imAccount.uri());
+ if( usPublish ) {
+ Nepomuk::SimpleResource &localAccountRes = m_graph[localAccountUri];
+ localAccountRes.setUri( localAccountUri );
+ localAccountRes.setProperty( NCO::requestedPresenceSubscriptionTo(), imAccountUri );
- } else {
- kWarning() << "Invalid Tp::Contact::PresenceState received.";
- Q_ASSERT(false);
+ fireGraphTimer();
}
+ else {
+ // Remove us from the requested-to-them list
+ KJob* job = Nepomuk::removeProperty( QList<QUrl>() << localAccountUri,
+ NCO::publishesPresenceTo(),
+ QVariantList() << imAccountUri );
+ connect( job, SIGNAL(finished(KJob*)), this, SLOT(onRemovePropertiesJob(KJob*)) );
+ }
+
+ if( themRequest ) {
+ Nepomuk::SimpleResource &imAccount = m_graph[imAccountUri];
+ imAccount.setUri( imAccountUri );
+ imAccount.setProperty( NCO::requestedPresenceSubscriptionTo(), localAccountUri );
- saveGraph(Nepomuk::SimpleResourceGraph() << imAccount << localAccount);*/
+ fireGraphTimer();
+ }
+ else {
+ // Remove us from their publish list
+ KJob* job = Nepomuk::removeProperty( QList<QUrl>() << imAccountUri,
+ NCO::requestedPresenceSubscriptionTo(),
+ QVariantList() << localAccountUri );
+ connect( job, SIGNAL(finished(KJob*)), this, SLOT(onRemovePropertiesJob(KJob*)) );
+ }
}
void NepomukStorage::setContactCapabilities(const QString &path,
@@ -1136,6 +1149,14 @@ void NepomukStorage::onContactGraphJob(KJob* job)
m_unresolvedContacts = unresolvedContacts;
}
+void NepomukStorage::onRemovePropertiesJob(KJob* job)
+{
+ if( job->error() ) {
+ kWarning() << job->errorString();
+ return;
+ }
+}
+
int qHash(ContactIdentifier c)
{
// FIXME: This is a shit way of doing it.
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.h b/kpeople/nepomuk-feeder/nepomuk-storage.h
index 778fa61..a58cbe4 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.h
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.h
@@ -157,6 +157,7 @@ private Q_SLOTS:
void onContactTimer();
void onContactGraphJob(KJob *job);
+ void onRemovePropertiesJob(KJob *job);
private:
Q_DISABLE_COPY(NepomukStorage);
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list