Search in sources :

Example 21 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class IdentityEngine method handleSetIdentityStatus.

/**
 * Handle Server response to set capability status request. The response
 * should be a Status-msg indicating whether the request has succeeded or
 * failed. The request is completed with the status result (or
 * ERROR_UNEXPECTED_RESPONSE if the data-type retrieved is not a
 * Status-msg).
 *
 * @param data List of BaseDataTypes generated from Server response.
 */
private void handleSetIdentityStatus(List<BaseDataType> data) {
    Bundle bu = null;
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.STATUS_MSG_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        mStatusList.clear();
        for (BaseDataType item : data) {
            if (item.getType() == BaseDataType.STATUS_MSG_DATA_TYPE) {
                mStatusList.add((StatusMsg) item);
            } else {
                completeUiRequest(ServiceStatus.ERROR_UNEXPECTED_RESPONSE);
                return;
            }
        }
        bu = new Bundle();
        bu.putParcelableArrayList(KEY_DATA, mStatusList);
    }
    completeUiRequest(errorStatus, bu);
    newState(State.IDLE);
}
Also used : Bundle(android.os.Bundle) ServiceStatus(com.vodafone360.people.service.ServiceStatus) BaseDataType(com.vodafone360.people.datatypes.BaseDataType)

Example 22 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class IdentityEngine method handleValidateIdentityCredentials.

/**
 * Handle Server response to set validate credentials request. The response
 * should be a Status-msg indicating whether the request has succeeded or
 * failed. The request is completed with the status result (or
 * ERROR_UNEXPECTED_RESPONSE if the data-type retrieved is not a
 * Status-msg).
 *
 * @param data List of BaseDataTypes generated from Server response.
 */
private void handleValidateIdentityCredentials(List<BaseDataType> data) {
    Bundle bu = null;
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.STATUS_MSG_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        mStatusList.clear();
        for (BaseDataType item : data) {
            if (item.getType() == BaseDataType.STATUS_MSG_DATA_TYPE) {
                mStatusList.add((StatusMsg) item);
            } else {
                completeUiRequest(ServiceStatus.ERROR_UNEXPECTED_RESPONSE);
                return;
            }
        }
        bu = new Bundle();
        if (mStatusList.size() == 1) {
            bu.putBoolean("status", mStatusList.get(0).mStatus);
        } else {
            LogUtils.logW("Status list sould have one item. It has " + mStatusList.size());
            bu.putParcelableArrayList(KEY_DATA, mStatusList);
        }
    }
    completeUiRequest(errorStatus, bu);
    newState(State.IDLE);
    if (errorStatus == ServiceStatus.SUCCESS) {
        addUiRequestToQueue(ServiceUiRequest.GET_MY_IDENTITIES, null);
    } else if (errorStatus == ServiceStatus.ERROR_COMMS_TIMEOUT) {
        // if we timeout we need to clear our pending identities
        clearPendingIdentities();
    }
}
Also used : Bundle(android.os.Bundle) ServiceStatus(com.vodafone360.people.service.ServiceStatus) BaseDataType(com.vodafone360.people.datatypes.BaseDataType)

Example 23 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class IdentityEngine method handleGetMyIdentitiesResponse.

/**
 * Handle Server response to request for available Identities. The response
 * should be a list of Identity items. The request is completed with
 * ServiceStatus.SUCCESS or ERROR_UNEXPECTED_RESPONSE if the data-type
 * retrieved are not Identity items.
 *
 * @param data List of BaseDataTypes generated from Server response.
 */
private void handleGetMyIdentitiesResponse(List<BaseDataType> data) {
    LogUtils.logD("IdentityEngine: handleGetMyIdentitiesResponse");
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.MY_IDENTITY_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        synchronized (mMyIdentityList) {
            mMyIdentityList.clear();
            for (BaseDataType item : data) {
                Identity identity = (Identity) item;
                if (!identity.isIdentityFieldBlankorNull()) {
                    mMyIdentityList.add(identity);
                }
            }
            // cache the identities
            MyIdentitiesCacheTable.setCachedIdentities(mDatabaseHelper.getWritableDatabase(), mMyIdentityList);
            clearPendingIdentities();
        }
    } else if (errorStatus == ServiceStatus.ERROR_COMMS_TIMEOUT) {
        // reset the pending list in case of a timeout
        clearPendingIdentities();
    }
    pushIdentitiesToUi(ServiceUiRequest.GET_MY_IDENTITIES);
    // remove any identites returned from the pending list as they are validated by now!
    removePendingIdentities(mMyIdentityList);
    LogUtils.logD("IdentityEngine: handleGetMyIdentitiesResponse complete request.");
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) Identity(com.vodafone360.people.datatypes.Identity)

Example 24 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class IdentityEngine method handleDeleteIdentity.

/**
 * Handle Server response of request to delete the identity. The response
 * should be a status that whether the operation is succeeded or not. The
 * response will be a status result otherwise ERROR_UNEXPECTED_RESPONSE if
 * the response is not as expected.
 *
 * @param data
 *            List of BaseDataTypes generated from Server response.
 */
private void handleDeleteIdentity(final List<BaseDataType> data) {
    Bundle bu = null;
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.IDENTITY_DELETION_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        for (BaseDataType item : data) {
            if (item.getType() == BaseDataType.IDENTITY_DELETION_DATA_TYPE) {
                synchronized (mMyIdentityList) {
                    // iterating through the subscribed identities
                    for (Identity identity : mMyIdentityList) {
                        if (identity.mIdentityId.equals(getIdentityToBeDeleted().mIdentityId)) {
                            mMyIdentityList.remove(identity);
                            break;
                        }
                    }
                    // cache the new set of identities
                    MyIdentitiesCacheTable.setCachedIdentities(mDatabaseHelper.getWritableDatabase(), mMyIdentityList);
                }
                completeUiRequest(ServiceStatus.SUCCESS);
                return;
            } else {
                completeUiRequest(ServiceStatus.ERROR_UNEXPECTED_RESPONSE);
                return;
            }
        }
    }
    completeUiRequest(errorStatus, bu);
}
Also used : Bundle(android.os.Bundle) ServiceStatus(com.vodafone360.people.service.ServiceStatus) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) Identity(com.vodafone360.people.datatypes.Identity)

Example 25 with BaseDataType

use of com.vodafone360.people.datatypes.BaseDataType in project 360-Engine-for-Android by 360.

the class LoginEngine method handleSignUpResponse.

/**
 * Called when a response to the sign-up API is received. In case of success
 * sets a timeout value waiting for the activation SMS to arrive.
 *
 * @param data The received data
 */
private void handleSignUpResponse(List<BaseDataType> data) {
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.CONTACT_DATA_TYPE, data);
    LogUtils.logD("LoginEngine.handleSignUpResponse() errorStatus[" + errorStatus.name() + "]");
    if (errorStatus == ServiceStatus.SUCCESS) {
        LogUtils.logD("LoginEngine.handleSignUpResponse() - Registration successful");
        if (!Settings.ENABLE_ACTIVATION) {
            startGetSessionManual();
        } else {
            // Now waiting for SMS...
            setTimeout(ACTIVATE_LOGIN_TIMEOUT);
        }
    // AA
    } else if (errorStatus == ServiceStatus.ERROR_INVALID_PUBLIC_KEY) {
        // start new key retrieval and make the new cycle
        getNewPublicKey();
    } else {
        completeUiRequest(errorStatus, null);
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

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