diff -Nru libkpeople-0+git20131228+r406/debian/bzr-builder.manifest libkpeople-0.99.0+git20140105+r425/debian/bzr-builder.manifest --- libkpeople-0+git20131228+r406/debian/bzr-builder.manifest 2013-12-28 17:17:57.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/debian/bzr-builder.manifest 2014-01-05 14:37:10.000000000 +0000 @@ -1,3 +1,3 @@ -# bzr-builder format 0.3 deb-version 0+git20131228+r406-0ubuntu1 -lp:~blue-shell/blue-shell/libkpeople revid:git-v1:2c8da35b79681cba616e39a544247c34fb68f409 +# bzr-builder format 0.3 deb-version 0.99.0+git20140105+r425-0ubuntu1 +lp:~blue-shell/blue-shell/libkpeople revid:git-v1:ddf7b15ac9d24aa49df9e4b646b016733a4c6a54 merge packaging lp:~blue-shell/blue-shell/libkpeople-ubuntu revid:david@davidedmundson.co.uk-20131227094700-bxfo65gipi35m6oa diff -Nru libkpeople-0+git20131228+r406/debian/changelog libkpeople-0.99.0+git20140105+r425/debian/changelog --- libkpeople-0+git20131228+r406/debian/changelog 2013-12-28 17:17:57.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/debian/changelog 2014-01-05 14:37:10.000000000 +0000 @@ -1,8 +1,8 @@ -libkpeople (0+git20131228+r406-0ubuntu1~ubuntu13.04.1) raring; urgency=low +libkpeople (0.99.0+git20140105+r425-0ubuntu1~ubuntu13.04.1) raring; urgency=low * Auto build. - -- Launchpad Package Builder Sat, 28 Dec 2013 17:17:57 +0000 + -- David Edmundson Sun, 05 Jan 2014 14:37:10 +0000 libkpeople (0-0ubuntu1) UNRELEASED; urgency=low diff -Nru libkpeople-0+git20131228+r406/src/CMakeLists.txt libkpeople-0.99.0+git20140105+r425/src/CMakeLists.txt --- libkpeople-0+git20131228+r406/src/CMakeLists.txt 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/CMakeLists.txt 2014-01-05 14:37:08.000000000 +0000 @@ -16,7 +16,7 @@ kde4_add_library (kpeople SHARED global.cpp metacontact.cpp - abstractpersonplugin.cpp + abstractpersonaction.cpp persondata.cpp # matchessolver.cpp # match.cpp @@ -55,7 +55,7 @@ personsmodel.h persondata.h kpeople_export.h - abstractpersonplugin.h + abstractpersonaction.h basepersonsdatasource.h allcontactsmonitor.h contactmonitor.h @@ -64,7 +64,7 @@ ) install (FILES - KPeople/AbstractPersonPlugin + KPeople/AbstractPersonAction KPeople/AllContactsMonitor KPeople/BasePersonsDataSource KPeople/ContactMonitor diff -Nru libkpeople-0+git20131228+r406/src/KPeople/AbstractPersonAction libkpeople-0.99.0+git20140105+r425/src/KPeople/AbstractPersonAction --- libkpeople-0+git20131228+r406/src/KPeople/AbstractPersonAction 1970-01-01 00:00:00.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/KPeople/AbstractPersonAction 2014-01-05 14:37:08.000000000 +0000 @@ -0,0 +1 @@ +#include diff -Nru libkpeople-0+git20131228+r406/src/KPeople/AbstractPersonPlugin libkpeople-0.99.0+git20140105+r425/src/KPeople/AbstractPersonPlugin --- libkpeople-0+git20131228+r406/src/KPeople/AbstractPersonPlugin 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/KPeople/AbstractPersonPlugin 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -#include diff -Nru libkpeople-0+git20131228+r406/src/abstractpersonaction.cpp libkpeople-0.99.0+git20140105+r425/src/abstractpersonaction.cpp --- libkpeople-0+git20131228+r406/src/abstractpersonaction.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/abstractpersonaction.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -0,0 +1,39 @@ +/* + Copyright (C) 2013 David Edmundson + + 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 + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#include "abstractpersonaction.h" + +#include +#include + +using namespace KPeople; + +AbstractPersonAction::AbstractPersonAction(QObject *parent) : QObject (parent) +{ +} + +QList< QAction* > AbstractPersonAction::actionsForPerson(const KABC::Addressee &person, + const KABC::AddresseeList &contacts, + QObject *parent) const +{ + Q_UNUSED(person); + Q_UNUSED(contacts); + Q_UNUSED(parent); + return QList(); +} diff -Nru libkpeople-0+git20131228+r406/src/abstractpersonaction.h libkpeople-0.99.0+git20140105+r425/src/abstractpersonaction.h --- libkpeople-0+git20131228+r406/src/abstractpersonaction.h 1970-01-01 00:00:00.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/abstractpersonaction.h 2014-01-05 14:37:08.000000000 +0000 @@ -0,0 +1,52 @@ +/* + Copyright (C) 2013 David Edmundson + + 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 + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef ABSTRACT_PERSON_ACTION_H +#define ABSTRACT_PERSON_ACTION_H + +class PersonData; + +#include +#include + +#include "kpeople_export.h" +#include "persondata.h" + +namespace KPeople +{ + +class KPEOPLE_EXPORT AbstractPersonAction : public QObject +{ + Q_OBJECT +public: + AbstractPersonAction(QObject *parent); + /** A list of actions that can be executed for a contact + * Disabled actions should not be added + * + * @arg person the person KABC::Addressee object + * @arg contacts person's list of subcontacts + * @arg parent parent object for newly created actions + */ + virtual QList actionsForPerson(const KABC::Addressee &person, + const KABC::AddresseeList &contacts, + QObject *parent) const = 0; +}; + +} + +#endif diff -Nru libkpeople-0+git20131228+r406/src/abstractpersonplugin.cpp libkpeople-0.99.0+git20140105+r425/src/abstractpersonplugin.cpp --- libkpeople-0+git20131228+r406/src/abstractpersonplugin.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/abstractpersonplugin.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* - Copyright (C) 2013 David Edmundson - - 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 - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "abstractpersonplugin.h" - -#include -#include - -using namespace KPeople; - -AbstractPersonPlugin::AbstractPersonPlugin(QObject *parent) : QObject (parent) -{ -} - -QList< QAction* > AbstractPersonPlugin::actionsForPerson(const KABC::Addressee &person, - const KABC::AddresseeList &contacts, - QObject *parent) const -{ - Q_UNUSED(person); - Q_UNUSED(contacts); - Q_UNUSED(parent); - return QList(); -} diff -Nru libkpeople-0+git20131228+r406/src/abstractpersonplugin.h libkpeople-0.99.0+git20140105+r425/src/abstractpersonplugin.h --- libkpeople-0+git20131228+r406/src/abstractpersonplugin.h 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/abstractpersonplugin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - Copyright (C) 2013 David Edmundson - - 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 - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef ABSTRACT_PERSON_PLUGIN_H -#define ABSTRACT_PERSON_PLUGIN_H - -class PersonData; - -#include -#include - -#include "kpeople_export.h" -#include "persondata.h" - -namespace KPeople -{ - -class KPEOPLE_EXPORT AbstractPersonPlugin : public QObject -{ - Q_OBJECT -public: - AbstractPersonPlugin(QObject *parent); - /** A list of actions that can be executed for a contact - * Disabled actions should not be added - * - * @arg person the person KABC::Addressee object - * @arg contacts person's list of subcontacts - * @arg parent parent object for newly created actions - */ - virtual QList actionsForPerson(const KABC::Addressee &person, - const KABC::AddresseeList &contacts, - QObject *parent) const = 0; -}; - -} - -#endif diff -Nru libkpeople-0+git20131228+r406/src/allcontactsmonitor.h libkpeople-0.99.0+git20140105+r425/src/allcontactsmonitor.h --- libkpeople-0+git20131228+r406/src/allcontactsmonitor.h 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/allcontactsmonitor.h 2014-01-05 14:37:08.000000000 +0000 @@ -32,19 +32,41 @@ class AllContactsMonitorPrivate; +/** + * This class should be subclassed by each datasource and return a list of + * all contacts that the datasource knows about. + * + * Subclasses are expected to be asynchronous + * + */ class KPEOPLE_EXPORT AllContactsMonitor : public QObject { Q_OBJECT public: explicit AllContactsMonitor(); //TODO make protected? this isn't useful unless subclassed virtual ~AllContactsMonitor(); + + /** + * Returns all currently loaded contacts + */ virtual KABC::Addressee::Map contacts(); -// bool isInitialFetchComplete(); //make pure virtual or have a protected setter? +// bool isInitialFetchComplete(); Q_SIGNALS: // void initialFetchComplete(); + /** + * DataSources should emit this whenever a known contact changes + */ void contactChanged(const QString &contactId, const KABC::Addressee &contact); + + /** + * DataSources should emit this whenever a contact is added + */ void contactAdded(const QString &contactId, const KABC::Addressee &contact); + + /** + * DataSources should emit this whenever a contact is removed and they are no longer able to supply up-to-date data on a contact + */ void contactRemoved(const QString &contactId); // bool m_initialFetchComplete; diff -Nru libkpeople-0+git20131228+r406/src/autotests/fakecontactsource.cpp libkpeople-0.99.0+git20140105+r425/src/autotests/fakecontactsource.cpp --- libkpeople-0+git20131228+r406/src/autotests/fakecontactsource.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/autotests/fakecontactsource.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -19,14 +19,9 @@ #include "fakecontactsource.h" -FakeContactSource::FakeContactSource(QObject* parent, const QVariantList& args): BasePersonsDataSource(parent, args) +FakeContactSource::FakeContactSource(QObject *parent, const QVariantList &args) + : BasePersonsDataSource(parent, args) { - -} - -FakeAllContactsMonitor::FakeAllContactsMonitor() -{ - } QString FakeContactSource::sourcePluginId() const @@ -34,13 +29,25 @@ return "fakesource://"; } - KPeople::AllContactsMonitor* FakeContactSource::createAllContactsMonitor() { return new FakeAllContactsMonitor(); } +void FakeContactSource::changeContact1Email() +{ + qobject_cast(allContactsMonitor().data())->changeContact1Email(); +} + + +//---------------------------------------------------------------------------- + + +FakeAllContactsMonitor::FakeAllContactsMonitor() +{ +} + KABC::Addressee::Map FakeAllContactsMonitor::contacts() { KABC::Addressee::Map contacts; @@ -69,11 +76,6 @@ return contacts; } -void FakeContactSource::changeContact1Email() -{ - qobject_cast(allContactsMonitor().data())->changeContact1Email(); -} - void FakeAllContactsMonitor::changeContact1Email() { KABC::Addressee contact1 = contacts()["fakesource://contact1"]; diff -Nru libkpeople-0+git20131228+r406/src/autotests/fakecontactsource.h libkpeople-0.99.0+git20140105+r425/src/autotests/fakecontactsource.h --- libkpeople-0+git20131228+r406/src/autotests/fakecontactsource.h 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/autotests/fakecontactsource.h 2014-01-05 14:37:08.000000000 +0000 @@ -32,10 +32,10 @@ void changeContact1Email(); protected: virtual KPeople::AllContactsMonitor* createAllContactsMonitor(); - -private: }; +//---------------------------------------------------------------------------- + class FakeAllContactsMonitor : public KPeople::AllContactsMonitor { Q_OBJECT diff -Nru libkpeople-0+git20131228+r406/src/basepersonsdatasource.h libkpeople-0.99.0+git20140105+r425/src/basepersonsdatasource.h --- libkpeople-0+git20131228+r406/src/basepersonsdatasource.h 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/basepersonsdatasource.h 2014-01-05 14:37:08.000000000 +0000 @@ -43,10 +43,14 @@ BasePersonsDataSource(QObject *parent, const QVariantList &args = QVariantList()); virtual ~BasePersonsDataSource(); - //fetch and monitor all contacts + /** + * Return a ref counted AllContactMonitor which lists and monitors all contacts from a source + */ AllContactsMonitorPtr allContactsMonitor(); - //fetch and monitor a single contact + /** + * Return a ref counted watcher for a single contact + */ ContactMonitorPtr contactMonitor(const QString &contactId); /** diff -Nru libkpeople-0+git20131228+r406/src/contactmonitor.h libkpeople-0.99.0+git20140105+r425/src/contactmonitor.h --- libkpeople-0+git20131228+r406/src/contactmonitor.h 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/contactmonitor.h 2014-01-05 14:37:08.000000000 +0000 @@ -33,17 +33,40 @@ struct ContactMonitorPrivate; +/** + * This class loads data for a single contact from a datasource. + * + * Datasources should subclass this and call setContact() when the contact loads or changes. + * It is used for optimising performance over loading all contacts and filtering the results. + * Subclasses are expected to be asyncronous in loading data. + * + */ class KPEOPLE_EXPORT ContactMonitor: public QObject { Q_OBJECT public: ContactMonitor(const QString &contactId); virtual ~ContactMonitor(); + + /** + * The ID of the contact being loaded + */ QString contactId() const; + + /** + * The currently loaded information on this contact. + */ KABC::Addressee contact() const; Q_SIGNALS: + /** + * Emitted whenever the contact changes + */ void contactChanged(); protected: + /** + * Sets or updates the contact and emits contactChanged + * Subclasses should call this when data is loaded or changes + */ void setContact(const KABC::Addressee &contact); private: Q_DISABLE_COPY(ContactMonitor) diff -Nru libkpeople-0+git20131228+r406/src/defaultcontactmonitor_p.h libkpeople-0.99.0+git20140105+r425/src/defaultcontactmonitor_p.h --- libkpeople-0+git20131228+r406/src/defaultcontactmonitor_p.h 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/defaultcontactmonitor_p.h 2014-01-05 14:37:08.000000000 +0000 @@ -29,8 +29,11 @@ using namespace KPeople; -// if plugins don't implement a ContactWatcher, we repurpose the whole model, and single out changes for one contact -// ideally plugins (especially slow ones) will implement their own contact monitor which fetches just the one contact +/* + * If plugins don't implement a ContactWatcher, we repurpose the whole model, and single out changes for one contact + * ideally plugins (especially slow ones) will implement their own contact monitor. +*/ + class DefaultContactMonitor : public ContactMonitor { Q_OBJECT diff -Nru libkpeople-0+git20131228+r406/src/global.cpp libkpeople-0.99.0+git20140105+r425/src/global.cpp --- libkpeople-0+git20131228+r406/src/global.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/global.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -23,7 +23,7 @@ #include "personmanager_p.h" #include "personpluginmanager_p.h" -#include "abstractpersonplugin.h" +#include "abstractpersonaction.h" #include #include @@ -46,7 +46,7 @@ QObject *parent) { QList actions; - Q_FOREACH(KPeople::AbstractPersonPlugin *plugin, PersonPluginManager::personPlugins()) { + Q_FOREACH(KPeople::AbstractPersonAction *plugin, PersonPluginManager::actions()) { actions << plugin->actionsForPerson(person, contacts, parent); } diff -Nru libkpeople-0+git20131228+r406/src/metacontact.cpp libkpeople-0.99.0+git20140105+r425/src/metacontact.cpp --- libkpeople-0+git20131228+r406/src/metacontact.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/metacontact.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -246,7 +246,7 @@ d->personAddressee.setTimeZone(contact.timeZone()); } - if (!d->personAddressee.geo().isValid() && contact.timeZone().isValid()) { + if (!d->personAddressee.geo().isValid() && contact.geo().isValid()) { d->personAddressee.setGeo(contact.geo()); } @@ -287,9 +287,12 @@ const QString &contactPresence = contact.custom("telepathy", "presence"); const QString ¤tPersonPresence = d->personAddressee.custom("telepathy", "presence"); + // FIXME This needs to be redone when presence changes if (!contactPresence.isEmpty()) { if (KPeople::presenceSortPriority(contactPresence) < KPeople::presenceSortPriority(currentPersonPresence)) { d->personAddressee.insertCustom("telepathy", "presence", contactPresence); + d->personAddressee.insertCustom("telepathy", "contactId", contact.custom("telepathy", "contactId")); + d->personAddressee.insertCustom("telepathy", "accountPath", contact.custom("telepathy", "accountPath")); } } diff -Nru libkpeople-0+git20131228+r406/src/persondata.cpp libkpeople-0.99.0+git20140105+r425/src/persondata.cpp --- libkpeople-0+git20131228+r406/src/persondata.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/persondata.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -102,6 +102,10 @@ ContactMonitor *watcher = qobject_cast(sender()); - d->metaContact.updateContact(watcher->contactId(), watcher->contact()); + if (d->metaContact.contactIds().contains(watcher->contactId())) { + d->metaContact.updateContact(watcher->contactId(), watcher->contact()); + } else { + d->metaContact.insertContact(watcher->contactId(), watcher->contact()); + } Q_EMIT dataChanged(); } diff -Nru libkpeople-0+git20131228+r406/src/personmanager.cpp libkpeople-0.99.0+git20140105+r425/src/personmanager.cpp --- libkpeople-0+git20131228+r406/src/personmanager.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/personmanager.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -64,8 +64,9 @@ PersonManager::PersonManager(const QString &databasePath, QObject *parent): QObject(parent), - m_db(QSqlDatabase::addDatabase("QSQLITE3")) -{ m_db.setDatabaseName(databasePath); + m_db(QSqlDatabase::addDatabase("QSQLITE")) +{ + m_db.setDatabaseName(databasePath); m_db.open(); m_db.exec("CREATE TABLE IF NOT EXISTS persons (contactID VARCHAR UNIQUE NOT NULL, personID INT NOT NULL)"); m_db.exec("CREATE INDEX IF NOT EXISTS contactIdIndex ON persons (contactId)"); diff -Nru libkpeople-0+git20131228+r406/src/personpluginmanager.cpp libkpeople-0.99.0+git20140105+r425/src/personpluginmanager.cpp --- libkpeople-0+git20131228+r406/src/personpluginmanager.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/personpluginmanager.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -20,7 +20,7 @@ #include "personpluginmanager_p.h" #include "basepersonsdatasource.h" -#include "abstractpersonplugin.h" +#include "abstractpersonaction.h" #include #include @@ -36,7 +36,7 @@ public: PersonPluginManagerPrivate(); ~PersonPluginManagerPrivate(); - QList personPlugins; + QList actionPlugins; QHash dataSourcePlugins; }; @@ -50,16 +50,16 @@ if (dataSource) { dataSourcePlugins[dataSource->sourcePluginId()] = dataSource; } else { - kWarning() << "Failed to create data source"; + kWarning() << "Failed to create data source " << service->name() << service->path(); } } KService::List personPluginList = KServiceTypeTrader::self()->query(QLatin1String("KPeople/Plugin")); Q_FOREACH(const KService::Ptr &service, personPluginList) { - AbstractPersonPlugin *plugin = service->createInstance(0); + AbstractPersonAction *plugin = service->createInstance(0); if (plugin) { qDebug() << "found plugin" << service->name(); - personPlugins << plugin; + actionPlugins << plugin; } } } @@ -67,7 +67,7 @@ PersonPluginManagerPrivate::~PersonPluginManagerPrivate() { qDeleteAll(dataSourcePlugins); - qDeleteAll(personPlugins); + qDeleteAll(actionPlugins); } @@ -88,7 +88,7 @@ return s_instance->dataSourcePlugins[sourceId]; } -QList PersonPluginManager::personPlugins() +QList PersonPluginManager::actions() { - return s_instance->personPlugins; + return s_instance->actionPlugins; } diff -Nru libkpeople-0+git20131228+r406/src/personpluginmanager_p.h libkpeople-0.99.0+git20140105+r425/src/personpluginmanager_p.h --- libkpeople-0+git20131228+r406/src/personpluginmanager_p.h 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/personpluginmanager_p.h 2014-01-05 14:37:08.000000000 +0000 @@ -30,7 +30,7 @@ namespace KPeople { -class AbstractPersonPlugin; +class AbstractPersonAction; class BasePersonsDataSource; class KPEOPLE_EXPORT PersonPluginManager @@ -38,7 +38,7 @@ public: static QList dataSourcePlugins(); static BasePersonsDataSource* dataSource(const QString &sourceId); - static QList personPlugins(); + static QList actions(); /** diff -Nru libkpeople-0+git20131228+r406/src/personsmodel.cpp libkpeople-0.99.0+git20140105+r425/src/personsmodel.cpp --- libkpeople-0+git20131228+r406/src/personsmodel.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/personsmodel.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -139,6 +139,9 @@ QModelIndex PersonsModel::index(int row, int column, const QModelIndex &parent) const { + if (row < 0 || column < 0 || row >= rowCount(parent)) { + return QModelIndex(); + } //top level items have internalId -1. Anything >=0 is the row of the top level item if (!parent.isValid()) { return createIndex(row, column, -1); @@ -149,7 +152,7 @@ QModelIndex PersonsModel::parent(const QModelIndex &childIndex) const { - if (childIndex.internalId() == -1) { + if (childIndex.internalId() == -1 || !childIndex.isValid()) { return QModelIndex(); } @@ -178,7 +181,7 @@ contacts[contact] = addresseeMap.take(contact); } } - if (!addresseeMap.isEmpty()) { + if (!contacts.isEmpty()) { addPerson(MetaContact(key, contacts)); } } @@ -206,10 +209,9 @@ kWarning() << "Source emitted contactAdded for a contact we already know about " << contactId; onContactChanged(contactId, contact); } else { - //NOTE this is not quite ideal. we should do an update inside the begin/end insert rows - //in practice as everything is all in one thread, everything should be fine - int newContactPos = mc.insertContact(contactId, contact); - beginInsertRows(index(d->personIds.indexOf(personId), 0), newContactPos, newContactPos); + int newContactPos = mc.contacts().size(); + beginInsertRows(index(d->personIds.indexOf(personId)), newContactPos, newContactPos); + mc.insertContact(contactId, contact); endInsertRows(); personChanged(personId); } @@ -227,7 +229,7 @@ const QModelIndex contactIndex = index(row, 0, - index(d->personIds.indexOf(personId), 0)); + index(d->personIds.indexOf(personId))); Q_EMIT dataChanged(contactIndex, contactIndex); @@ -273,12 +275,13 @@ personChanged(oldPersonId); } - //if the person is already in the model, add the contact to it + //if the new person is already in the model, add the contact to it if (d->personIds.contains(newPersonId)) { int newContactPos = d->metacontacts[newPersonId].contacts().size(); beginInsertRows(index(d->personIds.indexOf(newPersonId), 0), newContactPos, newContactPos); d->metacontacts[newPersonId].insertContact(contactId, contact); endInsertRows(); + personChanged(newPersonId); } else { //if the person is not in the model, create a new person and insert it KABC::Addressee::Map contacts; contacts[contactId] = contact; @@ -339,9 +342,9 @@ { Q_D(const PersonsModel); int row = d->personIds.indexOf(personId); - const QModelIndex contactIndex = index(row); - if(row >=0 ) { - dataChanged(contactIndex, contactIndex); + if (row >= 0) { + const QModelIndex personIndex = index(row); + dataChanged(personIndex, personIndex); } } diff -Nru libkpeople-0+git20131228+r406/src/plugins/akonadi/akonadidatasource.cpp libkpeople-0.99.0+git20140105+r425/src/plugins/akonadi/akonadidatasource.cpp --- libkpeople-0+git20131228+r406/src/plugins/akonadi/akonadidatasource.cpp 2013-12-28 17:17:54.000000000 +0000 +++ libkpeople-0.99.0+git20140105+r425/src/plugins/akonadi/akonadidatasource.cpp 2014-01-05 14:37:08.000000000 +0000 @@ -164,21 +164,18 @@ ContactMonitor(contactId), m_monitor(monitor) { - //optimisation, base class could copy across from the model if the model exists + //TODO: optimisation, base class could copy across from the model if the model exists //then we should check if contact is already set to something and avoid the initial fetch - //FIXME This is a bug in the sending code. See Fixme in PersonData - if (contactId.startsWith("akonadi://")) { - - m_item = Item::fromUrl(QUrl(contactId)); - ItemFetchJob* itemFetchJob = new ItemFetchJob(m_item); - itemFetchJob->fetchScope().fetchFullPayload(); - connect(itemFetchJob, SIGNAL(finished(KJob*)), SLOT(onContactFetched(KJob*))); - - //monitor here too - m_monitor->setItemMonitored(m_item, true); - connect(m_monitor, SIGNAL(itemChanged(Akonadi::Item,QSet)), SLOT(onContactChanged(Akonadi::Item))); - } + //load the contact initially + m_item = Item::fromUrl(QUrl(contactId)); + ItemFetchJob* itemFetchJob = new ItemFetchJob(m_item); + itemFetchJob->fetchScope().fetchFullPayload(); + connect(itemFetchJob, SIGNAL(finished(KJob*)), SLOT(onContactFetched(KJob*))); + + //then watch for that item changing + m_monitor->setItemMonitored(m_item, true); + connect(m_monitor, SIGNAL(itemChanged(Akonadi::Item,QSet)), SLOT(onContactChanged(Akonadi::Item))); } AkonadiContact::~AkonadiContact()