[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:04:26 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=6ab2131
The following commit has been merged in the master branch:
commit 6ab2131e3f186490b7be4da91a3df2c97e631ca1
Author: George Goldberg <grundleborg at googlemail.com>
Date: Thu Feb 11 21:23:09 2010 +0000
More tidyup of Nepomuk related code, particularly TelepathyAccount class. Cleanup is complete (for now).
svn path=/trunk/playground/network/telepathy-integration-daemon/; revision=1088897
---
kpeople/nepomuk-feeder/telepathyaccount.cpp | 89 +++++++++++-----------
kpeople/nepomuk-feeder/telepathyaccount.h | 5 +-
kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp | 3 +-
3 files changed, 47 insertions(+), 50 deletions(-)
diff --git a/kpeople/nepomuk-feeder/telepathyaccount.cpp b/kpeople/nepomuk-feeder/telepathyaccount.cpp
index dfbcea0..ad19297 100644
--- a/kpeople/nepomuk-feeder/telepathyaccount.cpp
+++ b/kpeople/nepomuk-feeder/telepathyaccount.cpp
@@ -23,20 +23,13 @@
#include "telepathyaccountmonitor.h"
-#include "telepathy.h"
-
-// Ontology uri's
+// Ontology Vocabularies
#include "nco.h"
-#include "pimo.h"
-
-// Full Ontologies
-#include "personcontact.h"
-#include "imaccount.h"
+#include "telepathy.h"
-#include <kdebug.h>
+#include <KDebug>
#include <Nepomuk/ResourceManager>
-#include <Nepomuk/Thing>
#include <Nepomuk/Variant>
#include <Soprano/Model>
@@ -101,59 +94,63 @@ void TelepathyAccount::onAccountReady(Tp::PendingOperation *op)
void TelepathyAccount::doNepomukSetup()
{
+ // Get a copy of the "me" PersonContact.
Nepomuk::PersonContact mePersonContact = m_parent->mePersonContact();
- Nepomuk::IMAccount imAccount;
-
- imAccount = getNepomukImAccount(mePersonContact);
-
- // If the IMAccount returned is empty, create a new one.
- if (imAccount == Nepomuk::IMAccount()) {
- kDebug() << "No Nepomuk::IMAccount found. Create a new one";
-
- imAccount.addProperty(Nepomuk::Vocabulary::NCO::imAccountType(), m_account->protocol());
- imAccount.addProperty(Nepomuk::Vocabulary::NCO::imID(), m_account->parameters().value("account").toString());
- imAccount.addProperty(Nepomuk::Vocabulary::NCO::imNickname(), m_account->displayName());
- imAccount.addProperty(Nepomuk::Vocabulary::Telepathy::accountIdentifier(), m_path);
- mePersonContact.addProperty(Nepomuk::Vocabulary::NCO::hasIMAccount(), imAccount);
- }
-}
-
-Nepomuk::IMAccount TelepathyAccount::getNepomukImAccount(const Nepomuk::PersonContact &mePersonContact)
-{
- // ************************************************************************
- // Now we have got hold of "me", we
- // can query for "my" IM Accounts.
+ // Query Nepomuk for all IMAccounts that the "me" PersonContact has.
QString query = QString("select distinct ?a where { %1 %2 ?a . ?a a %3 }")
- .arg(Soprano::Node::resourceToN3(mePersonContact.resourceUri()))
- .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::hasIMAccount()))
- .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::IMAccount()));
+ .arg(Soprano::Node::resourceToN3(mePersonContact.resourceUri()))
+ .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::hasIMAccount()))
+ .arg(Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NCO::IMAccount()));
Soprano::Model *model = Nepomuk::ResourceManager::instance()->mainModel();
Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageSparql);
+ // Iterate over all the IMAccounts found.
while(it.next()) {
- Nepomuk::Resource foundImAccountResource(it.binding("a").uri());
- Nepomuk::IMAccount foundImAccount(foundImAccountResource);
- kDebug() << "Found IM Account: " << foundImAccount;
+ Nepomuk::IMAccount foundImAccount(it.binding("a").uri());
+ kDebug() << "Found IM Account: " << foundImAccount.uri();
+ // See if the Account has the same Telepathy Account Identifier as the account this
+ // TelepathyAccount instance has been created to look after.
QStringList accountIdentifiers = foundImAccount.accountIdentifiers();
- if (accountIdentifiers.size() != 0) {
- QString accountIdentifier = accountIdentifiers.first();
+ if (accountIdentifiers.size() != 1) {
+ kDebug() << "Account does not have 1 Telepathy Account Identifier. Oops. Ignoring."
+ << "Number of Identifiers: "
+ << accountIdentifiers.size();
+ continue;
+ }
- kDebug() << "Account Identifier:" << accountIdentifier;
+ // Exactly one identifier found. Check if it matches the one we are looking for.
+ QString accountIdentifier = accountIdentifiers.first();
+ kDebug() << "Account Identifier:" << accountIdentifier;
- if (accountIdentifier == m_path) {
- kDebug() << "Already have this account in Nepomuk. Skip.";
- // TODO: Update the account if necessary.
- return foundImAccount;
- }
+ if (accountIdentifier == m_path) {
+ kDebug() << "Found the corresponding IMAccount in Nepomuk.";
+ // It matches, so set our member variable to it and stop looping.
+ m_accountResource = foundImAccount;
+ break;
}
}
- return Nepomuk::IMAccount();
+ // If the accountResource is still empty, create a new IMAccount.
+ if (m_accountResource == Nepomuk::IMAccount()) {
+ kDebug() << "Could not find corresponding IMAccount in Nepomuk. Creating a new one.";
+
+ m_accountResource.addProperty(Nepomuk::Vocabulary::NCO::imAccountType(),
+ m_account->protocol());
+ m_accountResource.addProperty(Nepomuk::Vocabulary::NCO::imID(),
+ m_account->parameters().value("account").toString());
+ m_accountResource.addProperty(Nepomuk::Vocabulary::NCO::imNickname(),
+ m_account->displayName());
+ m_accountResource.addProperty(Nepomuk::Vocabulary::Telepathy::accountIdentifier(),
+ m_path);
+
+ mePersonContact.addProperty(Nepomuk::Vocabulary::NCO::hasIMAccount(),
+ m_accountResource);
+ }
}
void TelepathyAccount::onHaveConnectionChanged(bool haveConnection)
diff --git a/kpeople/nepomuk-feeder/telepathyaccount.h b/kpeople/nepomuk-feeder/telepathyaccount.h
index f224d51..7dc5316 100644
--- a/kpeople/nepomuk-feeder/telepathyaccount.h
+++ b/kpeople/nepomuk-feeder/telepathyaccount.h
@@ -65,11 +65,10 @@ private:
TelepathyAccountMonitor *m_parent;
- QString m_path;
Tp::AccountPtr m_account;
+ Nepomuk::IMAccount m_accountResource;
Tp::ConnectionPtr m_connection;
-
- Nepomuk::IMAccount accountResource;
+ QString m_path;
};
diff --git a/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp b/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp
index 210a8e4..37a2d1f 100644
--- a/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp
+++ b/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp
@@ -72,6 +72,7 @@ void TelepathyAccountMonitor::doNepomukSetup()
// fixme has been dealt with.
if (!me.exists()) {
// The PIMO:Person representing "me" does not exist, so we need to create it.
+ kWarning() << "PIMO 'me' does not exist. Creating it.";
me.addType(Nepomuk::Vocabulary::PIMO::Person());
}
@@ -87,7 +88,7 @@ void TelepathyAccountMonitor::doNepomukSetup()
}
if (!m_mePersonContact.exists()) {
- kWarning() << "Me NCO:PersonContact doesn't exist. Creating it...";
+ kWarning() << "PersonContact 'me' does not exist. Creating it.";
// FIXME: We shouldn't create this person contact, but for now we will
// to ease development :) (see above FIXME's)
m_mePersonContact = Nepomuk::PersonContact("nepomuk:/myself-person-contact");
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list