[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:25 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=7f2a9ab
The following commit has been merged in the master branch:
commit 7f2a9abed5de011764027871c423a08138378e19
Author: George Goldberg <grundleborg at googlemail.com>
Date: Thu Feb 11 21:22:45 2010 +0000
Begin massive cleanup and rewrite operation.
* Remove all Akonadi stuff
* Fix ontology to work (for what we use it for)
* Make Nepomuk integration stuff work in line with the methods decided on at the second Nepomuk Sprint.
svn path=/trunk/playground/network/telepathy-integration-daemon/; revision=1088891
---
kpeople/nepomuk-feeder/CMakeLists.txt | 18 ++-
kpeople/nepomuk-feeder/main.cpp | 2 +
kpeople/nepomuk-feeder/nie/CMakeLists.txt | 3 +-
.../{tpaccount.trig => telepathy.trig} | 34 ++--
kpeople/nepomuk-feeder/telepathyaccount.cpp | 179 +++++++++++++++------
kpeople/nepomuk-feeder/telepathyaccount.h | 16 +-
kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp | 50 +++---
kpeople/nepomuk-feeder/telepathyaccountmonitor.h | 22 +--
8 files changed, 211 insertions(+), 113 deletions(-)
diff --git a/kpeople/nepomuk-feeder/CMakeLists.txt b/kpeople/nepomuk-feeder/CMakeLists.txt
index ddc9c7f..7f73224 100644
--- a/kpeople/nepomuk-feeder/CMakeLists.txt
+++ b/kpeople/nepomuk-feeder/CMakeLists.txt
@@ -8,11 +8,10 @@ include(KDE4Defaults)
include(MacroLibrary)
include(MacroOptionalAddSubdirectory)
include(CheckIncludeFiles)
-find_package (KdepimLibs REQUIRED)
+include(NepomukAddOntologyClasses)
find_package (TelepathyQt4 REQUIRED)
find_package(Nepomuk REQUIRED)
-include(MacroAddOntology)
# find the pimo.trig file from the kdebase installation
find_file(PIMO_TRIG_SOURCE
@@ -55,6 +54,8 @@ include_directories(
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" )
+
+
add_subdirectory(nie)
########### next target ###############
@@ -65,18 +66,19 @@ set(telepathy_integration_daemon_SRCS
main.cpp
)
-kde4_add_ontology(pimo_SRCS ${PIMO_TRIG_SOURCE} "PIMO" "Nepomuk::Vocabulary" "trig")
-kde4_add_ontology(nco_SRCS ${NCO_TRIG_SOURCE} "NCO" "Nepomuk::Vocabulary" "trig")
-kde4_add_ontology(tpaccount_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tpaccount.trig "TPACCOUNT" "Nepomuk::Vocabulary" "trig")
+soprano_add_ontology(pimo_SRCS ${PIMO_TRIG_SOURCE} "PIMO" "Nepomuk::Vocabulary" "trig")
+soprano_add_ontology(nco_SRCS ${NCO_TRIG_SOURCE} "NCO" "Nepomuk::Vocabulary" "trig")
+soprano_add_ontology(telepathy_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/telepathy.trig "Telepathy" "Nepomuk::Vocabulary" "trig")
+
kde4_add_executable(telepathy-integration-daemon ${telepathy_integration_daemon_SRCS}
${pimo_SRCS}
${nco_SRCS}
- ${tpaccount_SRCS}
+ ${telepathy_SRCS}
+ ${telepathy_full_SRCS}
)
-target_link_libraries(telepathy-integration-daemon ${KDE4_AKONADI_LIBS}
- ${QT_QTCORE_LIBRARY}
+target_link_libraries(telepathy-integration-daemon ${QT_QTCORE_LIBRARY}
${QT_QTDBUS_LIBRARY}
${KDE4_KDECORE_LIBS}
${TELEPATHY_QT4_LIBRARIES}
diff --git a/kpeople/nepomuk-feeder/main.cpp b/kpeople/nepomuk-feeder/main.cpp
index 699038a..8efdcf6 100644
--- a/kpeople/nepomuk-feeder/main.cpp
+++ b/kpeople/nepomuk-feeder/main.cpp
@@ -69,6 +69,8 @@ int main(int argc, char *argv[])
// Quite the application when the monitor is destroyed.
QObject::connect(monitor, SIGNAL(destroyed()), &app, SLOT(quit()));
+ kDebug() << "Let's go...";
+
// Start event loop.
app.exec();
}
diff --git a/kpeople/nepomuk-feeder/nie/CMakeLists.txt b/kpeople/nepomuk-feeder/nie/CMakeLists.txt
index 1192c78..00f641c 100644
--- a/kpeople/nepomuk-feeder/nie/CMakeLists.txt
+++ b/kpeople/nepomuk-feeder/nie/CMakeLists.txt
@@ -1,4 +1,4 @@
-include(MacroAddOntologyClasses)
+include(NepomukAddOntologyClasses)
NEPOMUK_ADD_ONTOLOGY_CLASSES(
nie_SRCS
ONTOLOGIES
@@ -6,6 +6,7 @@ NEPOMUK_ADD_ONTOLOGY_CLASSES(
${CMAKE_CURRENT_SOURCE_DIR}/nfo.rdfs
${CMAKE_CURRENT_SOURCE_DIR}/nco.rdfs
${CMAKE_CURRENT_SOURCE_DIR}/nmo.rdfs
+ ${CMAKE_CURRENT_SOURCE_DIR}/../telepathy.trig
)
kde4_add_library(nie STATIC ${nie_SRCS})
target_link_libraries(nie ${QT_QTCORE_LIBRARY} ${NEPOMUK_LIBRARIES})
diff --git a/kpeople/nepomuk-feeder/tpaccount.trig b/kpeople/nepomuk-feeder/telepathy.trig
similarity index 50%
rename from kpeople/nepomuk-feeder/tpaccount.trig
rename to kpeople/nepomuk-feeder/telepathy.trig
index 091744a..af01110 100644
--- a/kpeople/nepomuk-feeder/tpaccount.trig
+++ b/kpeople/nepomuk-feeder/telepathy.trig
@@ -1,38 +1,34 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
- at prefix tpaccount: <http://nepomuk.kde.org/ontologies/2009/06/20/tpaccount#> .
+ at prefix telepathy: <http://nepomuk.kde.org/ontologies/2009/06/20/telepathy#> .
@prefix nao: <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#> .
@prefix nrl: <http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#> .
- at prefix nco: <http://www.semtaicdesktop.org/ontologies/2997/03/22/nco#> .
+ at prefix nco: <http://www.semanticdesktop.org/ontologies/2007/03/22/nco#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
-
-<http://nepomuk.kde.org/ontologies/2009/06/20/tpaccount> {
-
-tpaccount:identifier
- a nao:identifier;
- rdfs:comment "Identifier of a Local Telepathy Account (as given by the Telepathy Account Manaager).";
- rdfs:domain nco:Contact;
- rdfs:label "nao:identifier";
- rdfs:range xsd:string .
-
+telepathy: {telepathy:accountIdentifier
+ a rdf:Property ;
+ rdfs:subPropertyOf nao:identifier ;
+ rdfs:comment "Identifier of a Local Telepathy Account (as given by the Telepathy Account Manaager).";
+ rdfs:domain nco:IMAccount ;
+ rdfs:label "accountIdentifier" ;
+ rdfs:range xsd:string .
}
-
-<http://nepomuk.kde.org/ontologies/2009/06/20/tpaccount/metadata>
+<http://nepomuk.kde.org/ontologies/2009/06/20/telepathy/metadata>
{
- <http://nepomuk.kde.org/ontologies/2009/06/20/tpaccount>
+ <http://nepomuk.kde.org/ontologies/2009/06/20/telepathy>
a nrl:DocumentGraph , nrl:Ontology ;
- nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2009/06/20/tpaccount#" ;
- nao:hasDefaultNamespaceAbbreviation "tpaccount" ;
+ nao:hasDefaultNamespace "http://nepomuk.kde.org/ontologies/2009/06/20/telepathy#" ;
+ nao:hasDefaultNamespaceAbbreviation "telepathy" ;
nao:lastModified "2009-06-20T20:46:32.866Z" ;
nao:serializationLanguage "TriG" ;
nao:status "Testing" ;
nrl:updatable "0" ;
nao:version "1" .
- <http://nepomuk.kde.org/ontologies/2009/06/20/tpaccount/metadata>
+ <http://nepomuk.kde.org/ontologies/2009/06/20/telepathy/metadata>
a nrl:GraphMetadata , nrl:Ontology ;
nao:serializationLanguage "TriG" ;
- nrl:coreGraphMetadataFor <http://nepomuk.kde.org/ontologies/2009/06/20/tpaccount> .
+ nrl:coreGraphMetadataFor <http://nepomuk.kde.org/ontologies/2009/06/20/telepathy> .
}
diff --git a/kpeople/nepomuk-feeder/telepathyaccount.cpp b/kpeople/nepomuk-feeder/telepathyaccount.cpp
index 80626a3..75c9b36 100644
--- a/kpeople/nepomuk-feeder/telepathyaccount.cpp
+++ b/kpeople/nepomuk-feeder/telepathyaccount.cpp
@@ -1,7 +1,8 @@
/*
* This file is part of telepathy-integration-daemon
*
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009-2010 Collabora Ltd. <info at collabora.co.uk>
+ * @author George Goldberg <george.goldberg at collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,22 +23,25 @@
#include "telepathyaccountmonitor.h"
+#include "telepathy.h"
+
// Ontology uri's
#include "nco.h"
#include "pimo.h"
-#include "tpaccount.h"
// Full Ontologies
#include "personcontact.h"
-
-#include <Akonadi/AgentInstanceCreateJob>
-#include <Akonadi/AgentManager>
+#include "imaccount.h"
#include <kdebug.h>
+#include <Nepomuk/ResourceManager>
#include <Nepomuk/Thing>
#include <Nepomuk/Variant>
+#include <Soprano/Model>
+#include <Soprano/QueryResultIterator>
+
#include <TelepathyQt4/PendingOperation>
#include <TelepathyQt4/PendingReady>
@@ -46,6 +50,8 @@ TelepathyAccount::TelepathyAccount(const QString &path, TelepathyAccountMonitor
m_parent(parent),
m_path(path)
{
+ kDebug() << "Creating TelepathyAccount: " << path;
+
// We need to get the Tp::Account ready before we do any other stuff.
m_account = m_parent->accountManager()->accountForPath(path);
@@ -56,98 +62,175 @@ TelepathyAccount::TelepathyAccount(const QString &path, TelepathyAccountMonitor
connect(m_account->becomeReady(features),
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onAccountReady(Tp::PendingOperation*)));
+/*
+ // Connect to all the signals that indicate changes in properties we care about.
+ connect(m_account.data(),
+ SIGNAL(currentPresenceChanged(Tp::SimplePresence)),
+ SLOT(onCurrentPresenceChanged(Tp::SimplePresence)));
+ connect(m_account.data(),
+ SIGNAL(displayNameChanged(QString)),
+ SLOT(onDisplayNameChanged(QString)));
+ // ...... and any other properties we want to sync...
+*/
}
TelepathyAccount::~TelepathyAccount()
{
-
}
void TelepathyAccount::onAccountReady(Tp::PendingOperation *op)
{
if (op->isError()) {
- kWarning() << "Account" << m_path << "cannot become ready:"
- << op->errorName() << "-" << op->errorMessage();
+ kWarning() << "Account"
+ << m_path
+ << "cannot become ready:"
+ << op->errorName()
+ << "-"
+ << op->errorMessage();
return;
}
// Check that this Account is set up in nepomuk.
doNepomukSetup();
- // Once the nepomuk setup is complete, do the Akonadi setup.
- doAkonadiSetup();
+ // Connect to signals that indicate the account is online.
+ connect(m_account.data(),
+ SIGNAL(haveConnectionChanged(bool)),
+ SLOT(onHaveConnectionChanged(bool)));
}
void TelepathyAccount::doNepomukSetup()
{
+ // FIXME: Move getting hold of "me" into the parent class so we
+ // don't repeat it for each account?
// Get the PIMO:Person for "me" from nepomuk
+ // FIXME: Port to new OSCAF standard for accessing "me" as soon as it
+ // becomes available.
Nepomuk::Thing me(QUrl::fromEncoded("nepomuk:/myself"));
+ // FIXME: We should not create "me" if it doesn't exist once the above
+ // fixme has been dealt with.
if (!me.exists()) {
// The PIMO:Person representing "me" does not exist, so we need to create it.
me.addType(Nepomuk::Vocabulary::PIMO::Person());
}
+ Nepomuk::PersonContact mePersonContact;
+
// Loop through all the grounding instances of this person
Q_FOREACH (Nepomuk::Resource resource, me.groundingOccurrences()) {
// See if this grounding instance is of type nco:contact.
- if (resource.hasType(Nepomuk::Vocabulary::NCO::Contact())) {
- // we have an NCO:Contact. See if it is for this Telepathy Account.
- if (resource.hasProperty(Nepomuk::Vocabulary::TPACCOUNT::identifier())) {
- // we have a tpaccount property. See if it is the same as the path of this account.
- if (resource.property(Nepomuk::Vocabulary::TPACCOUNT::identifier()).toString() == m_path) {
- // Nepomuk has this account already. Don't need to do anything.
- return;
- }
- }
+ if (resource.hasType(Nepomuk::Vocabulary::NCO::PersonContact())) {
+ // FIXME: We are going to assume the first NCO::PersonContact is the
+ // right one. Can we improve this?
+ mePersonContact = resource;
+ break;
}
}
- kDebug() << "Telepathy Account" << m_path << "does not exist is nepomuk yet. Add it.";
- // Nepomuk doesn't yet have this account. Add it.
- Nepomuk::PersonContact contact(m_path);
- contact.setLabel(m_account->nickname());
+ if (!mePersonContact.exists()) {
+ kWarning() << "Me NCO:PersonContact doesn't exist. Creating it...";
+ // FIXME: We shouldn't create this person contact, but for now we will
+ // to ease development :) (see above comments)
+ mePersonContact = Nepomuk::PersonContact("nepomuk:/myself-person-contact");
+ me.addGroundingOccurrence(mePersonContact);
+ }
+
+ Nepomuk::IMAccount imAccount;
+
+ imAccount = getNepomukImAccount(mePersonContact);
- me.addProperty(Nepomuk::Vocabulary::NCO::PersonContact(), contact);
+ // 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);
+ }
}
-void TelepathyAccount::doAkonadiSetup()
+Nepomuk::IMAccount TelepathyAccount::getNepomukImAccount(const Nepomuk::PersonContact &mePersonContact)
{
- // Loop over the list of Agents to find one with the unique identifier of this account and with
- // the correct type.
- Akonadi::AgentInstance::List agentList = Akonadi::AgentManager::self()->instances();
-
- foreach (Akonadi::AgentInstance agent, agentList) {
- if (agent.type().identifier() == "telepathy_contacts_resource") {
- if (agent.type().identifier() == "telepathy_contacts_resource") {
- // This is our agent. Nothing to do. Return.
- kDebug() << "This telepathy account already has a Akonadi Resource for it.";
- return;
+ // ************************************************************************
+ // Now we have got hold of "me", we
+ // can query for "my" IM Accounts.
+ 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()));
+
+ Soprano::Model *model = Nepomuk::ResourceManager::instance()->mainModel();
+
+ Soprano::QueryResultIterator it = model->executeQuery(query, Soprano::Query::QueryLanguageSparql);
+
+ while(it.next()) {
+ Nepomuk::Resource foundImAccountResource(it.binding("a").uri());
+ Nepomuk::IMAccount foundImAccount(foundImAccountResource);
+ kDebug() << "Found IM Account: " << foundImAccount;
+
+ QStringList accountIdentifiers = foundImAccount.accountIdentifiers();
+
+ if (accountIdentifiers.size() != 0) {
+ 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 we reach here, the agent doesn't exist for this account, so create an instance of it.
- kDebug() << "This telepathy account doesn't already have an Akonadi Resource for it. Create one.";
+ return Nepomuk::IMAccount();
+}
- Akonadi::AgentType type = Akonadi::AgentManager::self()->type("telepathy_contacts_resource");
- Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(type);
+void TelepathyAccount::onHaveConnectionChanged(bool haveConnection)
+{
+ /*
+ if (haveConnection) {
+ // We now have a connection to the account. Get the connection ready to use.
+ if (!m_connection.isNull()) {
+ kWarning() << "Connection should be null, but is not :/";
+ return;
+ }
- connect(job, SIGNAL(result(KJob*)), SLOT(onAgentInstanceCreateJobComplete(KJob*)));
+ m_connection = m_account->connection();
+
+ Tp::Features features;
+ features << Tp::Connection::FeatureCore
+ << Tp::Connection::FeatureSimplePresence
+ << Tp::Connection::FeatureSelfContact
+ << Tp::Connection::FeatureRoster;
+
+ connect(m_connection->becomeReady(features),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onConnectionReady(Tp::PendingOperation*)));
+ } else {
+ // Connection has gone down. Delete our pointer to it.
+ m_connection.reset();
+ }
+ */
}
-void TelepathyAccount::onAgentInstanceCreateJobComplete(KJob *job)
+void TelepathyAccount::onConnectionReady(Tp::PendingOperation *op)
{
- Akonadi::AgentInstanceCreateJob *createJob = static_cast<Akonadi::AgentInstanceCreateJob*>(job);
-
- Q_ASSERT(createJob);
- if (!createJob) {
- kWarning() << "createJob is null. This method should only be called as the result of an"
- << "Akonadi::AgentInstanceCreateJob.";
+ /*
+ if (op->isError()) {
+ kWarning() << "Getting connection ready failed.";
+ m_connection.reset();
return;
}
- // Check if the job completed successfully.
// TODO: Implement me!
+ */
}
+
+#include "telepathyaccount.moc"
+
diff --git a/kpeople/nepomuk-feeder/telepathyaccount.h b/kpeople/nepomuk-feeder/telepathyaccount.h
index 79b776a..dd1277f 100644
--- a/kpeople/nepomuk-feeder/telepathyaccount.h
+++ b/kpeople/nepomuk-feeder/telepathyaccount.h
@@ -21,10 +21,14 @@
#ifndef TELEPATHY_INTEGRATION_DAEMON_TELEPATHYACCOUNT_H
#define TELEPATHY_INTEGRATION_DAEMON_TELEPATHYACCOUNT_H
+#include "imaccount.h"
+#include "personcontact.h"
+
#include <QtCore/QObject>
#include <QtCore/QString>
#include <TelepathyQt4/Account>
+#include <TelepathyQt4/Connection>
namespace Tp {
class PendingOperation;
@@ -44,15 +48,23 @@ public:
private Q_SLOTS:
void onAccountReady(Tp::PendingOperation *op);
- void onAgentInstanceCreateJobComplete(KJob *job);
+ void onHaveConnectionChanged(bool haveConnection);
+ void onConnectionReady(Tp::PendingOperation *op);
private:
+ Q_DISABLE_COPY(TelepathyAccount);
+
void doNepomukSetup();
- void doAkonadiSetup();
+ Nepomuk::IMAccount getNepomukImAccount(const Nepomuk::PersonContact &mePersonContact);
TelepathyAccountMonitor *m_parent;
+
QString m_path;
Tp::AccountPtr m_account;
+
+ Tp::ConnectionPtr m_connection;
+
+ Nepomuk::IMAccount accountResource;
};
diff --git a/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp b/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp
index 944b8aa..4d49f1b 100644
--- a/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp
+++ b/kpeople/nepomuk-feeder/telepathyaccountmonitor.cpp
@@ -1,7 +1,8 @@
/*
* This file is part of telepathy-integration-daemon
*
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009-2010 Collabora Ltd. <info at collabora.co.uk>
+ * @author George Goldberg <george.goldberg at collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,70 +20,71 @@
*/
#include "telepathyaccountmonitor.h"
+#include <Nepomuk/ResourceManager>
#include <KDebug>
-#include <KGlobal>
+
+#include <QtCore/QString>
#include <TelepathyQt4/PendingReady>
TelepathyAccountMonitor::TelepathyAccountMonitor(QObject *parent)
- : QObject(parent),
- m_config(KGlobal::config())
+ : QObject(parent)
{
- // Initialise the config group
- m_contactResourcesConfigGroup = m_config->group("contact_resources");
-
// Create an instance of the AccountManager and start to get it ready.
m_accountManager = Tp::AccountManager::create();
connect(m_accountManager->becomeReady(),
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onAccountManagerReady(Tp::PendingOperation*)));
-}
-TelepathyAccountMonitor::~TelepathyAccountMonitor()
-{
+ Nepomuk::ResourceManager *nepomukResourceManager = Nepomuk::ResourceManager::instance();
+
+ connect(nepomukResourceManager,
+ SIGNAL(error(QString, int)),
+ SLOT(onNepomukError(QString, int)));
}
-Tp::AccountManagerPtr TelepathyAccountMonitor::accountManager()
+TelepathyAccountMonitor::~TelepathyAccountMonitor()
{
- return m_accountManager;
}
void TelepathyAccountMonitor::onAccountManagerReady(Tp::PendingOperation *op)
{
if (op->isError()) {
kWarning() << "Account manager cannot become ready:"
- << op->errorName() << "-" << op->errorMessage();
+ << op->errorName()
+ << "-"
+ << op->errorMessage();
return;
}
- // Account Manager is now ready. We should watch for any changes in the Accounts List.
+ // Account Manager is now ready. We should watch for any new accounts being created.
connect(m_accountManager.data(),
SIGNAL(accountCreated(const QString&)),
SLOT(onAccountCreated(const QString&)));
- connect(m_accountManager.data(),
- SIGNAL(accountRemoved(const QString&)),
- SLOT(onAccountRemoved(const QString&)));
- foreach (const QString &path, m_accountManager->validAccountPaths()) {
+ // Take into account (ha ha) the accounts that already existed when the AM object became ready.
+ foreach (const QString &path, m_accountManager->allAccountPaths()) {
onAccountCreated(path);
}
}
void TelepathyAccountMonitor::onAccountCreated(const QString &path)
{
- m_accounts.insert(path, new TelepathyAccount(path, this));
+ new TelepathyAccount(path, this);
}
-void TelepathyAccountMonitor::onAccountRemoved(const QString &path)
+Tp::AccountManagerPtr TelepathyAccountMonitor::accountManager() const
{
- Q_UNUSED(path);
- // TODO: Implement me!
+ return m_accountManager;
}
-KConfigGroup TelepathyAccountMonitor::contactResourcesConfigGroup()
+void TelepathyAccountMonitor::onNepomukError(const QString &uri, int errorCode)
{
- return m_contactResourcesConfigGroup;
+ kDebug() << "A Nepomuk Error occurred:" << uri << errorCode;
}
+
+#include "telepathyaccountmonitor.moc"
+
diff --git a/kpeople/nepomuk-feeder/telepathyaccountmonitor.h b/kpeople/nepomuk-feeder/telepathyaccountmonitor.h
index fd7e4e8..5814dd7 100644
--- a/kpeople/nepomuk-feeder/telepathyaccountmonitor.h
+++ b/kpeople/nepomuk-feeder/telepathyaccountmonitor.h
@@ -1,7 +1,8 @@
/*
* This file is part of telepathy-integration-daemon
*
- * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2009-2010 Collabora Ltd. <info at collabora.co.uk>
+ * @author George Goldberg <george.goldberg at collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,9 +24,6 @@
#include "telepathyaccount.h"
-#include <KConfigGroup>
-#include <KSharedConfig>
-
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QString>
@@ -36,6 +34,10 @@ namespace Tp {
class PendingOperation;
}
+/**
+ * Monitors the Telepathy Account Manager, ensuring that whenever an account is created, a
+ * TelepathyAccount object is created to monitor it.
+ */
class TelepathyAccountMonitor : public QObject
{
Q_OBJECT
@@ -44,20 +46,18 @@ public:
explicit TelepathyAccountMonitor(QObject *parent = 0);
~TelepathyAccountMonitor();
- Tp::AccountManagerPtr accountManager();
-
- KConfigGroup contactResourcesConfigGroup();
+ Tp::AccountManagerPtr accountManager() const;
private Q_SLOTS:
void onAccountManagerReady(Tp::PendingOperation *op);
void onAccountCreated(const QString &path);
- void onAccountRemoved(const QString &path);
+ void onNepomukError(const QString &uri, int errorCode);
private:
+ Q_DISABLE_COPY(TelepathyAccountMonitor);
+
Tp::AccountManagerPtr m_accountManager;
- QMap<QString, TelepathyAccount*> m_accounts;
- KSharedConfigPtr m_config;
- KConfigGroup m_contactResourcesConfigGroup;
+
};
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list