Commit e0d5a9b2 authored by blam's avatar blam

Merge branch 'jb53422' into 'master'

Jb53422

See merge request !90
parents 88beda14 734477e2
...@@ -51,7 +51,7 @@ namespace { ...@@ -51,7 +51,7 @@ namespace {
static const QString StarredContactGroupName = QStringLiteral("contactGroups/starred"); static const QString StarredContactGroupName = QStringLiteral("contactGroups/starred");
QDate jsonObjectToDate(const QJsonObject &object) QDate jsonObjectToDate(const QJsonObject &object, bool *ok)
{ {
const int year = object.value("year").toInt(); const int year = object.value("year").toInt();
const int month = object.value("month").toInt(); const int month = object.value("month").toInt();
...@@ -61,6 +61,9 @@ QDate jsonObjectToDate(const QJsonObject &object) ...@@ -61,6 +61,9 @@ QDate jsonObjectToDate(const QJsonObject &object)
if (!date.isValid()) { if (!date.isValid()) {
SOCIALD_LOG_ERROR("Cannot read date from JSON:" << object); SOCIALD_LOG_ERROR("Cannot read date from JSON:" << object);
} }
if (ok) {
*ok = date.isValid();
}
return date; return date;
} }
...@@ -80,7 +83,11 @@ QList<T> jsonArrayToList(const QJsonArray &array) ...@@ -80,7 +83,11 @@ QList<T> jsonArrayToList(const QJsonArray &array)
{ {
QList<T> values; QList<T> values;
for (auto it = array.constBegin(); it != array.constEnd(); ++it) { for (auto it = array.constBegin(); it != array.constEnd(); ++it) {
values.append(T::fromJsonObject(it->toObject())); bool error = false;
const T &value = T::fromJsonObject(it->toObject(), &error);
if (!error) {
values.append(value);
}
} }
return values; return values;
} }
...@@ -169,7 +176,7 @@ bool shouldAddDetailChanges(const QContactDetail &detail, bool *hasChanges) ...@@ -169,7 +176,7 @@ bool shouldAddDetailChanges(const QContactDetail &detail, bool *hasChanges)
} }
GooglePeople::Source GooglePeople::Source::fromJsonObject(const QJsonObject &object) GooglePeople::Source GooglePeople::Source::fromJsonObject(const QJsonObject &object, bool *)
{ {
Source ret; Source ret;
ret.type = object.value("type").toString(); ret.type = object.value("type").toString();
...@@ -223,7 +230,7 @@ bool GooglePeople::Address::saveContactDetails(QContact *contact, const QList<Ad ...@@ -223,7 +230,7 @@ bool GooglePeople::Address::saveContactDetails(QContact *contact, const QList<Ad
return true; return true;
} }
GooglePeople::Address GooglePeople::Address::fromJsonObject(const QJsonObject &obj) GooglePeople::Address GooglePeople::Address::fromJsonObject(const QJsonObject &obj, bool *)
{ {
Address ret; Address ret;
ret.metadata = FieldMetadata::fromJsonObject(obj.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(obj.value("metadata").toObject());
...@@ -296,7 +303,7 @@ bool GooglePeople::Biography::saveContactDetails(QContact *contact, const QList< ...@@ -296,7 +303,7 @@ bool GooglePeople::Biography::saveContactDetails(QContact *contact, const QList<
return saveContactDetail(contact, &detail); return saveContactDetail(contact, &detail);
} }
GooglePeople::Biography GooglePeople::Biography::fromJsonObject(const QJsonObject &object) GooglePeople::Biography GooglePeople::Biography::fromJsonObject(const QJsonObject &object, bool *)
{ {
Biography ret; Biography ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -332,11 +339,20 @@ bool GooglePeople::Birthday::saveContactDetails(QContact *contact, const QList<B ...@@ -332,11 +339,20 @@ bool GooglePeople::Birthday::saveContactDetails(QContact *contact, const QList<B
return saveContactDetail(contact, &detail); return saveContactDetail(contact, &detail);
} }
GooglePeople::Birthday GooglePeople::Birthday::fromJsonObject(const QJsonObject &object) GooglePeople::Birthday GooglePeople::Birthday::fromJsonObject(const QJsonObject &object, bool *error)
{ {
bool dateOk = false;
const QDate date = jsonObjectToDate(object.value("date").toObject(), &dateOk);
if (error) {
*error = !dateOk;
}
if (!dateOk) {
return Birthday();
}
Birthday ret; Birthday ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
ret.date = jsonObjectToDate(object.value("date").toObject()); ret.date = date;
return ret; return ret;
} }
...@@ -388,7 +404,7 @@ bool GooglePeople::EmailAddress::saveContactDetails(QContact *contact, const QLi ...@@ -388,7 +404,7 @@ bool GooglePeople::EmailAddress::saveContactDetails(QContact *contact, const QLi
return true; return true;
} }
GooglePeople::EmailAddress GooglePeople::EmailAddress::fromJsonObject(const QJsonObject &object) GooglePeople::EmailAddress GooglePeople::EmailAddress::fromJsonObject(const QJsonObject &object, bool *)
{ {
EmailAddress ret; EmailAddress ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -467,11 +483,20 @@ bool GooglePeople::Event::saveContactDetails(QContact *contact, const QList<Even ...@@ -467,11 +483,20 @@ bool GooglePeople::Event::saveContactDetails(QContact *contact, const QList<Even
return true; return true;
} }
GooglePeople::Event GooglePeople::Event::fromJsonObject(const QJsonObject &object) GooglePeople::Event GooglePeople::Event::fromJsonObject(const QJsonObject &object, bool *error)
{ {
bool dateOk = false;
const QDate date = jsonObjectToDate(object.value("date").toObject(), &dateOk);
if (error) {
*error = !dateOk;
}
if (!dateOk) {
return Event();
}
Event ret; Event ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
ret.date = jsonObjectToDate(object.value("date").toObject()); ret.date = date;
ret.type = object.value("type").toString(); ret.type = object.value("type").toString();
return ret; return ret;
} }
...@@ -568,7 +593,7 @@ bool GooglePeople::Membership::saveContactDetails( ...@@ -568,7 +593,7 @@ bool GooglePeople::Membership::saveContactDetails(
return true; return true;
} }
GooglePeople::Membership GooglePeople::Membership::fromJsonObject(const QJsonObject &object) GooglePeople::Membership GooglePeople::Membership::fromJsonObject(const QJsonObject &object, bool *)
{ {
Membership ret; Membership ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -631,7 +656,7 @@ bool GooglePeople::Name::saveContactDetails(QContact *contact, const QList<Name> ...@@ -631,7 +656,7 @@ bool GooglePeople::Name::saveContactDetails(QContact *contact, const QList<Name>
return saveContactDetail(contact, &detail); return saveContactDetail(contact, &detail);
} }
GooglePeople::Name GooglePeople::Name::fromJsonObject(const QJsonObject &object) GooglePeople::Name GooglePeople::Name::fromJsonObject(const QJsonObject &object, bool *)
{ {
Name ret; Name ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -676,7 +701,7 @@ bool GooglePeople::Nickname::saveContactDetails(QContact *contact, const QList<N ...@@ -676,7 +701,7 @@ bool GooglePeople::Nickname::saveContactDetails(QContact *contact, const QList<N
return true; return true;
} }
GooglePeople::Nickname GooglePeople::Nickname::fromJsonObject(const QJsonObject &object) GooglePeople::Nickname GooglePeople::Nickname::fromJsonObject(const QJsonObject &object, bool *)
{ {
Nickname ret; Nickname ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -718,7 +743,7 @@ bool GooglePeople::Organization::saveContactDetails(QContact *contact, const QLi ...@@ -718,7 +743,7 @@ bool GooglePeople::Organization::saveContactDetails(QContact *contact, const QLi
return true; return true;
} }
GooglePeople::Organization GooglePeople::Organization::fromJsonObject(const QJsonObject &object) GooglePeople::Organization GooglePeople::Organization::fromJsonObject(const QJsonObject &object, bool *)
{ {
Organization ret; Organization ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -795,7 +820,7 @@ bool GooglePeople::PhoneNumber::saveContactDetails(QContact *contact, const QLis ...@@ -795,7 +820,7 @@ bool GooglePeople::PhoneNumber::saveContactDetails(QContact *contact, const QLis
return true; return true;
} }
GooglePeople::PhoneNumber GooglePeople::PhoneNumber::fromJsonObject(const QJsonObject &object) GooglePeople::PhoneNumber GooglePeople::PhoneNumber::fromJsonObject(const QJsonObject &object, bool *)
{ {
PhoneNumber ret; PhoneNumber ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -882,7 +907,7 @@ QString GooglePeople::PersonMetadata::etag(const QContact &contact) ...@@ -882,7 +907,7 @@ QString GooglePeople::PersonMetadata::etag(const QContact &contact)
return sourceInfo.value("etag").toString(); return sourceInfo.value("etag").toString();
} }
GooglePeople::PersonMetadata GooglePeople::PersonMetadata::fromJsonObject(const QJsonObject &object) GooglePeople::PersonMetadata GooglePeople::PersonMetadata::fromJsonObject(const QJsonObject &object, bool *)
{ {
PersonMetadata ret; PersonMetadata ret;
ret.sources = jsonArrayToList<Source>(object.value("sources").toArray()); ret.sources = jsonArrayToList<Source>(object.value("sources").toArray());
...@@ -961,7 +986,7 @@ bool GooglePeople::Photo::saveContactDetails(QContact *contact, const QList<Phot ...@@ -961,7 +986,7 @@ bool GooglePeople::Photo::saveContactDetails(QContact *contact, const QList<Phot
return true; return true;
} }
GooglePeople::Photo GooglePeople::Photo::fromJsonObject(const QJsonObject &object) GooglePeople::Photo GooglePeople::Photo::fromJsonObject(const QJsonObject &object, bool *)
{ {
Photo ret; Photo ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -1008,7 +1033,7 @@ bool GooglePeople::Url::saveContactDetails(QContact *contact, const QList<Url> & ...@@ -1008,7 +1033,7 @@ bool GooglePeople::Url::saveContactDetails(QContact *contact, const QList<Url> &
return true; return true;
} }
GooglePeople::Url GooglePeople::Url::fromJsonObject(const QJsonObject &object) GooglePeople::Url GooglePeople::Url::fromJsonObject(const QJsonObject &object, bool *)
{ {
Url ret; Url ret;
ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = FieldMetadata::fromJsonObject(object.value("metadata").toObject());
...@@ -1091,7 +1116,7 @@ GooglePeople::Person GooglePeople::Person::fromJsonObject(const QJsonObject &obj ...@@ -1091,7 +1116,7 @@ GooglePeople::Person GooglePeople::Person::fromJsonObject(const QJsonObject &obj
{ {
Person ret; Person ret;
ret.resourceName = object.value("resourceName").toString(); ret.resourceName = object.value("resourceName").toString();
ret.metadata = PersonMetadata::fromJsonObject(object.value("metadata").toObject()); ret.metadata = PersonMetadata::fromJsonObject(object.value("metadata").toObject(), nullptr);
ret.addresses = jsonArrayToList<Address>(object.value("addresses").toArray()); ret.addresses = jsonArrayToList<Address>(object.value("addresses").toArray());
ret.biographies = jsonArrayToList<Biography>(object.value("biographies").toArray()); ret.biographies = jsonArrayToList<Biography>(object.value("biographies").toArray());
ret.birthdays = jsonArrayToList<Birthday>(object.value("birthdays").toArray()); ret.birthdays = jsonArrayToList<Birthday>(object.value("birthdays").toArray());
......
...@@ -45,7 +45,7 @@ namespace GooglePeople ...@@ -45,7 +45,7 @@ namespace GooglePeople
ProfileMetadata profileMetadata; ProfileMetadata profileMetadata;
*/ */
static Source fromJsonObject(const QJsonObject &obj); static Source fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
}; };
class FieldMetadata class FieldMetadata
...@@ -75,7 +75,7 @@ namespace GooglePeople ...@@ -75,7 +75,7 @@ namespace GooglePeople
QString countryCode; QString countryCode;
static bool saveContactDetails(QContact *contact, const QList<Address> &values); static bool saveContactDetails(QContact *contact, const QList<Address> &values);
static Address fromJsonObject(const QJsonObject &obj); static Address fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -90,7 +90,7 @@ namespace GooglePeople ...@@ -90,7 +90,7 @@ namespace GooglePeople
*/ */
static bool saveContactDetails(QContact *contact, const QList<Biography> &values); static bool saveContactDetails(QContact *contact, const QList<Biography> &values);
static Biography fromJsonObject(const QJsonObject &obj); static Biography fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -105,7 +105,7 @@ namespace GooglePeople ...@@ -105,7 +105,7 @@ namespace GooglePeople
*/ */
static bool saveContactDetails(QContact *contact, const QList<Birthday> &values); static bool saveContactDetails(QContact *contact, const QList<Birthday> &values);
static Birthday fromJsonObject(const QJsonObject &obj); static Birthday fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -119,7 +119,7 @@ namespace GooglePeople ...@@ -119,7 +119,7 @@ namespace GooglePeople
QString displayName; QString displayName;
static bool saveContactDetails(QContact *contact, const QList<EmailAddress> &values); static bool saveContactDetails(QContact *contact, const QList<EmailAddress> &values);
static EmailAddress fromJsonObject(const QJsonObject &obj); static EmailAddress fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -135,7 +135,7 @@ namespace GooglePeople ...@@ -135,7 +135,7 @@ namespace GooglePeople
*/ */
static bool saveContactDetails(QContact *contact, const QList<Event> &values); static bool saveContactDetails(QContact *contact, const QList<Event> &values);
static Event fromJsonObject(const QJsonObject &obj); static Event fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -155,7 +155,7 @@ namespace GooglePeople ...@@ -155,7 +155,7 @@ namespace GooglePeople
const QList<Membership> &values, const QList<Membership> &values,
int accountId, int accountId,
const QList<QContactCollection> &candidateCollections); const QList<QContactCollection> &candidateCollections);
static Membership fromJsonObject(const QJsonObject &obj); static Membership fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -182,7 +182,7 @@ namespace GooglePeople ...@@ -182,7 +182,7 @@ namespace GooglePeople
*/ */
static bool saveContactDetails(QContact *contact, const QList<Name> &values); static bool saveContactDetails(QContact *contact, const QList<Name> &values);
static Name fromJsonObject(const QJsonObject &obj); static Name fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -197,7 +197,7 @@ namespace GooglePeople ...@@ -197,7 +197,7 @@ namespace GooglePeople
*/ */
static bool saveContactDetails(QContact *contact, const QList<Nickname> &values); static bool saveContactDetails(QContact *contact, const QList<Nickname> &values);
static Nickname fromJsonObject(const QJsonObject &obj); static Nickname fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -222,7 +222,7 @@ namespace GooglePeople ...@@ -222,7 +222,7 @@ namespace GooglePeople
*/ */
static bool saveContactDetails(QContact *contact, const QList<Organization> &values); static bool saveContactDetails(QContact *contact, const QList<Organization> &values);
static Organization fromJsonObject(const QJsonObject &obj); static Organization fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -239,7 +239,7 @@ namespace GooglePeople ...@@ -239,7 +239,7 @@ namespace GooglePeople
*/ */
static bool saveContactDetails(QContact *contact, const QList<PhoneNumber> &values); static bool saveContactDetails(QContact *contact, const QList<PhoneNumber> &values);
static PhoneNumber fromJsonObject(const QJsonObject &obj); static PhoneNumber fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -254,7 +254,7 @@ namespace GooglePeople ...@@ -254,7 +254,7 @@ namespace GooglePeople
static QString etag(const QContact &contact); static QString etag(const QContact &contact);
static bool saveContactDetails(QContact *contact, const PersonMetadata &value); static bool saveContactDetails(QContact *contact, const PersonMetadata &value);
static PersonMetadata fromJsonObject(const QJsonObject &obj); static PersonMetadata fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonObject toJsonObject(const QContact &contact); static QJsonObject toJsonObject(const QContact &contact);
}; };
...@@ -270,7 +270,7 @@ namespace GooglePeople ...@@ -270,7 +270,7 @@ namespace GooglePeople
QString *localAvatarFile = nullptr); QString *localAvatarFile = nullptr);
static bool saveContactDetails(QContact *contact, const QList<Photo> &values); static bool saveContactDetails(QContact *contact, const QList<Photo> &values);
static Photo fromJsonObject(const QJsonObject &obj); static Photo fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
...@@ -283,7 +283,7 @@ namespace GooglePeople ...@@ -283,7 +283,7 @@ namespace GooglePeople
QString formattedType; QString formattedType;
static bool saveContactDetails(QContact *contact, const QList<Url> &values); static bool saveContactDetails(QContact *contact, const QList<Url> &values);
static Url fromJsonObject(const QJsonObject &obj); static Url fromJsonObject(const QJsonObject &obj, bool *error = nullptr);
static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges); static QJsonArray jsonValuesForContact(const QContact &contact, bool *hasChanges);
}; };
......
...@@ -188,6 +188,33 @@ void GoogleContactSqliteSyncAdaptor::syncFinishedSuccessfully() ...@@ -188,6 +188,33 @@ void GoogleContactSqliteSyncAdaptor::syncFinishedSuccessfully()
void GoogleContactSqliteSyncAdaptor::syncFinishedWithError() void GoogleContactSqliteSyncAdaptor::syncFinishedWithError()
{ {
SOCIALD_LOG_ERROR("Sync finished with error"); SOCIALD_LOG_ERROR("Sync finished with error");
if (q->m_collection.id().isNull()) {
return;
}
// If sync fails, clear the sync token and date for the collection, so that the next sync
// requests a full contact listing, to ensure we are up-to-date with the server.
q->m_collection.setExtendedMetaData(CollectionKeySyncToken, QString());
q->m_collection.setExtendedMetaData(CollectionKeySyncTokenDate, QString());
QHash<QContactCollection*, QList<QContact>* > modifiedCollections;
QList<QContact> emptyContacts;
modifiedCollections.insert(&q->m_collection, &emptyContacts);
QtContactsSqliteExtensions::ContactManagerEngine *cme = QtContactsSqliteExtensions::contactManagerEngine(*q->m_contactManager);
QContactManager::Error error = QContactManager::NoError;
if (!cme->storeChanges(nullptr,
&modifiedCollections,
QList<QContactCollectionId>(),
QtContactsSqliteExtensions::ContactManagerEngine::PreserveLocalChanges,
true,
&error)) {
SOCIALD_LOG_ERROR("Failed to clear sync token for account:" << q->m_accountId
<< "due to error:" << error);
}
} }
//------------------------------------- //-------------------------------------
...@@ -419,7 +446,8 @@ void GoogleTwoWayContactSyncAdaptor::contactsFinishedHandler() ...@@ -419,7 +446,8 @@ void GoogleTwoWayContactSyncAdaptor::contactsFinishedHandler()
if (reply->error() == QNetworkReply::ProtocolInvalidOperationError) { if (reply->error() == QNetworkReply::ProtocolInvalidOperationError) {
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 400) { if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 400
&& !m_retriedConnectionsList) {
SOCIALD_LOG_INFO("Will request new sync token, got error from server:" SOCIALD_LOG_INFO("Will request new sync token, got error from server:"
<< reply->readAll()); << reply->readAll());
DataRequestType requestType = static_cast<DataRequestType>( DataRequestType requestType = static_cast<DataRequestType>(
...@@ -428,6 +456,7 @@ void GoogleTwoWayContactSyncAdaptor::contactsFinishedHandler() ...@@ -428,6 +456,7 @@ void GoogleTwoWayContactSyncAdaptor::contactsFinishedHandler()
reply->property("contactChangeNotifier").toInt()); reply->property("contactChangeNotifier").toInt());
m_connectionsListParams.requestSyncToken = true; m_connectionsListParams.requestSyncToken = true;
m_connectionsListParams.syncToken.clear(); m_connectionsListParams.syncToken.clear();
m_retriedConnectionsList = true;
requestData(requestType, contactChangeNotifier); requestData(requestType, contactChangeNotifier);
decrementSemaphore(m_accountId); decrementSemaphore(m_accountId);
return; return;
...@@ -1108,12 +1137,14 @@ void GoogleTwoWayContactSyncAdaptor::purgeAccount(int pid) ...@@ -1108,12 +1137,14 @@ void GoogleTwoWayContactSyncAdaptor::purgeAccount(int pid)
void GoogleTwoWayContactSyncAdaptor::finalize(int accountId) void GoogleTwoWayContactSyncAdaptor::finalize(int accountId)
{ {
if (syncAborted()|| status() == SocialNetworkSyncAdaptor::Error) {
m_sqliteSync->syncFinishedWithError();
return;
}
if (accountId != m_accountId if (accountId != m_accountId
|| m_accessToken.isEmpty() || m_accessToken.isEmpty()) {
|| syncAborted()
|| status() == SocialNetworkSyncAdaptor::Error) {
// account failure occurred before sync process was started, // account failure occurred before sync process was started,
// or other error occurred during sync.
// in this case we have nothing left to do except cleanup. // in this case we have nothing left to do except cleanup.
return; return;
} }
......
...@@ -173,6 +173,7 @@ private: ...@@ -173,6 +173,7 @@ private:
int m_accountId = 0; int m_accountId = 0;
int m_apiRequestsRemaining = 0; int m_apiRequestsRemaining = 0;
bool m_retriedConnectionsList = false;
bool m_allowFinalCleanup = false; bool m_allowFinalCleanup = false;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment