void DocumentsHandler::getExtraInformation(Akonadi::Item::List &items) { for (int pos = 0; pos < items.count(); ++pos) { Akonadi::Item &item = items[pos]; if (!item.hasPayload<SugarDocument>()) { qCCritical(FATCRM_SUGARCRMRESOURCE_LOG) << "item (id=" << item.id() << ", remoteId=" << item.remoteId() << ", mime=" << item.mimeType() << ") is missing Document payload"; continue; } SugarDocument document = item.payload<SugarDocument>(); bool update = false; KDSoapGenerated::TNS__Select_fields selectedFields; selectedFields.setItems({QStringLiteral("id")}); // Get the Account(s) related to this document // http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Web_Services/Method_Calls/get_relationships/ // http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Web_Services/Examples/REST/PHP/Retrieving_Related_Records/ KDSoapGenerated::TNS__Get_entry_result_version2 result = mSession->soap()->get_relationships(sessionId(), QStringLiteral("Documents"), document.id(), moduleToName(Module::Accounts).toLower(), {}, selectedFields, {}, 0 /*deleted*/, QString(), 0 /*offset*/, 0 /*limit*/); QStringList linkedAccountIds; Q_FOREACH (const KDSoapGenerated::TNS__Entry_value& entry, result.entry_list().items()) { linkedAccountIds.append(entry.id()); } if (!linkedAccountIds.isEmpty()) { document.setLinkedAccountIds(linkedAccountIds); update = true; } QStringList linkedOpportunityIds; result = mSession->soap()->get_relationships(sessionId(), QStringLiteral("Documents"), document.id(), moduleToName(Module::Opportunities).toLower(), {}, selectedFields, {}, 0 /*deleted*/, QString(), 0 /*offset*/, 0 /*limit*/); Q_FOREACH (const KDSoapGenerated::TNS__Entry_value &entry, result.entry_list().items()) { linkedOpportunityIds.append(entry.id()); } if (!linkedOpportunityIds.isEmpty()) { document.setLinkedOpportunityIds(linkedOpportunityIds); update = true; } if (update) { item.setPayload<SugarDocument>(document); } } }
KMime::Message::Ptr TagConverter::createMessage(const Akonadi::Tag &tag, const Akonadi::Item::List &items, const QString &username) { QStringList itemRemoteIds; itemRemoteIds.reserve(items.count()); for (const Akonadi::Item &item : items) { const QString memberUrl = KolabHelpers::createMemberUrl(item, username); if (!memberUrl.isEmpty()) { itemRemoteIds << memberUrl; } } // save message to the server. const QLatin1String productId("Akonadi-Kolab-Resource"); const KMime::Message::Ptr message = Kolab::KolabObjectWriter::writeTag(tag, itemRemoteIds, Kolab::KolabV3, productId); return message; }
Akonadi::Item::List SalesforceContactsHandler::itemsFromListEntriesResponse(const TNS__QueryResult &queryResult, const Akonadi::Collection &parentCollection) { Akonadi::Item::List items; Q_FOREACH (const ENS__SObject &entry, queryResult.records()) { const QList<KDSoapValue> valueList = entry.any(); if (valueList.isEmpty()) { kWarning() << "Contacts entry for id=" << entry.id().value() << "has no values"; kDebug() << "fieldsToNull:" << entry.fieldsToNull(); continue; } Akonadi::Item item; item.setRemoteId(entry.id().value()); item.setParentCollection(parentCollection); item.setMimeType(KABC::Addressee::mimeType()); KABC::Addressee addressee; addressee.setUid(entry.id().value()); QList<KDSoapValue>::const_iterator it = valueList.constBegin(); QList<KDSoapValue>::const_iterator endIt = valueList.constEnd(); for (; it != endIt; ++it) { ContactAccessorHash::const_iterator accessorIt = mAccessors->constFind(it->name()); if (accessorIt != mAccessors->constEnd()) { if (accessorIt->isAvailable) { accessorIt->setter(it->value().value<QString>(), addressee); } } else { kWarning() << "Contacts entry for id=" << entry.id().value() << "has unknown value named" << it->name(); } } item.setPayload<KABC::Addressee>(addressee); items << item; } kDebug() << "Query result had" << items.count() << "valid contact items"; return items; }
void NotesRepository::slotNotesReceived(const Akonadi::Item::List &items) { mNotesLoaded += items.count(); foreach(const Akonadi::Item &item, items) { storeNote(item); }