use of com.vodafone360.people.datatypes.BaseDataType 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.datatypes.BaseDataType 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.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class ContactSyncEngine method processPushEvent.
/**
* Determines if a given response is a push message and processes in this
* case TODO: we need the check for Me Profile be migrated to he new engine
*
* @param resp Response to check and process
* @return true if the response was processed
*/
private boolean processPushEvent(DecodedResponse resp) {
if (resp.mDataTypes == null || resp.mDataTypes.size() == 0) {
return false;
}
BaseDataType dataType = resp.mDataTypes.get(0);
if ((dataType == null) || dataType.getType() != BaseDataType.PUSH_EVENT_DATA_TYPE) {
return false;
}
PushEvent pushEvent = (PushEvent) dataType;
LogUtils.logV("Push Event Type = " + pushEvent.mMessageType);
switch(pushEvent.mMessageType) {
case CONTACTS_CHANGE:
LogUtils.logI("ContactSyncEngine.processCommsResponse - Contacts changed push message received");
mServerSyncRequired = true;
// fetch the newest groups
EngineManager.getInstance().getGroupsEngine().addUiGetGroupsRequest();
mEventCallback.kickWorkerThread();
break;
case SYSTEM_NOTIFICATION:
LogUtils.logI("ContactSyncEngine.processCommsResponse - System notification push message received");
break;
default:
// do nothing.
break;
}
return true;
}
use of com.vodafone360.people.datatypes.BaseDataType 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);
}
}
use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.
the class LoginEngineTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d("TAG", "LoginEngineTest.reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
switch(mState) {
case IDLE:
break;
case LOGIN_REQUEST:
case SMS_RESPONSE_SIGNIN:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
StatusMsg msg = new StatusMsg();
data.add(msg);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
mState = LoginTestState.LOGIN_REQUEST_VALID;
break;
case LOGIN_REQUEST_VALID:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
AuthSessionHolder sesh = new AuthSessionHolder();
data.add(sesh);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
mState = LoginTestState.SMS_RESPONSE_SIGNIN;
break;
case REGISTRATION:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine Registration");
data.add(mTestModule.createDummyContactData());
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SIGNUP_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case REGISTRATION_ERROR:
data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_T_AND_C:
case FETCH_PRIVACY:
case USER_NAME_STATE:
SimpleText txt = new SimpleText();
txt.addText("Simple text");
data.add(txt);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_T_AND_C_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case SERVER_ERROR:
data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
default:
}
}
Aggregations