Search in sources :

Example 1 with SystemNotification

use of com.vodafone360.people.datatypes.SystemNotification in project 360-Engine-for-Android by 360.

the class SyncMeEngine method processMeProfileThumbnailResponse.

/**
 * This method stores the thumbnail picture for the me profile
 * @param resp Response - normally contains ExternalResponseObject for the
 *            picture
 */
private void processMeProfileThumbnailResponse(final DecodedResponse resp) {
    if (resp.mDataTypes.size() == 0) {
        LogUtils.logE("SyncMeProfile processMeProfileThumbnailResponse():" + SystemNotification.SysNotificationCode.EXTERNAL_HTTP_ERROR);
        completeUiRequest(ServiceStatus.ERROR_COMMS_BAD_RESPONSE);
        return;
    }
    Contact currentMeProfile = new Contact();
    ServiceStatus status = SyncMeDbUtils.fetchMeProfile(mDbHelper, currentMeProfile);
    if (status == ServiceStatus.SUCCESS) {
        if (resp.mReqId == null || resp.mReqId == 0) {
            if (resp.mDataTypes.get(0).getType() == BaseDataType.SYSTEM_NOTIFICATION_DATA_TYPE && ((SystemNotification) resp.mDataTypes.get(0)).getSysCode() == SystemNotification.SysNotificationCode.EXTERNAL_HTTP_ERROR) {
                LogUtils.logE("SyncMeProfile processMeProfileThumbnailResponse():" + SystemNotification.SysNotificationCode.EXTERNAL_HTTP_ERROR);
            }
            completeUiRequest(status);
            return;
        } else if (resp.mDataTypes.get(0).getType() == BaseDataType.SYSTEM_NOTIFICATION_DATA_TYPE) {
            if (((SystemNotification) resp.mDataTypes.get(0)).getSysCode() == SystemNotification.SysNotificationCode.EXTERNAL_HTTP_ERROR) {
                LogUtils.logE("SyncMeProfile processMeProfileThumbnailResponse():" + SystemNotification.SysNotificationCode.EXTERNAL_HTTP_ERROR);
            }
            completeUiRequest(status);
            return;
        }
        status = BaseEngine.getResponseStatus(BaseDataType.EXTERNAL_RESPONSE_OBJECT_DATA_TYPE, resp.mDataTypes);
        if (status != ServiceStatus.SUCCESS) {
            completeUiRequest(ServiceStatus.ERROR_COMMS_BAD_RESPONSE);
            LogUtils.logE("SyncMeProfile processMeProfileThumbnailResponse() - Can't read response");
            return;
        }
        if (resp.mDataTypes == null || resp.mDataTypes.isEmpty()) {
            LogUtils.logE("SyncMeProfile processMeProfileThumbnailResponse() - Datatypes are null");
            completeUiRequest(ServiceStatus.ERROR_COMMS_BAD_RESPONSE);
            return;
        }
        // finally save the thumbnails
        ExternalResponseObject ext = (ExternalResponseObject) resp.mDataTypes.get(0);
        if (ext.mBody == null) {
            LogUtils.logE("SyncMeProfile processMeProfileThumbnailResponse() - no body");
            completeUiRequest(ServiceStatus.ERROR_COMMS_BAD_RESPONSE);
            return;
        }
        try {
            ThumbnailUtils.saveExternalResponseObjectToFile(currentMeProfile.localContactID, ext);
            ContactSummaryTable.modifyPictureLoadedFlag(currentMeProfile.localContactID, true, mDbHelper.getWritableDatabase());
            mDbHelper.markMeProfileAvatarChanged();
        } catch (IOException e) {
            LogUtils.logE("SyncMeProfile processMeProfileThumbnailResponse()", e);
            completeUiRequest(ServiceStatus.ERROR_COMMS_BAD_RESPONSE);
        }
    }
    completeUiRequest(status);
}
Also used : SystemNotification(com.vodafone360.people.datatypes.SystemNotification) ExternalResponseObject(com.vodafone360.people.datatypes.ExternalResponseObject) ServiceStatus(com.vodafone360.people.service.ServiceStatus) IOException(java.io.IOException) Contact(com.vodafone360.people.datatypes.Contact)

