Search in sources :

Example 1 with EngineManager

use of com.vodafone360.people.engine.EngineManager in project 360-Engine-for-Android by 360.

the class MainApplication method removeUserData.

/**
     * Remove all user data from People client, this includes all account
     * information (downloaded contacts, login credentials etc.) and all cached
     * settings.
     */
public synchronized void removeUserData() {
    EngineManager mEngineManager = EngineManager.getInstance();
    if (mEngineManager != null) {
        // Resets all the engines, the call will block until every engines
        // have been reset.
        mEngineManager.resetAllEngines();
    }
    // Remove NAB Account at this point (does nothing on 1.X)
    NativeContactsApi.getInstance().removePeopleAccount();
    // the same action as in NetworkSettingsActivity onChecked()
    setInternetAvail(InternetAvail.ALWAYS_CONNECT, false);
    mDatabaseHelper.removeUserData();
    // Before clearing the Application cache, kick the widget update. Pref's
    // file contain the widget ID.
    WidgetUtils.kickWidgetUpdateNow(this);
    mApplicationCache.clearCachedData(this);
}
Also used : EngineManager(com.vodafone360.people.engine.EngineManager)

Example 2 with EngineManager

use of com.vodafone360.people.engine.EngineManager in project 360-Engine-for-Android by 360.

the class PeopleServiceImpl method logon.

/***
     * @see com.vodafone360.people.service.interfaces.IPeopleService#logon(LoginDetails)
     */
@Override
public void logon(LoginDetails loginDetails) {
    EngineManager manager = EngineManager.getInstance();
    manager.getLoginEngine().addUiLoginRequest(loginDetails);
}
Also used : EngineManager(com.vodafone360.people.engine.EngineManager)

Example 3 with EngineManager

use of com.vodafone360.people.engine.EngineManager 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 4 with EngineManager

use of com.vodafone360.people.engine.EngineManager in project 360-Engine-for-Android by 360.

the class EngineManager method onCommsInMessage.

/**
     * Respond to incoming message received from Comms layer. If this message
     * has a valid engine id it is routed to that engine, otherwise The
     * {@link EngineManager} will try to get the next response.
     * 
     * @param source EngineId associated with incoming message.
     */
public void onCommsInMessage(EngineId source) {
    BaseEngine engine = null;
    if (source != null) {
        engine = mEngineList.get(source.ordinal());
    }
    if (engine != null) {
        engine.onCommsInMessage();
    } else {
        LogUtils.logE("EngineManager.onCommsInMessage - " + "Cannot dispatch message, unknown source " + source);
        final ResponseQueue queue = ResponseQueue.getInstance();
        queue.getNextResponse(source);
    }
}
Also used : ResponseQueue(com.vodafone360.people.service.io.ResponseQueue)

Example 5 with EngineManager

use of com.vodafone360.people.engine.EngineManager in project 360-Engine-for-Android by 360.

the class ActivitiesEngine method processCommsResponse.

/**
     * Handle response received from transport layer (via EngineManager)
     * 
     * @param resp Received Response item either a Status/Timeline related push
     *            message or a response to a get activities request.
     */
@Override
protected void processCommsResponse(DecodedResponse resp) {
    LogUtils.logD("ActivitiesEngine processCommsResponse");
    // handle push response
    if (resp.mReqId == 0 && resp.mDataTypes.size() > 0) {
        PushEvent evt = (PushEvent) resp.mDataTypes.get(0);
        handlePushRequest(evt.mMessageType);
    } else {
        dequeueRequest(resp.mReqId);
        handleGetActivitiesResponse(resp.mDataTypes);
    }
}
Also used : PushEvent(com.vodafone360.people.datatypes.PushEvent)

Aggregations

EngineManager (com.vodafone360.people.engine.EngineManager)4 ServiceStatus (com.vodafone360.people.service.ServiceStatus)2 Bundle (android.os.Bundle)1 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)1 PushEvent (com.vodafone360.people.datatypes.PushEvent)1 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)1 ArrayList (java.util.ArrayList)1