Search in sources :

Example 26 with BaseDataType

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);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 27 with BaseDataType

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);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 28 with BaseDataType

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;
}
Also used : PushEvent(com.vodafone360.people.datatypes.PushEvent) BaseDataType(com.vodafone360.people.datatypes.BaseDataType)

Example 29 with BaseDataType

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);
    }
}
Also used : ContactChanges(com.vodafone360.people.datatypes.ContactChanges)

Example 30 with BaseDataType

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:
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) AuthSessionHolder(com.vodafone360.people.datatypes.AuthSessionHolder) StatusMsg(com.vodafone360.people.datatypes.StatusMsg) SimpleText(com.vodafone360.people.datatypes.SimpleText) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue)

Aggregations

BaseDataType (com.vodafone360.people.datatypes.BaseDataType)29 ArrayList (java.util.ArrayList)25 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)21 ServiceStatus (com.vodafone360.people.service.ServiceStatus)15 ServerError (com.vodafone360.people.datatypes.ServerError)12 MediumTest (android.test.suitebuilder.annotation.MediumTest)9 Contact (com.vodafone360.people.datatypes.Contact)9 IOException (java.io.IOException)9 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)8 Identity (com.vodafone360.people.datatypes.Identity)7 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)7 HessianDecoder (com.vodafone360.people.service.utils.hessian.HessianDecoder)7 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)6 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)5 PushEvent (com.vodafone360.people.datatypes.PushEvent)5 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)5 Bundle (android.os.Bundle)3 Suppress (android.test.suitebuilder.annotation.Suppress)3 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)3 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)3