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);
}
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);
}
}
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);
}
Aggregations