use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class LoginEngine method handleServerSimpleTextResponse.
/**
* Called when a response to the GetTermsAndConditions, GetPrivacyStatement
* and GetUsernameState APIs are received. In case of success, completes the
* request and passes the response data to the UI.
*
* @param data The received data
*/
private void handleServerSimpleTextResponse(List<BaseDataType> data, State type) {
LogUtils.logV("LoginEngine.handleServerSimpleTextResponse()");
ServiceStatus serviceStatus = getResponseStatus(BaseDataType.SIMPLE_TEXT_DATA_TYPE, data);
String result = null;
if (serviceStatus == ServiceStatus.SUCCESS) {
result = ((SimpleText) data.get(0)).mValue.toString().replace(CARRIAGE_RETURN_CHARACTER, SPACE_CHARACTER);
switch(type) {
case FETCHING_TERMS_OF_SERVICE:
LogUtils.logD("LoginEngine.handleServerSimpleTextResponse() Terms of Service");
ApplicationCache.setTermsOfService(result, mContext);
break;
case FETCHING_PRIVACY_STATEMENT:
LogUtils.logD("LoginEngine.handleServerSimpleTextResponse() Privacy Statemet");
ApplicationCache.setPrivacyStatemet(result, mContext);
break;
case FETCHING_USERNAME_STATE:
// TODO: Unused by UI.
break;
}
}
updateTermsState(serviceStatus, result);
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class LoginEngine method handleActivateAccountResponse.
/**
* Called when a response to the Activate API is received (manual login or
* sign-up). In case of success, moves to the logged in state and completes
* the manual login or sign-up request.
*
* @param data The received data
*/
private void handleActivateAccountResponse(List<BaseDataType> data) {
LogUtils.logD("LoginEngine.handleActivateAccountResponse()");
ServiceStatus errorStatus = getResponseStatus(BaseDataType.STATUS_MSG_DATA_TYPE, data);
if (errorStatus == ServiceStatus.SUCCESS) {
LogUtils.logD("LoginEngine.handleActivateAccountResponse: ** Mobile number activated **");
setRegistrationComplete(true);
completeUiRequest(ServiceStatus.SUCCESS, null);
return;
}
setActivatedSession(null);
completeUiRequest(ServiceStatus.ERROR_ACCOUNT_ACTIVATION_FAILED, null);
}
use of com.vodafone360.people.service.io.Request 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.service.io.Request in project 360-Engine-for-Android by 360.
the class SyncMeDbUtils method populateWithModifiedDetails.
private static void populateWithModifiedDetails(final DatabaseHelper dbHelper, final ArrayList<ContactDetail> updates, Contact meProfile) {
boolean avatarChanged = dbHelper.isMeProfileAvatarChanged();
for (ContactDetail detail : meProfile.details) {
// LogUtils.logV("meProfile.details:" + detail);
if (avatarChanged && detail.key == ContactDetail.DetailKeys.PHOTO) {
populatePhotoDetail(dbHelper, meProfile, detail);
updates.add(detail);
} else if (detail.key != ContactDetail.DetailKeys.VCARD_INTERNET_ADDRESS && detail.key != ContactDetail.DetailKeys.VCARD_IMADDRESS && detail.key != ContactDetail.DetailKeys.PRESENCE_TEXT) {
// fix for bug 16029 - it's a server issue (getMe() returns
// broken details) but the workaround on the client side is
// just
// not to add the extra details to setMe() request
detail.updated = null;
// LogUtils.logV("meProfile.details: put");
updates.add(detail);
}
}
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class SyncMeEngine method downloadMeProfileThumbnail.
/**
* The call to download the thumbnail picture for the me profile.
* @param url String - picture url of Me Profile (comes with getMyChanges())
* @param localContactId long - local contact id of Me Profile
*/
private void downloadMeProfileThumbnail(final String url, final long localContactId) {
if (NetworkAgent.getAgentState() == NetworkAgent.AgentState.CONNECTED) {
Request request = new Request(url, ThumbnailUtils.REQUEST_THUMBNAIL_URI, engineId());
newState(State.FETCHING_ME_PROFILE_THUMBNAIL);
setReqId(QueueManager.getInstance().addRequestAndNotify(request));
}
}
Aggregations