Search in sources :

Example 41 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class SyncMeEngine method processPushEvent.

/**
     * This method process the "pc" push event.
     * @param resp Response - server response normally containing a "pc"
     *            PushEvent data type
     * @return boolean - TRUE if a push event was found in the response
     */
private boolean processPushEvent(final 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("SyncMeEngine processPushMessage():" + pushEvent.mMessageType);
    switch(pushEvent.mMessageType) {
        case PROFILE_CHANGE:
            addGetMeProfileContactRequest();
            break;
        default:
            break;
    }
    return true;
}
Also used : PushEvent(com.vodafone360.people.datatypes.PushEvent) BaseDataType(com.vodafone360.people.datatypes.BaseDataType)

Example 42 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class Auth method getPublicKey.

/**
     * Implementation of "auth/getpublickey" API.
     * 
     * @param engine Handle to LoginEngine which handles requests using this
     *            API.
     * @return Request ID generated for this request.
     * @throws NullPointerException when engine is NULL
     */
public static int getPublicKey(BaseEngine engine) {
    if (engine == null) {
        throw new NullPointerException("Auth.getPublicKey() engine cannot be NULL");
    }
    Request request = new Request(FUNCTION_GET_PUBLIC_KEY, Request.Type.RETRIEVE_PUBLIC_KEY, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData("type", "all");
    QueueManager queue = QueueManager.getInstance();
    int requestId = queue.addRequest(request);
    queue.fireQueueStateChanged();
    return requestId;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Example 43 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class IdentityEngine method handleGetAvailableIdentitiesResponse.

/**
     * 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 handleGetAvailableIdentitiesResponse(List<BaseDataType> data) {
    LogUtils.logD("IdentityEngine: handleServerGetAvailableIdentitiesResponse");
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.AVAILABLE_IDENTITY_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        synchronized (mAvailableIdentityList) {
            mAvailableIdentityList.clear();
            for (BaseDataType item : data) {
                Identity identity = (Identity) item;
                if (!identity.isIdentityFieldBlankorNull()) {
                    mAvailableIdentityList.add(identity);
                }
            }
        }
    }
    pushIdentitiesToUi(ServiceUiRequest.GET_AVAILABLE_IDENTITIES);
    LogUtils.logD("IdentityEngine: handleGetAvailableIdentitiesResponse complete request.");
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) Identity(com.vodafone360.people.datatypes.Identity)

Example 44 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class PresenceEngine method updateChatDatabase.

/**
     * Updates the database with the given ChatMessage and Type.
     * 
     * @param message ChatMessage.
     * @param type TimelineSummaryItem.Type.
     */
private void updateChatDatabase(ChatMessage message, TimelineSummaryItem.Type type) {
    ChatDbUtils.convertUserIds(message, mDbHelper);
    LogUtils.logD("PresenceEngine.updateChatDatabase() with [" + type.name() + "] message");
    if (message.getLocalContactId() == null || message.getLocalContactId() < 0) {
        LogUtils.logE("PresenceEngine.updateChatDatabase() " + "WILL NOT UPDATE THE DB! - INVALID localContactId = " + message.getLocalContactId());
        return;
    }
    /** We mark all incoming messages as unread. **/
    ChatDbUtils.saveChatMessageAsATimeline(message, type, mDbHelper);
    UiAgent uiAgent = mEventCallback.getUiAgent();
    if (uiAgent != null && (message.getLocalContactId() != -1)) {
        uiAgent.updateChat(message.getLocalContactId(), true, message.getNetworkId());
    }
}
Also used : UiAgent(com.vodafone360.people.service.agent.UiAgent)

Example 45 with Type

use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.

the class HttpConnectionThread method addErrorToResponseQueue.

/**
     * Adds errors to the response queue whenever there is an HTTP error on the
     * backend.
     * 
     * @param reqIds The request IDs the error happened for.
     */
public void addErrorToResponseQueue(List<Integer> reqIds) {
    EngineId source = null;
    QueueManager requestQueue = QueueManager.getInstance();
    ResponseQueue responseQueue = ResponseQueue.getInstance();
    for (Integer reqId : reqIds) {
        // attempt to get type from request
        Request req = requestQueue.getRequest(reqId);
        if (req != null)
            source = req.mEngineId;
        responseQueue.addToResponseQueue(new DecodedResponse(reqId, null, source, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) EngineId(com.vodafone360.people.engine.EngineManager.EngineId) Request(com.vodafone360.people.service.io.Request) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue) QueueManager(com.vodafone360.people.service.io.QueueManager)

Aggregations

ArrayList (java.util.ArrayList)14 Suppress (android.test.suitebuilder.annotation.Suppress)13 DatabaseHelper (com.vodafone360.people.database.DatabaseHelper)11 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)11 IEngineEventCallback (com.vodafone360.people.engine.IEngineEventCallback)11 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)11 ProcessorFactory (com.vodafone360.people.engine.contactsync.ProcessorFactory)11 ServiceStatus (com.vodafone360.people.service.ServiceStatus)10 ServiceUiRequest (com.vodafone360.people.service.ServiceUiRequest)10 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)7 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)6 Identity (com.vodafone360.people.datatypes.Identity)6 Request (com.vodafone360.people.service.io.Request)5 Cursor (android.database.Cursor)4 Contact (com.vodafone360.people.datatypes.Contact)4 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)4 ServerError (com.vodafone360.people.datatypes.ServerError)4 SQLException (android.database.SQLException)3 SQLiteException (android.database.sqlite.SQLiteException)3 Bundle (android.os.Bundle)3