use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class ResponseQueue method addToResponseQueue.
/**
* Adds a response item to the queue.
*
* @param reqId The request ID to add the response for.
* @param data The response data to add to the queue.
* @param source The corresponding engine that fired off the request for the
* response.
*/
public void addToResponseQueue(final DecodedResponse response) {
synchronized (QueueManager.getInstance().lock) {
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.UNKNOWN_DATA_TYPE, response.mDataTypes);
if (status == ServiceStatus.ERROR_INVALID_SESSION) {
EngineManager em = EngineManager.getInstance();
if (em != null) {
LogUtils.logE("Logging out the current user because of invalide session");
em.getLoginEngine().logoutAndRemoveUser();
return;
}
}
synchronized (mResponses) {
mResponses.add(response);
}
Request request = RequestQueue.getInstance().removeRequest(response.mReqId);
if (request != null) {
// we suppose the response being handled by the same engine
// that issued the request with the given id
response.mSource = request.mEngineId;
}
mEngMgr = EngineManager.getInstance();
if (mEngMgr != null) {
mEngMgr.onCommsInMessage(response.mSource);
}
}
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class Chat method startChat.
/**
* Starts new chat session
*
* @param recipients - list of UserIds
* @return request id
*/
public static int startChat(List<String> recipients) {
if (recipients == null) {
LogUtils.logE("Chat.sentChatMessage() recipients can't be null");
return -1;
}
Request request = new Request(EMPTY, Request.Type.CREATE_CONVERSATION, EngineId.PRESENCE_ENGINE, false, Settings.API_REQUESTS_TIMEOUT_CHAT_CREATE_CONV);
request.addData(ChatMessage.Tags.RECIPIENTS_LIST.tag(), recipients);
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class Contacts method getMyChanges.
/**
* Implementation of contacts/getmychanges. Parameters are; [auth], Long
* fromrevision
*
* @param engine Handle to ContactSync engine
* @param fromrevision Start revision.
* @return request id generated for this request.
*/
public static int getMyChanges(BaseEngine engine, Long fromrevision) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Contacts.getMyChanges() Invalid session, return -1");
return -1;
}
Request request = new Request(FUNCTION_GET_MY_CHANGES, Request.Type.CONTACT_CHANGES_OR_UPDATES, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
request.addData("fromrevision", fromrevision.toString());
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class Contacts method deleteContactDetails.
/**
* Implementation of contacts/deletecontactdetails API. Parameters are;
* [auth], Long contactid, List<ContactDetail> detaillist
*
* @param engine Handle to ContactSync engine
* @param contactid
* @param detaillist
* @return request id generated for this request.
*/
public static int deleteContactDetails(BaseEngine engine, Long contactid, List<ContactDetail> detaillist) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Contacts.deleteContactDetails() Invalid session, return -1");
return -1;
}
if (contactid == null) {
LogUtils.logE("Contacts.deleteContactDetails() contactidlist cannot be NULL");
return -1;
}
if (detaillist == null) {
LogUtils.logE("Contacts.deleteContactDetails() detaillist cannot be NULL");
return -1;
}
Request request = new Request(FUNCTION_DELETE_CONTACT_DETAILS, Request.Type.CONTACT_DETAIL_DELETE, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
request.addData("contactid", contactid);
request.addData("detaillist", ApiUtils.createVectorOfContactDetail(detaillist));
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class Contacts method bulkUpdateContacts.
/**
* Implementation of contacts/bulkupdatecontacts API. Parameters are;
* [auth], List<Contact> contactlist
*
* @param engine Handle to ContactSync engine
* @param contactlist List containing the contacts to be updated on server.
* @return request id generated for this request.
*/
public static int bulkUpdateContacts(BaseEngine engine, List<Contact> contactlist) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Contacts.bulkUpdateContacts() Invalid session, return -1");
return -1;
}
if (contactlist == null) {
LogUtils.logE("Contacts.bulkUpdateContacts() contactidlist cannot be NULL");
return -1;
}
Request request = new Request(FUNCTION_BULK_UPDATE_CONTACTS, Request.Type.CONTACT_CHANGES_OR_UPDATES, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
request.addData("contactlist", ApiUtils.createVectorOfContact(contactlist));
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
Aggregations