Search in sources :

Example 26 with Request

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

Example 27 with Request

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

Example 28 with Request

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

Example 29 with Request

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

Example 30 with Request

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

Aggregations

Request (com.vodafone360.people.service.io.Request)43 QueueManager (com.vodafone360.people.service.io.QueueManager)27 ServiceStatus (com.vodafone360.people.service.ServiceStatus)16 ArrayList (java.util.ArrayList)16 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)12 ServiceUiRequest (com.vodafone360.people.service.ServiceUiRequest)12 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)11 Suppress (android.test.suitebuilder.annotation.Suppress)10 DatabaseHelper (com.vodafone360.people.database.DatabaseHelper)9 IEngineEventCallback (com.vodafone360.people.engine.IEngineEventCallback)9 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)9 ProcessorFactory (com.vodafone360.people.engine.contactsync.ProcessorFactory)9 ServerError (com.vodafone360.people.datatypes.ServerError)6 IOException (java.io.IOException)6 Identity (com.vodafone360.people.datatypes.Identity)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Bundle (android.os.Bundle)4 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)4 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)4 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)4