use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class SyncMeDbUtils method updateMeProfileDbDetailIds.
/**
* The utility method to save Contacts/setMe() response to the database...
* @param dbHelper Database - database
* @param uploadedMeProfile Contact - me profile which has been uploaded in
* Contacts/setMe() call
* @param result ContactChanges - the contents of response Contacts/setMe().
* The contact details in response need to be in the same order
* as they were in setMe() request
*/
public static void updateMeProfileDbDetailIds(final DatabaseHelper dbHelper, final ArrayList<ContactDetail> uploadedDetails, final ContactChanges result) {
Contact uploadedMeProfile = new Contact();
SyncMeDbUtils.fetchMeProfile(dbHelper, uploadedMeProfile);
boolean changed = false;
if (result.mUserProfile.userID != null && !result.mUserProfile.userID.equals(uploadedMeProfile.userID)) {
uploadedMeProfile.userID = result.mUserProfile.userID;
changed = true;
}
if (result.mUserProfile.contactID != null && !result.mUserProfile.contactID.equals(uploadedMeProfile.contactID)) {
uploadedMeProfile.contactID = result.mUserProfile.contactID;
changed = true;
}
if (changed) {
dbHelper.modifyContactServerId(uploadedMeProfile.localContactID, uploadedMeProfile.contactID, uploadedMeProfile.userID);
}
ListIterator<ContactDetail> destIt = uploadedDetails.listIterator();
for (ContactDetail srcDetail : result.mUserProfile.details) {
if (!destIt.hasNext()) {
LogUtils.logE("SyncMeDbUtils updateProfileDbDetailsId() - # of details in response > # in request");
return;
}
final ContactDetail destDetail = destIt.next();
if (srcDetail.key == null || !srcDetail.key.equals(destDetail.key)) {
LogUtils.logE("SyncMeDbUtils updateProfileDbDetailsId() - details order is wrong");
break;
}
destDetail.unique_id = srcDetail.unique_id;
dbHelper.syncContactDetail(destDetail.localDetailID, destDetail.unique_id);
}
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processSetMeResponse.
/**
* Processes the response from a SetMe request. If successful, the server
* IDs will be stored in the local database if they have changed. Otherwise
* the processor will complete with a suitable error.
* @param resp Response from server.
*/
private void processSetMeResponse(final DecodedResponse resp) {
LogUtils.logD("SyncMeProfile.processMeProfileUpdateResponse()");
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
if (status == ServiceStatus.SUCCESS) {
ContactChanges result = (ContactChanges) resp.mDataTypes.get(0);
SyncMeDbUtils.updateMeProfileDbDetailIds(mDbHelper, mUploadedMeDetails, result);
if (updateRevisionPostUpdate(result.mServerRevisionBefore, result.mServerRevisionAfter, mFromRevision, mDbHelper)) {
mFromRevision = result.mServerRevisionAfter;
}
}
completeUiRequest(status);
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processUpdateStatusResponse.
/**
* This method processes the response to status update by setMe() method
* @param resp Response - the expected response datatype is ContactChanges
*/
private void processUpdateStatusResponse(final DecodedResponse resp) {
LogUtils.logD("SyncMeDbUtils processUpdateStatusResponse()");
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
if (status == ServiceStatus.SUCCESS) {
ContactChanges result = (ContactChanges) resp.mDataTypes.get(0);
LogUtils.logI("SyncMeProfile.processUpdateStatusResponse() - Me profile userId = " + result.mUserProfile.userID);
SyncMeDbUtils.savePresenceStatusResponse(mDbHelper, result);
}
completeUiRequest(status);
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class DatabaseHelper method convertNativeContactChanges.
/**
* Converts an array of ContactChange into a Contact object.
*
* @see ContactChange
* @see Contact
* @param contactChanges the array of ContactChange to convert
* @return the equivalent Contact
*/
private Contact convertNativeContactChanges(ContactChange[] contactChanges) {
if (contactChanges == null || contactChanges.length <= 0)
return null;
final Contact contact = new Contact();
contact.localContactID = contactChanges[0].getInternalContactId();
// coming from native
contact.nativeContactId = new Integer((int) contactChanges[0].getNabContactId());
contact.synctophone = true;
// fill the contact with all the details
for (int i = 0; i < contactChanges.length; i++) {
final ContactDetail detail = convertContactChange(contactChanges[i]);
// setting it to -1 means that it does not need to be synced back to
// native
detail.syncNativeContactId = -1;
contact.details.add(detail);
}
return contact;
}
use of com.vodafone360.people.datatypes.ContactChanges in project 360-Engine-for-Android by 360.
the class DownloadServerContactsTest method reportBackWithNoChanges.
private void reportBackWithNoChanges(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportBackWithNoChanges");
Integer pageNo = mProcessor.testGetPageFromReqId(reqId);
assertTrue(pageNo != null);
assertEquals(Integer.valueOf(0), pageNo);
ContactChanges contactChanges = new ContactChanges();
data.add(contactChanges);
contactChanges.mCurrentServerVersion = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionBefore = CURRENT_SERVER_VERSION;
contactChanges.mServerRevisionAfter = CURRENT_SERVER_VERSION;
contactChanges.mVersionAnchor = CURRENT_SERVER_VERSION;
contactChanges.mNumberOfPages = 1;
mItemCount--;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
Aggregations