Search in sources :

Example 36 with Request

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

the class ResponseQueue method addToResponseQueue.

/**
     * Adds a response item to the queue.
     * 
     * @param reqId The request ID to add the response for.
     * @param data The response data to add to the queue.
     * @param source The corresponding engine that fired off the request for the
     *            response.
     */
public void addToResponseQueue(final DecodedResponse response) {
    synchronized (QueueManager.getInstance().lock) {
        ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.UNKNOWN_DATA_TYPE, response.mDataTypes);
        if (status == ServiceStatus.ERROR_INVALID_SESSION) {
            EngineManager em = EngineManager.getInstance();
            if (em != null) {
                LogUtils.logE("Logging out the current user because of invalide session");
                em.getLoginEngine().logoutAndRemoveUser();
                return;
            }
        }
        synchronized (mResponses) {
            mResponses.add(response);
        }
        Request request = RequestQueue.getInstance().removeRequest(response.mReqId);
        if (request != null) {
            // we suppose the response being handled by the same engine 
            // that issued the request with the given id
            response.mSource = request.mEngineId;
        }
        mEngMgr = EngineManager.getInstance();
        if (mEngMgr != null) {
            mEngMgr.onCommsInMessage(response.mSource);
        }
    }
}
Also used : EngineManager(com.vodafone360.people.engine.EngineManager) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 37 with Request

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

the class Chat method startChat.

/**
     * Starts new chat session
     * 
     * @param recipients - list of UserIds
     * @return request id
     */
public static int startChat(List<String> recipients) {
    if (recipients == null) {
        LogUtils.logE("Chat.sentChatMessage() recipients can't be null");
        return -1;
    }
    Request request = new Request(EMPTY, Request.Type.CREATE_CONVERSATION, EngineId.PRESENCE_ENGINE, false, Settings.API_REQUESTS_TIMEOUT_CHAT_CREATE_CONV);
    request.addData(ChatMessage.Tags.RECIPIENTS_LIST.tag(), recipients);
    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 38 with Request

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

the class Contacts method getMyChanges.

/**
     * Implementation of contacts/getmychanges. Parameters are; [auth], Long
     * fromrevision
     * 
     * @param engine Handle to ContactSync engine
     * @param fromrevision Start revision.
     * @return request id generated for this request.
     */
public static int getMyChanges(BaseEngine engine, Long fromrevision) {
    if (LoginEngine.getSession() == null) {
        LogUtils.logE("Contacts.getMyChanges() Invalid session, return -1");
        return -1;
    }
    Request request = new Request(FUNCTION_GET_MY_CHANGES, Request.Type.CONTACT_CHANGES_OR_UPDATES, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
    request.addData("fromrevision", fromrevision.toString());
    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 39 with Request

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

the class Contacts method deleteContactDetails.

/**
     * Implementation of contacts/deletecontactdetails API. Parameters are;
     * [auth], Long contactid, List<ContactDetail> detaillist
     * 
     * @param engine Handle to ContactSync engine
     * @param contactid
     * @param detaillist
     * @return request id generated for this request.
     */
public static int deleteContactDetails(BaseEngine engine, Long contactid, List<ContactDetail> detaillist) {
    if (LoginEngine.getSession() == null) {
        LogUtils.logE("Contacts.deleteContactDetails() Invalid session, return -1");
        return -1;
    }
    if (contactid == null) {
        LogUtils.logE("Contacts.deleteContactDetails() contactidlist cannot be NULL");
        return -1;
    }
    if (detaillist == null) {
        LogUtils.logE("Contacts.deleteContactDetails() detaillist cannot be NULL");
        return -1;
    }
    Request request = new Request(FUNCTION_DELETE_CONTACT_DETAILS, Request.Type.CONTACT_DETAIL_DELETE, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
    request.addData("contactid", contactid);
    request.addData("detaillist", ApiUtils.createVectorOfContactDetail(detaillist));
    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 40 with Request

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

the class Contacts method bulkUpdateContacts.

/**
     * Implementation of contacts/bulkupdatecontacts API. Parameters are;
     * [auth], List<Contact> contactlist
     * 
     * @param engine Handle to ContactSync engine
     * @param contactlist List containing the contacts to be updated on server.
     * @return request id generated for this request.
     */
public static int bulkUpdateContacts(BaseEngine engine, List<Contact> contactlist) {
    if (LoginEngine.getSession() == null) {
        LogUtils.logE("Contacts.bulkUpdateContacts() Invalid session, return -1");
        return -1;
    }
    if (contactlist == null) {
        LogUtils.logE("Contacts.bulkUpdateContacts() contactidlist cannot be NULL");
        return -1;
    }
    Request request = new Request(FUNCTION_BULK_UPDATE_CONTACTS, Request.Type.CONTACT_CHANGES_OR_UPDATES, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
    request.addData("contactlist", ApiUtils.createVectorOfContact(contactlist));
    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)

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