Example 2 with SystemNotification

use of com.vodafone360.people.datatypes.SystemNotification in project 360-Engine-for-Android by 360.

the class PresenceEngine method handleSystemNotification.

private void handleSystemNotification(SystemNotification sn) {
    LogUtils.logE("PresenceEngine.handleServerResponse(): " + sn);
    switch(sn.getSysCode()) {
        case SEND_MESSAGE_FAILED:
            ChatMessage msg = mSendMessagesHash.get(sn.getInfo().get(Tags.TOS.toString()));
            if (msg != null) {
                ChatDbUtils.deleteUnsentMessage(mDbHelper, msg);
            }
            showErrorNotification(ServiceUiRequest.UNSOLICITED_CHAT_ERROR_REFRESH, null);
            break;
        case CONVERSATION_NULL:
            if (!mSendMessagesHash.isEmpty()) {
                mSendMessagesHash.remove(sn.getInfo().get(Tags.TOS.toString()));
            }
            showErrorNotification(ServiceUiRequest.UNSOLICITED_CHAT_ERROR, null);
            break;
        case COMMUNITY_LOGOUT_SUCCESSFUL:
            break;
        default:
            LogUtils.logE("PresenceEngine.handleServerResponse()" + " - unhandled notification: " + sn);
    }
}
Also used : ChatMessage(com.vodafone360.people.datatypes.ChatMessage)

Example 3 with SystemNotification

use of com.vodafone360.people.datatypes.SystemNotification in project 360-Engine-for-Android by 360.

the class HessianDecoderTest method testPushMessages.

/*
	@MediumTest
	public void testContactChangesResponse(){
		
	}
	*/
@MediumTest
public void testPushMessages() {
    List<BaseDataType> clist = new ArrayList<BaseDataType>();
    HessianDecoder hess = new HessianDecoder();
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(7, testPcPushMsgData, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    int size = clist.size();
    assertTrue(size == 1);
    assertTrue(clist.get(0) instanceof PushEvent);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(8, testCcPushMsgData, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 1);
    assertTrue(clist.get(0) instanceof PushEvent);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(9, testSnPushMsgData, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 1);
    assertTrue(clist.get(0) instanceof SystemNotification);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(10, testSnPushMsgData2, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 1);
    assertTrue(clist.get(0) instanceof SystemNotification);
    try {
        DecodedResponse resp = hess.decodeHessianByteArray(11, testUnknownPushMsgData, Type.PUSH_MSG, false, EngineId.UNDEFINED);
        clist = resp.mDataTypes;
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue("IOException thrown", false);
    }
    size = clist.size();
    assertTrue(size == 0);
// assertTrue(clist.get(0) instanceof PushEvent);
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) SystemNotification(com.vodafone360.people.datatypes.SystemNotification) PushEvent(com.vodafone360.people.datatypes.PushEvent) ArrayList(java.util.ArrayList) HessianDecoder(com.vodafone360.people.service.utils.hessian.HessianDecoder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) IOException(java.io.IOException) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

SystemNotification (com.vodafone360.people.datatypes.SystemNotification)2 IOException (java.io.IOException)2 MediumTest (android.test.suitebuilder.annotation.MediumTest)1 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)1 ChatMessage (com.vodafone360.people.datatypes.ChatMessage)1 Contact (com.vodafone360.people.datatypes.Contact)1 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)1 PushEvent (com.vodafone360.people.datatypes.PushEvent)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)1 HessianDecoder (com.vodafone360.people.service.utils.hessian.HessianDecoder)1 ArrayList (java.util.ArrayList)1