use of com.vodafone360.people.datatypes.StatusMsg in project 360-Engine-for-Android by 360.
the class IdentityEngine method handleValidateIdentityCredentials.
/**
* Handle Server response to set validate credentials request. The response
* should be a Status-msg indicating whether the request has succeeded or
* failed. The request is completed with the status result (or
* ERROR_UNEXPECTED_RESPONSE if the data-type retrieved is not a
* Status-msg).
*
* @param data List of BaseDataTypes generated from Server response.
*/
private void handleValidateIdentityCredentials(List<BaseDataType> data) {
Bundle bu = null;
ServiceStatus errorStatus = getResponseStatus(BaseDataType.STATUS_MSG_DATA_TYPE, data);
if (errorStatus == ServiceStatus.SUCCESS) {
mStatusList.clear();
for (BaseDataType item : data) {
if (item.getType() == BaseDataType.STATUS_MSG_DATA_TYPE) {
mStatusList.add((StatusMsg) item);
} else {
completeUiRequest(ServiceStatus.ERROR_UNEXPECTED_RESPONSE);
return;
}
}
bu = new Bundle();
if (mStatusList.size() == 1) {
bu.putBoolean("status", mStatusList.get(0).mStatus);
} else {
LogUtils.logW("Status list sould have one item. It has " + mStatusList.size());
bu.putParcelableArrayList(KEY_DATA, mStatusList);
}
}
completeUiRequest(errorStatus, bu);
newState(State.IDLE);
if (errorStatus == ServiceStatus.SUCCESS) {
addUiRequestToQueue(ServiceUiRequest.GET_MY_IDENTITIES, null);
} else if (errorStatus == ServiceStatus.ERROR_COMMS_TIMEOUT) {
// if we timeout we need to clear our pending identities
clearPendingIdentities();
}
}
use of com.vodafone360.people.datatypes.StatusMsg in project 360-Engine-for-Android by 360.
the class IdentityEngine method handleSetIdentityStatus.
/**
* Handle Server response to set capability status request. The response
* should be a Status-msg indicating whether the request has succeeded or
* failed. The request is completed with the status result (or
* ERROR_UNEXPECTED_RESPONSE if the data-type retrieved is not a
* Status-msg).
*
* @param data List of BaseDataTypes generated from Server response.
*/
private void handleSetIdentityStatus(List<BaseDataType> data) {
Bundle bu = null;
ServiceStatus errorStatus = getResponseStatus(BaseDataType.STATUS_MSG_DATA_TYPE, data);
if (errorStatus == ServiceStatus.SUCCESS) {
mStatusList.clear();
for (BaseDataType item : data) {
if (item.getType() == BaseDataType.STATUS_MSG_DATA_TYPE) {
mStatusList.add((StatusMsg) item);
} else {
completeUiRequest(ServiceStatus.ERROR_UNEXPECTED_RESPONSE);
return;
}
}
bu = new Bundle();
bu.putParcelableArrayList(KEY_DATA, mStatusList);
}
completeUiRequest(errorStatus, bu);
newState(State.IDLE);
}
use of com.vodafone360.people.datatypes.StatusMsg in project 360-Engine-for-Android by 360.
the class HessianDecoder method decodeResponseByRequestType.
/**
* Parses the hashtables retrieved from the hessian payload that came from the server and
* returns a type for it.
*
* @param clist The list that will be populated with the data types.
* @param hash The hash table that contains the parsed date returned by the backend.
* @param type The type of the request that was sent, e.g. get contacts changes.
*
* @return The type of the response that was parsed (to be found in DecodedResponse.ResponseType).
*/
private int decodeResponseByRequestType(List<BaseDataType> clist, Hashtable<String, Object> hash, Request.Type type) {
int responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
switch(type) {
case CONTACT_CHANGES_OR_UPDATES:
responseType = DecodedResponse.ResponseType.GET_CONTACTCHANGES_RESPONSE.ordinal();
// create ContactChanges
ContactChanges contChanges = new ContactChanges();
contChanges = contChanges.createFromHashtable(hash);
clist.add(contChanges);
break;
case ADD_CONTACT:
clist.add(Contact.createFromHashtable(hash));
responseType = DecodedResponse.ResponseType.ADD_CONTACT_RESPONSE.ordinal();
break;
case SIGN_UP:
clist.add(Contact.createFromHashtable(hash));
responseType = DecodedResponse.ResponseType.SIGNUP_RESPONSE.ordinal();
break;
case RETRIEVE_PUBLIC_KEY:
// AA define new object type
clist.add(PublicKeyDetails.createFromHashtable(hash));
responseType = DecodedResponse.ResponseType.RETRIEVE_PUBLIC_KEY_RESPONSE.ordinal();
break;
case CONTACT_DELETE:
ContactListResponse cresp = new ContactListResponse();
cresp.createFromHashTable(hash);
// add ids
@SuppressWarnings("unchecked") Vector<Long> contactIds = (Vector<Long>) hash.get(KEY_CONTACT_ID_LIST);
if (contactIds != null) {
for (Long cid : contactIds) {
cresp.mContactIdList.add((cid).intValue());
}
}
clist.add(cresp);
responseType = DecodedResponse.ResponseType.DELETE_CONTACT_RESPONSE.ordinal();
break;
case CONTACT_DETAIL_DELETE:
ContactDetailDeletion cdel = new ContactDetailDeletion();
clist.add(cdel.createFromHashtable(hash));
responseType = DecodedResponse.ResponseType.DELETE_CONTACT_DETAIL_RESPONSE.ordinal();
break;
case CONTACT_GROUP_RELATION_LIST:
ItemList groupRelationList = new ItemList(ItemList.Type.contact_group_relation);
groupRelationList.populateFromHashtable(hash);
clist.add(groupRelationList);
responseType = DecodedResponse.ResponseType.GET_CONTACT_GROUP_RELATIONS_RESPONSE.ordinal();
break;
case CONTACT_GROUP_RELATIONS:
ItemList groupRelationsList = new ItemList(ItemList.Type.contact_group_relations);
groupRelationsList.populateFromHashtable(hash);
clist.add(groupRelationsList);
responseType = DecodedResponse.ResponseType.GET_CONTACT_GROUP_RELATIONS_RESPONSE.ordinal();
break;
case DELETE_CONTACT_GROUP_RELATIONS:
// The hessian data sent by the backend is of the form
// r{1}{0}Mt{0}{0}zz. The MicroHessianInput always skips the 2 bytes
// after the type. This doesn't seem to be handling the case where
// the type is of length zero. Due to this, after decoding, the hash
// doesn't contain any elements/keys. Due to this, we are hardcoding
// the status to true here.
StatusMsg statusMsg = new StatusMsg();
statusMsg.mStatus = true;
clist.add(statusMsg);
responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
break;
case GROUP_LIST:
ItemList zyblist = new ItemList(ItemList.Type.group_privacy);
zyblist.populateFromHashtable(hash);
clist.add(zyblist);
responseType = DecodedResponse.ResponseType.GET_GROUPS_RESPONSE.ordinal();
break;
case ITEM_LIST_OF_LONGS:
ItemList listOfLongs = new ItemList(ItemList.Type.long_value);
listOfLongs.populateFromHashtable(hash);
clist.add(listOfLongs);
// TODO
responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
break;
case // TODO status and status list are used by many requests as a type. each request should have its own type however!
STATUS_LIST:
ItemList zybstatlist = new ItemList(ItemList.Type.status_msg);
zybstatlist.populateFromHashtable(hash);
clist.add(zybstatlist);
// TODO
responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
break;
case STATUS:
StatusMsg s = new StatusMsg();
s.mStatus = true;
clist.add(s);
// TODO
responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
break;
case TEXT_RESPONSE_ONLY:
Object val = hash.get("result");
if (val != null && val instanceof String) {
SimpleText txt = new SimpleText();
txt.addText((String) val);
clist.add(txt);
}
// TODO
responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
break;
case EXPECTING_STATUS_ONLY:
StatusMsg statMsg = new StatusMsg();
clist.add(statMsg.createFromHashtable(hash));
// TODO
responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
break;
case PRESENCE_LIST:
PresenceList mPresenceList = new PresenceList();
mPresenceList.createFromHashtable(hash);
clist.add(mPresenceList);
responseType = DecodedResponse.ResponseType.GET_PRESENCE_RESPONSE.ordinal();
break;
case PUSH_MSG:
// parse content of RPG Push msg
parsePushMessage(clist, hash);
responseType = DecodedResponse.ResponseType.PUSH_MESSAGE.ordinal();
break;
case CREATE_CONVERSATION:
Conversation mConversation = new Conversation();
mConversation.createFromHashtable(hash);
clist.add(mConversation);
responseType = DecodedResponse.ResponseType.CREATE_CONVERSATION_RESPONSE.ordinal();
break;
case DELETE_IDENTITY:
IdentityDeletion mIdenitityDeletion = new IdentityDeletion();
clist.add(mIdenitityDeletion.createFromHashtable(hash));
responseType = DecodedResponse.ResponseType.DELETE_IDENTITY_RESPONSE.ordinal();
break;
default:
LogUtils.logE("HessianDecoder.decodeResponseByRequestType() Unhandled type[" + type.name() + "]");
}
return responseType;
}
use of com.vodafone360.people.datatypes.StatusMsg in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method reportDeleteGroupListSuccess.
private void reportDeleteGroupListSuccess(int reqId, List<BaseDataType> data) {
Log.d(LOG_TAG, "reportDeleteGroupListSuccess");
mProcessor.verifyGroupDelsState();
final List<Long> contactIdList = new ArrayList<Long>();
Long activeGroupId = mProcessor.testFetchDeleteGroupList(contactIdList);
if (mItemCount == 1) {
assertEquals(Long.valueOf(TEST_GROUP_2), activeGroupId);
} else if (mItemCount == 2) {
assertEquals(Long.valueOf(TEST_GROUP_1), activeGroupId);
} else {
fail("Unexpected number of groups in delete group list");
}
StatusMsg statusMsg = new StatusMsg();
statusMsg.mStatus = true;
data.add(statusMsg);
mItemCount--;
assertTrue(mItemCount >= 0);
if (mItemCount == 0) {
nextState(State.IDLE);
}
}
use of com.vodafone360.people.datatypes.StatusMsg in project 360-Engine-for-Android by 360.
the class ActivitiesEngineTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d("TAG", "IdentityEngineTest.reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
switch(mState) {
case IDLE:
break;
case ON_CREATE:
case ON_DESTROY:
break;
case GET_ACTIVITIES_SUCCESS:
ActivityItem item = new ActivityItem();
data.add(item);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case GET_TIMELINE_EVENT_FROM_SERVER:
ActivityItem item2 = new ActivityItem();
ActivityContact act = new ActivityContact();
act.mName = "Bill Fleege";
act.mLocalContactId = new Long(8);
List<ActivityContact> clist = new ArrayList<ActivityContact>();
clist.add(act);
item2.contactList = clist;
item2.activityFlags = 2;
item2.type = ActivityItem.Type.CONTACT_JOINED;
item2.time = System.currentTimeMillis();
data.add(item2);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case GET_POPULATED_ACTIVITIES:
ActivityItem item3 = new ActivityItem();
ActivityContact act2 = new ActivityContact();
act2.mName = "Bill Fleege";
act2.mLocalContactId = new Long(8);
List<ActivityContact> clist2 = new ArrayList<ActivityContact>();
clist2.add(act2);
item3.contactList = clist2;
item3.activityFlags = 2;
item3.type = ActivityItem.Type.CONTACT_JOINED;
item3.time = System.currentTimeMillis();
item3.title = "bills new status";
item3.description = "a description";
data.add(item3);
ActivityItem item4 = new ActivityItem();
item4.contactList = clist2;
item4.activityFlags = 5;
item4.type = ActivityItem.Type.CONTACT_JOINED;
item4.time = System.currentTimeMillis();
item4.title = "bills new status";
item4.description = "a description";
item4.activityId = new Long(23);
item4.hasChildren = false;
item4.uri = "uri";
item4.parentActivity = new Long(0);
item4.preview = ByteBuffer.allocate(46);
item4.preview.position(0);
item4.preview.rewind();
for (int i = 0; i < 23; i++) {
item4.preview.putChar((char) i);
}
item4.previewMime = "jepg";
item4.previewUrl = "storeurl";
item4.store = "google";
item4.visibilityFlags = 0;
data.add(item4);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case GET_ACTIVITIES_SERVER_ERR:
ServerError err = new ServerError("Catastrophe");
err.errorDescription = "Fail";
data.add(err);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_ACTIVITIES_UNEXPECTED_RESPONSE:
StatusMsg msg = new StatusMsg();
msg.mCode = "ok";
msg.mDryRun = false;
msg.mStatus = true;
data.add(msg);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case SET_STATUS:
Identity id3 = new Identity();
data.add(id3);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case ON_SYNC_COMPLETE:
ServerError err2 = new ServerError("Catastrophe");
err2.errorDescription = "Fail";
data.add(err2);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_NEXT_RUNTIME:
break;
default:
}
}
Aggregations