Search in sources :

Example 1 with PresenceEngine

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

the class PresenceEngine method handleServerError.

private void handleServerError(ServerError srvError) {
    LogUtils.logE("PresenceEngine.handleServerResponse() - Server error: " + srvError);
    ServiceStatus errorStatus = srvError.toServiceStatus();
    if (errorStatus == ServiceStatus.ERROR_COMMS_TIMEOUT) {
        LogUtils.logW("PresenceEngine handleServerResponce(): TIME OUT IS RETURNED TO PRESENCE ENGINE.");
        notifyUiAgentOfTimeOut(srvError.requestId);
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 2 with PresenceEngine

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

the class EngineManager method createPresenceEngine.

/**
     * Create instance of PresenceEngine.
     */
private synchronized void createPresenceEngine() {
    final MainApplication app = (MainApplication) mService.getApplication();
    mPresenceEngine = new PresenceEngine(mUiEventCallback, app.getDatabase());
    ConnectionManager.getInstance().addConnectionListener(mPresenceEngine);
    getLoginEngine().addListener(mPresenceEngine);
    addEngine(mPresenceEngine);
}
Also used : MainApplication(com.vodafone360.people.MainApplication) PresenceEngine(com.vodafone360.people.engine.presence.PresenceEngine)

Example 3 with PresenceEngine

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

the class PresenceEngineTest method setUp.

//private MainApplication mApplication = null;
//private PresenceTestState mState = PresenceTestState.IDLE;
@Override
protected void setUp() throws Exception {
    super.setUp();
    mEngineTester = new EngineTestFramework(this);
    mEng = new PresenceEngine(mEngineTester, null);
    //mApplication = (MainApplication)Instrumentation.newApplication(MainApplication.class, getInstrumentation().getTargetContext());
    mEngineTester.setEngine(mEng);
//mState = PresenceTestState.IDLE;
}
Also used : EngineTestFramework(com.vodafone360.people.tests.engine.EngineTestFramework) PresenceEngine(com.vodafone360.people.engine.presence.PresenceEngine)

Example 4 with PresenceEngine

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

the class PresenceEngine method processUiRequest.

@Override
protected void processUiRequest(ServiceUiRequest requestId, Object data) {
    if (!isFirstTimeSyncComplete()) {
        LogUtils.logE("PresenceEngine.processUIRequest():" + " Can't run PresenceEngine before the contact list is downloaded:1");
        return;
    }
    LogUtils.logW("PresenceEngine.processUiRequest() requestId.name[" + requestId.name() + "]");
    if (data == null && requestId != ServiceUiRequest.GET_PRESENCE_LIST) {
        LogUtils.logW("PresenceEngine.processUiRequest() skipping processing for request with no data!");
        return;
    }
    switch(requestId) {
        case SET_MY_AVAILABILITY:
            Hashtable<String, String> presenceHash = (Hashtable<String, String>) data;
            notifyUiAgentOfRequest(Presence.setMyAvailability(presenceHash), presenceHash);
            break;
        case GET_PRESENCE_LIST:
            Presence.getPresenceList(EngineId.PRESENCE_ENGINE, null);
            break;
        case CREATE_CONVERSATION:
            List<String> tos = ((ChatMessage) data).getTos();
            LogUtils.logW("PresenceEngine processUiRequest() CREATE_CONVERSATION with: " + tos);
            Chat.startChat(tos);
            break;
        case SEND_CHAT_MESSAGE:
            ChatMessage msg = (ChatMessage) data;
            updateChatDatabase(msg, TimelineSummaryItem.Type.OUTGOING);
            //cache the message (necessary for failed message sending failures)
            mSendMessagesHash.put(msg.getTos().get(0), msg);
            Chat.sendChatMessage(msg);
            break;
        default:
            LogUtils.logE("PresenceEngine processUiRequest() Unhandled UI request [" + requestId.name() + "]");
            // don't complete with success and schedule the next runtime
            return;
    }
    completeUiRequest(ServiceStatus.SUCCESS, null);
    setTimeout(CHECK_FREQUENCY);
}
Also used : ChatMessage(com.vodafone360.people.datatypes.ChatMessage) Hashtable(java.util.Hashtable)

Aggregations

PresenceEngine (com.vodafone360.people.engine.presence.PresenceEngine)2 MainApplication (com.vodafone360.people.MainApplication)1 ChatMessage (com.vodafone360.people.datatypes.ChatMessage)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1 EngineTestFramework (com.vodafone360.people.tests.engine.EngineTestFramework)1 Hashtable (java.util.Hashtable)1