Commit 5a62bfa1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

GIT_SILENT: coding style

parent 7c63fb4a
......@@ -143,10 +143,10 @@ MailDispatcherAgent::MailDispatcherAgent(const QString &id)
new MailDispatcherAgentAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"),
Settings::self(), QDBusConnection::ExportAdaptors);
Settings::self(), QDBusConnection::ExportAdaptors);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/MailDispatcherAgent"),
this, QDBusConnection::ExportAdaptors);
this, QDBusConnection::ExportAdaptors);
QString service = QStringLiteral("org.freedesktop.Akonadi.MailDispatcherAgent");
if (Akonadi::ServerManager::hasInstanceIdentifier()) {
service += QLatin1Char('.') + Akonadi::ServerManager::instanceIdentifier();
......
......@@ -68,7 +68,7 @@ NewMailNotifierAgent::NewMailNotifierAgent(const QString &id)
mDefaultIconName = QStringLiteral("kmail");
QDBusConnection::sessionBus().registerObject(QStringLiteral("/NewMailNotifierAgent"),
this, QDBusConnection::ExportAdaptors);
this, QDBusConnection::ExportAdaptors);
QString service = QStringLiteral("org.freedesktop.Akonadi.NewMailNotifierAgent");
if (Akonadi::ServerManager::hasInstanceIdentifier()) {
......
......@@ -37,7 +37,8 @@
GoogleResourceMigrator::GoogleResourceMigrator()
: MigratorBase(QLatin1String("googleresourcemigrator"))
{}
{
}
QString GoogleResourceMigrator::displayName() const
{
......@@ -56,7 +57,6 @@ bool GoogleResourceMigrator::shouldAutostart() const
}
namespace {
static const QStringView akonadiGoogleCalendarResource = {u"akonadi_googlecalendar_resource"};
static const QStringView akonadiGoogleContactsResource = {u"akonadi_googlecontacts_resource"};
static const QStringView akonadiGoogleGroupwareResource = {u"akonadi_google_resource"};
......@@ -64,7 +64,7 @@ static const QStringView akonadiGoogleGroupwareResource = {u"akonadi_google_reso
bool isLegacyGoogleResource(const Akonadi::AgentInstance &instance)
{
return instance.type().identifier() == akonadiGoogleCalendarResource
|| instance.type().identifier() == akonadiGoogleContactsResource;
|| instance.type().identifier() == akonadiGoogleContactsResource;
}
bool isGoogleGroupwareResource(const Akonadi::AgentInstance &instance)
......@@ -165,13 +165,13 @@ void removeInstanceAndWait(const Akonadi::AgentInstance &instance)
QEventLoop loop;
QObject::connect(&watcher, &QDBusServiceWatcher::serviceUnregistered,
&loop, [&loop, &instance]() {
qCDebug(MIGRATION_LOG) << "GoogleResourceMigrator: resource" << instance.identifier() << "has disappeared from DBus";
loop.quit();
});
qCDebug(MIGRATION_LOG) << "GoogleResourceMigrator: resource" << instance.identifier() << "has disappeared from DBus";
loop.quit();
});
QTimer::singleShot(std::chrono::seconds(20), &loop, [&loop, &instance]() {
qCWarning(MIGRATION_LOG) << "GoogleResourceMigrator: timeout while waiting for resource" << instance.identifier() << "to be removed";
loop.quit();
});
qCWarning(MIGRATION_LOG) << "GoogleResourceMigrator: timeout while waiting for resource" << instance.identifier() << "to be removed";
loop.quit();
});
Akonadi::AgentManager::self()->removeInstance(instance);
qCDebug(MIGRATION_LOG) << "GoogleResourceMigrator: waiting for" << instance.identifier() << "to disappear from DBus";
......@@ -180,7 +180,6 @@ void removeInstanceAndWait(const Akonadi::AgentInstance &instance)
qCInfo(MIGRATION_LOG) << "GoogleResourceMigrator: removed the legacy calendar resource" << instance.identifier();
}
} // namespace
void GoogleResourceMigrator::startWork()
......@@ -258,44 +257,44 @@ void GoogleResourceMigrator::migrateNextAccount()
auto job = new Akonadi::AgentInstanceCreateJob(akonadiGoogleGroupwareResource.toString(), this);
connect(job, &Akonadi::AgentInstanceCreateJob::finished,
this, [this, job, account, instances](KJob *) {
if (job->error()) {
qCWarning(MIGRATION_LOG) << "GoogleResourceMigrator: Failed to create new Google Groupware Resource:" << job->errorString();
message(Error, i18n("Failed to create a new Google Groupware Resource: %1", job->errorString()));
setMigrationState(MigratorBase::Failed);
return;
}
const auto newInstance = job->instance();
if (!migrateAccount(account, instances, newInstance)) {
qCWarning(MIGRATION_LOG) << "GoogleResourceMigrator: failed to migrate account" << account;
message(Error, i18n("Failed to migrate account %1", account));
setMigrationState(MigratorBase::Failed);
return;
}
removeLegacyInstances(account, instances);
// Reconfigure and restart the new instance
newInstance.reconfigure();
newInstance.restart();
if (instances.calendarResource.isValid() ^ instances.contactResource.isValid()) {
const auto res = instances.calendarResource.isValid()
? instances.calendarResource.identifier()
: instances.contactResource.identifier();
qCInfo(MIGRATION_LOG) << "GoogleResourceMigrator: migrated configuration from" << res
<< "to" << newInstance.identifier();
} else {
qCInfo(MIGRATION_LOG) << "GoogleResourceMigrator: migrated configuration from"
<< instances.calendarResource.identifier() << "and"
<< instances.contactResource.identifier() << "to"
<< newInstance.identifier();
}
message(Success, i18n("Migrated account %1 to new Google Groupware Resource", account));
++mMigrationsDone;
migrateNextAccount();
});
if (job->error()) {
qCWarning(MIGRATION_LOG) << "GoogleResourceMigrator: Failed to create new Google Groupware Resource:" << job->errorString();
message(Error, i18n("Failed to create a new Google Groupware Resource: %1", job->errorString()));
setMigrationState(MigratorBase::Failed);
return;
}
const auto newInstance = job->instance();
if (!migrateAccount(account, instances, newInstance)) {
qCWarning(MIGRATION_LOG) << "GoogleResourceMigrator: failed to migrate account" << account;
message(Error, i18n("Failed to migrate account %1", account));
setMigrationState(MigratorBase::Failed);
return;
}
removeLegacyInstances(account, instances);
// Reconfigure and restart the new instance
newInstance.reconfigure();
newInstance.restart();
if (instances.calendarResource.isValid() ^ instances.contactResource.isValid()) {
const auto res = instances.calendarResource.isValid()
? instances.calendarResource.identifier()
: instances.contactResource.identifier();
qCInfo(MIGRATION_LOG) << "GoogleResourceMigrator: migrated configuration from" << res
<< "to" << newInstance.identifier();
} else {
qCInfo(MIGRATION_LOG) << "GoogleResourceMigrator: migrated configuration from"
<< instances.calendarResource.identifier() << "and"
<< instances.contactResource.identifier() << "to"
<< newInstance.identifier();
}
message(Success, i18n("Migrated account %1 to new Google Groupware Resource", account));
++mMigrationsDone;
migrateNextAccount();
});
job->start();
}
......@@ -311,7 +310,7 @@ QString GoogleResourceMigrator::mergeAccountNames(const ResourceValues<QString>
}
} else if (!accountName.calendar.isEmpty()) {
return accountName.calendar;
} else if( !accountName.contacts.isEmpty()) {
} else if (!accountName.contacts.isEmpty()) {
return accountName.contacts;
}
......@@ -335,8 +334,7 @@ int GoogleResourceMigrator::mergeAccountIds(const ResourceValues<int> &accountId
return std::max(accountId.calendar, accountId.contacts);
}
bool GoogleResourceMigrator::migrateAccount(const QString &account, const Instances &oldInstances,
const Akonadi::AgentInstance &newInstance)
bool GoogleResourceMigrator::migrateAccount(const QString &account, const Instances &oldInstances, const Akonadi::AgentInstance &newInstance)
{
org::kde::Akonadi::Google::Settings resourceSettings{
Akonadi::ServerManager::self()->agentServiceName(Akonadi::ServerManager::Resource, newInstance.identifier()),
......
......@@ -54,8 +54,10 @@ private:
explicit ResourceValues() = default;
template<typename U, typename V>
ResourceValues(U &&calendar, V &&contacts)
: calendar(calendar), contacts(contacts)
{}
: calendar(calendar)
, contacts(contacts)
{
}
T calendar{};
T contacts{};
......
......@@ -73,7 +73,7 @@ public:
protected:
KJob *createAgentInstance(const QString &typeId, QObject *receiver, const char *slot);
virtual void migrationFailed(const QString &errorMsg, const Akonadi::AgentInstance &instance
= Akonadi::AgentInstance()) = 0;
= Akonadi::AgentInstance()) = 0;
Q_SIGNALS:
void message(KMigratorBase::MessageType type, const QString &msg);
......
......@@ -43,7 +43,7 @@ ContactsResource::ContactsResource(const QString &id)
ContactsResourceSettings::instance(KSharedConfig::openConfig());
new ContactsResourceSettingsAdaptor(ContactsResourceSettings::self());
QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"),
ContactsResourceSettings::self(), QDBusConnection::ExportAdaptors);
ContactsResourceSettings::self(), QDBusConnection::ExportAdaptors);
changeRecorder()->fetchCollection(true);
changeRecorder()->itemFetchScope().fetchFullPayload(true);
......
......@@ -614,8 +614,8 @@ void DavGroupwareResource::collectionChanged(const Collection &collection)
job->setProperty(QStringLiteral("calendar-color"), color.name(), QStringLiteral("http://apple.com/ns/ical/"));
}
connect(job, &KDAV::DavCollectionModifyJob::result, this, [=](KJob *job) {
onCollectionChangedFinished(job, collection);
});
onCollectionChangedFinished(job, collection);
});
job->start();
}
......
......@@ -70,7 +70,9 @@ template<typename T>
CollectionStateMonitor<T>::CollectionStateMonitor(QObject *parent, const QHash<QString, T> &stateHash, const QString &inboxId, const StateComparisonFunc &comparisonFunc, int recheckInterval)
: StateMonitorBase(parent)
, mMonitor(this)
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#if QT_VERSION < QT_VERSION_CHECK(5 \
, 14 \
, 0)
, mPending(stateHash.keys().toSet())
#else
, mPending(stateHash.keyBegin(), stateHash.keyEnd())
......
......@@ -73,10 +73,10 @@ void CalendarHandler::setupCollection(Collection &collection, const CalendarPtr
collection.setRemoteId(calendar->uid());
if (calendar->editable()) {
collection.setRights(Collection::CanChangeCollection
|Collection::CanDeleteCollection
|Collection::CanCreateItem
|Collection::CanChangeItem
|Collection::CanDeleteItem);
|Collection::CanDeleteCollection
|Collection::CanCreateItem
|Collection::CanChangeItem
|Collection::CanDeleteItem);
} else {
collection.setRights(Collection::ReadOnly);
}
......@@ -107,30 +107,30 @@ void CalendarHandler::retrieveCollections(const Collection &rootCollection)
qCDebug(GOOGLE_CALENDAR_LOG) << "Retrieving calendars...";
auto job = new CalendarFetchJob(m_settings->accountPtr(), this);
connect(job, &CalendarFetchJob::finished, this, [this, rootCollection](KGAPI2::Job *job){
if (!m_iface->handleError(job)) {
return;
}
qCDebug(GOOGLE_CALENDAR_LOG) << "Calendars retrieved";
const ObjectsList calendars = qobject_cast<CalendarFetchJob *>(job)->items();
Collection::List collections;
collections.reserve(calendars.count());
const QStringList activeCalendars = m_settings->calendars();
for (const auto &object : calendars) {
const CalendarPtr &calendar = object.dynamicCast<Calendar>();
qCDebug(GOOGLE_CALENDAR_LOG) << " -" << calendar->title() << "(" << calendar->uid() << ")";
if (!activeCalendars.contains(calendar->uid())) {
qCDebug(GOOGLE_CALENDAR_LOG) << "Skipping, not subscribed";
continue;
}
Collection collection;
setupCollection(collection, calendar);
collection.setParentCollection(rootCollection);
collections << collection;
}
m_iface->collectionsRetrievedFromHandler(collections);
});
if (!m_iface->handleError(job)) {
return;
}
qCDebug(GOOGLE_CALENDAR_LOG) << "Calendars retrieved";
const ObjectsList calendars = qobject_cast<CalendarFetchJob *>(job)->items();
Collection::List collections;
collections.reserve(calendars.count());
const QStringList activeCalendars = m_settings->calendars();
for (const auto &object : calendars) {
const CalendarPtr &calendar = object.dynamicCast<Calendar>();
qCDebug(GOOGLE_CALENDAR_LOG) << " -" << calendar->title() << "(" << calendar->uid() << ")";
if (!activeCalendars.contains(calendar->uid())) {
qCDebug(GOOGLE_CALENDAR_LOG) << "Skipping, not subscribed";
continue;
}
Collection collection;
setupCollection(collection, calendar);
collection.setParentCollection(rootCollection);
collections << collection;
}
m_iface->collectionsRetrievedFromHandler(collections);
});
}
void CalendarHandler::retrieveItems(const Collection &collection)
......@@ -184,7 +184,7 @@ void CalendarHandler::slotItemsRetrieved(KGAPI2::Job *job)
}
Item item;
item.setMimeType( mimeType() );
item.setMimeType(mimeType());
item.setParentCollection(collection);
item.setRemoteId(event->id());
item.setRemoteRevision(event->etag());
......@@ -219,23 +219,23 @@ void CalendarHandler::itemAdded(const Item &item, const Collection &collection)
auto *job = new EventCreateJob(event, collection.remoteId(), m_settings->accountPtr(), this);
job->setSendUpdates(SendUpdatesPolicy::None);
connect(job, &EventCreateJob::finished, this, [this, item](KGAPI2::Job *job){
if (!m_iface->handleError(job)) {
return;
}
Item newItem(item);
const EventPtr event = qobject_cast<EventCreateJob *>(job)->items().first().dynamicCast<Event>();
qCDebug(GOOGLE_CALENDAR_LOG) << "Event added";
newItem.setRemoteId(event->id());
newItem.setRemoteRevision(event->etag());
newItem.setGid(event->uid());
m_iface->itemChangeCommitted(newItem);
newItem.setPayload<KCalendarCore::Event::Ptr>(event.dynamicCast<KCalendarCore::Event>());
new ItemModifyJob(newItem, this);
emitReadyStatus();
});
if (!m_iface->handleError(job)) {
return;
}
Item newItem(item);
const EventPtr event = qobject_cast<EventCreateJob *>(job)->items().first().dynamicCast<Event>();
qCDebug(GOOGLE_CALENDAR_LOG) << "Event added";
newItem.setRemoteId(event->id());
newItem.setRemoteRevision(event->etag());
newItem.setGid(event->uid());
m_iface->itemChangeCommitted(newItem);
newItem.setPayload<KCalendarCore::Event::Ptr>(event.dynamicCast<KCalendarCore::Event>());
new ItemModifyJob(newItem, this);
emitReadyStatus();
});
}
void CalendarHandler::itemChanged(const Item &item, const QSet< QByteArray > &/*partIdentifiers*/)
void CalendarHandler::itemChanged(const Item &item, const QSet< QByteArray > & /*partIdentifiers*/)
{
m_iface->emitStatus(AgentBase::Running, i18nc("@info:status", "Changing event in calendar '%1'", item.parentCollection().displayName()));
qCDebug(GOOGLE_CALENDAR_LOG) << "Changing event" << item.remoteId();
......@@ -252,9 +252,9 @@ void CalendarHandler::itemsRemoved(const Item::List &items)
QStringList eventIds;
eventIds.reserve(items.count());
std::transform(items.cbegin(), items.cend(), std::back_inserter(eventIds),
[](const Item &item){
return item.remoteId();
});
[](const Item &item){
return item.remoteId();
});
qCDebug(GOOGLE_CALENDAR_LOG) << "Removing events:" << eventIds;
auto job = new EventDeleteJob(eventIds, items.first().parentCollection().remoteId(), m_settings->accountPtr(), this);
job->setProperty(ITEMS_PROPERTY, QVariant::fromValue(items));
......@@ -264,21 +264,21 @@ void CalendarHandler::itemsRemoved(const Item::List &items)
void CalendarHandler::itemsMoved(const Item::List &items, const Collection &collectionSource, const Collection &collectionDestination)
{
m_iface->emitStatus(AgentBase::Running, i18ncp("@info:status", "Moving %1 events from calendar '%2' to calendar '%3'",
"Moving %1 event from calendar '%2' to calendar '%3'",
items.count(), collectionSource.displayName(), collectionDestination.displayName()));
"Moving %1 event from calendar '%2' to calendar '%3'",
items.count(), collectionSource.displayName(), collectionDestination.displayName()));
QStringList eventIds;
eventIds.reserve(items.count());
std::transform(items.cbegin(), items.cend(), std::back_inserter(eventIds),
[](const Item &item){
return item.remoteId();
});
[](const Item &item){
return item.remoteId();
});
qCDebug(GOOGLE_CALENDAR_LOG) << "Moving events" << eventIds << "from" << collectionSource.remoteId() << "to" << collectionDestination.remoteId();
auto job = new EventMoveJob(eventIds, collectionSource.remoteId(), collectionDestination.remoteId(), m_settings->accountPtr(), this);
job->setProperty(ITEMS_PROPERTY, QVariant::fromValue(items));
connect(job, &EventMoveJob::finished, this, &CalendarHandler::slotGenericJobFinished);
}
void CalendarHandler::collectionAdded(const Collection &collection, const Collection &/*parent*/)
void CalendarHandler::collectionAdded(const Collection &collection, const Collection & /*parent*/)
{
m_iface->emitStatus(AgentBase::Running, i18nc("@info:status", "Creating calendar '%1'", collection.displayName()));
qCDebug(GOOGLE_CALENDAR_LOG) << "Adding calendar" << collection.displayName();
......@@ -288,22 +288,22 @@ void CalendarHandler::collectionAdded(const Collection &collection, const Collec
auto job = new CalendarCreateJob(calendar, m_settings->accountPtr(), this);
connect(job, &CalendarCreateJob::finished, this, [this, collection](KGAPI2::Job *job){
if (!m_iface->handleError(job)) {
return;
}
CalendarPtr calendar = qobject_cast<CalendarCreateJob *>(job)->items().first().dynamicCast<Calendar>();
qCDebug(GOOGLE_CALENDAR_LOG) << "Created calendar" << calendar->uid();
// Enable newly added calendar in settings, otherwise user won't see it
m_settings->addCalendar(calendar->uid());
// TODO: the calendar returned by google is almost empty, i.e. it's not "editable",
// does not contain the color, etc
calendar->setEditable(true);
// Populate remoteId & other stuff
Collection newCollection(collection);
setupCollection(newCollection, calendar);
m_iface->collectionChangeCommitted(newCollection);
emitReadyStatus();
});
if (!m_iface->handleError(job)) {
return;
}
CalendarPtr calendar = qobject_cast<CalendarCreateJob *>(job)->items().first().dynamicCast<Calendar>();
qCDebug(GOOGLE_CALENDAR_LOG) << "Created calendar" << calendar->uid();
// Enable newly added calendar in settings, otherwise user won't see it
m_settings->addCalendar(calendar->uid());
// TODO: the calendar returned by google is almost empty, i.e. it's not "editable",
// does not contain the color, etc
calendar->setEditable(true);
// Populate remoteId & other stuff
Collection newCollection(collection);
setupCollection(newCollection, calendar);
m_iface->collectionChangeCommitted(newCollection);
emitReadyStatus();
});
}
void CalendarHandler::collectionChanged(const Collection &collection)
......@@ -328,7 +328,6 @@ void CalendarHandler::collectionRemoved(const Collection &collection)
connect(job, &CalendarDeleteJob::finished, this, &CalendarHandler::slotGenericJobFinished);
}
/**
* FreeBusy
*/
......@@ -356,13 +355,13 @@ void FreeBusyHandler::canHandleFreeBusy(const QString &email)
m_settings->accountPtr(),
this);
connect(job, &FreeBusyQueryJob::finished, this, [this](KGAPI2::Job *job){
auto queryJob = qobject_cast<FreeBusyQueryJob *>(job);
if (!m_iface->handleError(job, false)) {
m_iface->handlesFreeBusy(queryJob->id(), false);
return;
}
m_iface->handlesFreeBusy(queryJob->id(), true);
});
auto queryJob = qobject_cast<FreeBusyQueryJob *>(job);
if (!m_iface->handleError(job, false)) {
m_iface->handlesFreeBusy(queryJob->id(), false);
return;
}
m_iface->handlesFreeBusy(queryJob->id(), true);
});
}
void FreeBusyHandler::retrieveFreeBusy(const QString &email, const QDateTime &start, const QDateTime &end)
......@@ -374,27 +373,27 @@ void FreeBusyHandler::retrieveFreeBusy(const QString &email, const QDateTime &st
auto job = new FreeBusyQueryJob(email, start, end, m_settings->accountPtr(), this);
connect(job, &FreeBusyQueryJob::finished, this, [this](KGAPI2::Job *job) {
auto queryJob = qobject_cast<FreeBusyQueryJob *>(job);
if (!m_iface->handleError(job, false)) {
m_iface->freeBusyRetrieved(queryJob->id(), QString(), false, QString());
return;
}
KCalendarCore::FreeBusy::Ptr fb(new KCalendarCore::FreeBusy);
fb->setUid(QStringLiteral("%1%2@google.com").arg(QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyyMMddTHHmmssZ"))));
fb->setOrganizer(job->account()->accountName());
fb->addAttendee(KCalendarCore::Attendee(QString(), queryJob->id()));
// FIXME: is it really sort?
fb->setDateTime(QDateTime::currentDateTimeUtc(), KCalendarCore::IncidenceBase::RoleSort);
const auto ranges = queryJob->busy();
for (const auto &range : ranges) {
fb->addPeriod(range.busyStart, range.busyEnd);
}
KCalendarCore::ICalFormat format;
const QString fbStr = format.createScheduleMessage(fb, KCalendarCore::iTIPRequest);
m_iface->freeBusyRetrieved(queryJob->id(), fbStr, true, QString());
});
auto queryJob = qobject_cast<FreeBusyQueryJob *>(job);
if (!m_iface->handleError(job, false)) {
m_iface->freeBusyRetrieved(queryJob->id(), QString(), false, QString());
return;
}
KCalendarCore::FreeBusy::Ptr fb(new KCalendarCore::FreeBusy);
fb->setUid(QStringLiteral("%1%2@google.com").arg(QDateTime::currentDateTimeUtc().toString(QStringLiteral("yyyyMMddTHHmmssZ"))));
fb->setOrganizer(job->account()->accountName());
fb->addAttendee(KCalendarCore::Attendee(QString(), queryJob->id()));
// FIXME: is it really sort?
fb->setDateTime(QDateTime::currentDateTimeUtc(), KCalendarCore::IncidenceBase::RoleSort);
const auto ranges = queryJob->busy();
for (const auto &range : ranges) {
fb->addPeriod(range.busyStart, range.busyEnd);
}
KCalendarCore::ICalFormat format;
const QString fbStr = format.createScheduleMessage(fb, KCalendarCore::iTIPRequest);
m_iface->freeBusyRetrieved(queryJob->id(), fbStr, true, QString());
});
}
......@@ -137,33 +137,33 @@ void ContactHandler::retrieveCollections(const Collection &rootCollection)
auto job = new ContactsGroupFetchJob(m_settings->accountPtr(), this);
connect(job, &ContactFetchJob::finished, this, [this, rootCollection](KGAPI2::Job *job){
if (!m_iface->handleError(job)) {
return;
}
qCDebug(GOOGLE_CONTACTS_LOG) << "Contacts groups retrieved";
const ObjectsList objects = qobject_cast<ContactsGroupFetchJob *>(job)->items();
Collection::List collections;
collections.reserve(objects.count());
std::transform(objects.cbegin(), objects.cend(), std::back_inserter(collections),
[this, &rootCollection](const ObjectPtr &object){
const ContactsGroupPtr group = object.dynamicCast<ContactsGroup>();
qCDebug(GOOGLE_CONTACTS_LOG) << " -" << group->title() << "(" << group->id() << ")";
Collection collection;
setupCollection(collection, group);
collection.setParentCollection(rootCollection);
m_collections[ collection.remoteId() ] = collection;
return collection;
});
m_iface->collectionsRetrievedFromHandler(collections);
});
if (!m_iface->handleError(job)) {
return;
}
qCDebug(GOOGLE_CONTACTS_LOG) << "Contacts groups retrieved";
const ObjectsList objects = qobject_cast<ContactsGroupFetchJob *>(job)->items();
Collection::List collections;
collections.reserve(objects.count());
std::transform(objects.cbegin(), objects.cend(), std::back_inserter(collections),
[this, &rootCollection](const ObjectPtr &object){
const ContactsGroupPtr group = object.dynamicCast<ContactsGroup>();
qCDebug(GOOGLE_CONTACTS_LOG) << " -" << group->title() << "(" << group->id() << ")";
Collection collection;
setupCollection(collection, group);
collection.setParentCollection(rootCollection);
m_collections[ collection.remoteId() ] = collection;
return collection;
});
m_iface->collectionsRetrievedFromHandler(collections);
});
}
void ContactHandler::retrieveItems(const Collection &collection)
{
// Contacts are stored inside "My Contacts" and "Other Contacts" only
if ((collection.remoteId() != OTHERCONTACTS_REMOTEID)
&& (collection.remoteId() != myContactsRemoteId())) {
&& (collection.remoteId() != myContactsRemoteId())) {
m_iface->itemsRetrievalDone();
return;
}
......@@ -201,15 +201,15 @@ void ContactHandler::slotItemsRetrieved(KGAPI2::Job *job)
const ContactPtr contact = object.dynamicCast<Contact>();
Item item;
item.setMimeType( mimeType() );
item.setMimeType(mimeType());
item.setParentCollection(collection);