Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Address book name fixes. JB#50552
Browse files Browse the repository at this point in the history
Google address book name should come from the atom feed, instead of
being hardcoded.
  • Loading branch information
Bea Lam committed Sep 25, 2020
1 parent 4d2368b commit d26215a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/google/google-contacts/googlecontactatom.cpp
Expand Up @@ -189,12 +189,12 @@ QList<QContact> GoogleContactAtom::deletedEntryContacts() const
return mDeletedContactList;
}

void GoogleContactAtom::addEntrySystemGroup(const QString &systemGroupId, const QString &systemGroupAtomId)
void GoogleContactAtom::addEntrySystemGroup(const QString &systemGroupId, const QString &systemGroupAtomId, const QString &systemGroupTitle)
{
mSystemGroupAtomIds.insert(systemGroupId, systemGroupAtomId);
mSystemGroupAtomIds.insert(systemGroupId, qMakePair(systemGroupAtomId, systemGroupTitle));
}

QMap<QString, QString> GoogleContactAtom::entrySystemGroups() const
QMap<QString, QPair<QString, QString> > GoogleContactAtom::entrySystemGroups() const
{
return mSystemGroupAtomIds;
}
Expand Down
6 changes: 3 additions & 3 deletions src/google/google-contacts/googlecontactatom.h
Expand Up @@ -81,8 +81,8 @@ class GoogleContactAtom {
void addDeletedEntryContact(const QContact &contact);
QList<QContact> deletedEntryContacts() const;

void addEntrySystemGroup(const QString &systemGroupId, const QString &systemGroupAtomId);
QMap<QString, QString> entrySystemGroups() const;
void addEntrySystemGroup(const QString &systemGroupId, const QString &systemGroupAtomId, const QString &systemGroupTitle);
QMap<QString, QPair<QString, QString> > entrySystemGroups() const;

void setNextEntriesUrl(const QString &nextUrl);
QString nextEntriesUrl() const;
Expand Down Expand Up @@ -129,7 +129,7 @@ class GoogleContactAtom {
QList<QContact> mDeletedContactList;
QList<QPair<QContact, QStringList> > mContactList;

QMap<QString, QString> mSystemGroupAtomIds;
QMap<QString, QPair<QString, QString> > mSystemGroupAtomIds;

QString mNextEntriesUrl;
};
Expand Down
6 changes: 5 additions & 1 deletion src/google/google-contacts/googlecontactstream.cpp
Expand Up @@ -299,6 +299,8 @@ void GoogleContactStream::handleAtomEntry()
bool isInGroup = false;
bool isDeleted = false;

QString title;

// or it will be a series of batch operation success/fail info
// if this xml is the response to a batch update/delete request.
bool isBatchOperationResponse = false;
Expand Down Expand Up @@ -365,6 +367,8 @@ void GoogleContactStream::handleAtomEntry()
// either a contact id or a group id.
QContactDetail guidDetail = handleEntryId(&systemGroupAtomId);
entryContact.saveDetail(&guidDetail);
} else if (mXmlReader->name().toString() == QStringLiteral("title")) {
title = mXmlReader->readElementText();
} else {
// This is some XML element which we don't handle.
// We should store it, so that we can send it back when we upload changes.
Expand All @@ -379,7 +383,7 @@ void GoogleContactStream::handleAtomEntry()

if (!systemGroupId.isEmpty()) {
// this entry was a group
mAtom->addEntrySystemGroup(systemGroupId, systemGroupAtomId);
mAtom->addEntrySystemGroup(systemGroupId, systemGroupAtomId, title);
} else {
// this entry was a contact.
// the etag is the "version identifier".
Expand Down
14 changes: 9 additions & 5 deletions src/google/google-contacts/googletwowaycontactsyncadaptor.cpp
Expand Up @@ -417,19 +417,23 @@ void GoogleTwoWayContactSyncAdaptor::groupsFinishedHandler()
return;
}

SOCIALD_LOG_TRACE("received information about" << atom->entrySystemGroups().size() << "groups for account" << accountId);
const QMap<QString, QPair<QString, QString> > entrySystemGroups = atom->entrySystemGroups();
SOCIALD_LOG_TRACE("received information about" << entrySystemGroups.size() << "groups for account" << accountId);

auto it = entrySystemGroups.find(QStringLiteral("Contacts"));
if (it != entrySystemGroups.constEnd()) {
// we have found the atom id of the group we need to upload new contacts to.
const QString myContactsGroupAtomId = it.value().first;
const QString myContactsGroupAtomTitle = it.value().second;

if (atom->entrySystemGroups().contains(QStringLiteral("Contacts"))) {
QContactCollection collection;
collection.setMetaData(QContactCollection::KeyName, MyContactsCollectionName);
collection.setMetaData(QContactCollection::KeyName, myContactsGroupAtomTitle);
collection.setMetaData(QContactCollection::KeyDescription, QStringLiteral("Google - Contacts"));
collection.setMetaData(QContactCollection::KeyColor, QStringLiteral("tomato"));
collection.setMetaData(QContactCollection::KeySecondaryColor, QStringLiteral("royalblue"));
collection.setExtendedMetaData(COLLECTION_EXTENDEDMETADATA_KEY_APPLICATIONNAME, QCoreApplication::applicationName());
collection.setExtendedMetaData(COLLECTION_EXTENDEDMETADATA_KEY_ACCOUNTID, accountId);

// we have found the atom id of the group we need to upload new contacts to.
QString myContactsGroupAtomId = atom->entrySystemGroups().value(QStringLiteral("Contacts"));
if (myContactsGroupAtomId.isEmpty()) {
// We don't consider this a fatal error,
// instead, we just refuse to upsync new contacts.
Expand Down
2 changes: 1 addition & 1 deletion src/knowncontacts/knowncontactssyncer.cpp
Expand Up @@ -44,7 +44,7 @@
Exchange accounts.
*/

const auto GalCollectionName = QLatin1String("EAS GAL contacts");
const auto GalCollectionName = QLatin1String("GAL");
const auto CollectionKeyLastSync = QLatin1String("last-sync-time");

static void setGuid(QContact *contact, const QString &id);
Expand Down
2 changes: 1 addition & 1 deletion src/vk/vk-contacts/vkcontactsyncadaptor.cpp
Expand Up @@ -49,7 +49,7 @@ static const char *IMAGE_DOWNLOADER_IDENTIFIER_KEY = "identifier";

namespace {

const QString FriendCollectionName = QStringLiteral("vk-friends");
const QString FriendCollectionName = QStringLiteral("VK");

bool saveNonexportableDetail(QContact &c, QContactDetail &d)
{
Expand Down

0 comments on commit d26215a

Please sign in to comment.