use of com.vodafone360.people.service.io.Request 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);
}
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processGetMyChangesResponse.
/**
* Processes the response from a GetMyChanges request. The me profile data
* will be merged in the local database if the response is successful.
* Otherwise the processor will complete with a suitable error.
* @param resp Response from server.
*/
private void processGetMyChangesResponse(final DecodedResponse resp) {
LogUtils.logD("SyncMeEngine processGetMyChangesResponse()");
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
if (status == ServiceStatus.SUCCESS) {
ContactChanges changes = (ContactChanges) resp.mDataTypes.get(0);
Contact currentMeProfile = new Contact();
status = SyncMeDbUtils.fetchMeProfile(mDbHelper, currentMeProfile);
switch(status) {
case SUCCESS:
SyncMeDbUtils.updateMeProfile(mDbHelper, currentMeProfile, changes.mUserProfile);
break;
case // this is the 1st time sync
ERROR_NOT_FOUND:
currentMeProfile.copy(changes.mUserProfile);
status = SyncMeDbUtils.setMeProfile(mDbHelper, currentMeProfile);
setFirstTimeMeSyncComplete(true);
break;
default:
completeUiRequest(status);
return;
}
final String url = fetchThumbnailUrlFromProfile(changes.mUserProfile);
if (url != null) {
downloadMeProfileThumbnail(url, currentMeProfile.localContactID);
} else {
completeUiRequest(status);
}
storeMeProfileRevisionInDb(changes.mCurrentServerVersion);
} else {
completeUiRequest(status);
}
}
use of com.vodafone360.people.service.io.Request 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);
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class RequestQueue method clearAllRequests.
/**
* Clears all requests from the queue and puts null responses on the
* response queue to tell the engines that they have been cleared. This
* should be called from the connection thread as soon as it is stopped.
*/
protected void clearAllRequests() {
synchronized (QueueManager.getInstance().lock) {
ResponseQueue responseQueue = ResponseQueue.getInstance();
for (int i = 0; i < mRequests.size(); i++) {
Request request = mRequests.get(i);
LogUtils.logE("RequestQueue.clearActiveRequests() Deleting request " + request.getRequestId());
mRequests.remove(i--);
// necessarily times out before)
if (request.getExpiryDate() > 0) {
mTimeOutWatcher.removeRequest(request);
}
responseQueue.addToResponseQueue(new DecodedResponse(request.getRequestId(), null, request.mEngineId, DecodedResponse.ResponseType.TIMED_OUT_RESPONSE.ordinal()));
}
}
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class Activities method getActivities.
/**
* Implementation of People getactvities API. The required parameters are;
* [auth], List<Long> activityidlist [opt], Map<String, List<String>>
* filterlist [opt]
*
* @param engine Handle to ActivitiesEngine which handles requests using
* this API.
* @param activityidlist List of Activity IDs to retrieve
* @param filterlist List of filters to filter Activities request against.
* @return Request ID generated for this request.
*/
public static int getActivities(BaseEngine engine, List<Long> activityidlist, Map<String, List<String>> filterlist) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Activities.getActivities() Invalid session");
return -1;
}
Request request = new Request(FUNCTION_GET_ACTIVITIES, Request.Type.COMMON, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_ACTIVITIES);
if (activityidlist != null) {
request.addData("activityidlist", new Vector<Object>(activityidlist));
}
if (filterlist != null) {
request.addData("filterlist", ApiUtils.createHashTable(filterlist));
}
int requestId = QueueManager.getInstance().addRequest(request);
QueueManager.getInstance().fireQueueStateChanged();
return requestId;
}
Aggregations