use of com.vodafone360.people.datatypes.Identity in project 360-Engine-for-Android by 360.
the class IdentityEngineTest method testFetchIdentities.
// Takes too long
@Suppress
@MediumTest
public void testFetchIdentities() {
mState = IdentityTestState.FETCH_IDENTITIES;
NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
mEng.getAvailableThirdPartyIdentities();
// mEng.run();
ServiceStatus status = mEngineTester.waitForEvent();
assertEquals(ServiceStatus.SUCCESS, status);
Object data = mEngineTester.data();
assertTrue(data != null);
try {
ArrayList<Identity> identityList = ((Bundle) data).getParcelableArrayList("data");
assertTrue(identityList.size() == 1);
} catch (Exception e) {
throw (new RuntimeException("Expected identity list with 1 item"));
}
}
use of com.vodafone360.people.datatypes.Identity in project 360-Engine-for-Android by 360.
the class IdentityEngineTest method testSetIdentityCapability.
@MediumTest
// Breaks tests.
@Suppress
public void testSetIdentityCapability() {
mState = IdentityTestState.SET_IDENTITY_CAPABILTY;
String network = "facebook";
// Bundle fbund = new Bundle();
// fbund.putBoolean("sync_contacts", true);
String identityId = "mikeyb";
NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
// AA mEng.addUiSetIdentityCapabilityStatus(network, identityId, fbund);
mEng.addUiSetIdentityStatus(network, identityId, true);
ServiceStatus status = mEngineTester.waitForEvent();
assertEquals(ServiceStatus.SUCCESS, status);
Object data = mEngineTester.data();
assertTrue(data != null);
try {
ArrayList<StatusMsg> identityList = ((Bundle) data).getParcelableArrayList("data");
assertTrue(identityList.size() == 1);
} catch (Exception e) {
throw (new RuntimeException("Expected identity list with 1 item"));
}
}
use of com.vodafone360.people.datatypes.Identity in project 360-Engine-for-Android by 360.
the class Identities method deleteIdentity.
/**
* Implementation of identities/deleteIdentity API. Parameters are; [auth],
* String network, String identityid.
*
* @param engine
* Handle to IdentitiesEngine.
* @param network
* Name of network.
* @param identityId
* The user's identity ID.
* @return requestId The request ID generated for this request.
*/
public static int deleteIdentity(final BaseEngine engine, final String network, final String identityId) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Identities.deleteIdentity() Invalid session, return -1");
return -1;
}
if (network == null) {
LogUtils.logE("Identities.deleteIdentity() network cannot be NULL");
return -1;
}
if (identityId == null) {
LogUtils.logE("Identities.deleteIdentity() identityId cannot be NULL");
return -1;
}
Request request = new Request(FUNCTION_DELETE_IDENITY, Request.Type.DELETE_IDENTITY, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_IDENTITIES);
request.addData("network", network);
request.addData("identityid", identityId);
LogUtils.logI("Identity to be removed : " + network + " : " + identityId);
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
use of com.vodafone360.people.datatypes.Identity in project 360-Engine-for-Android by 360.
the class PresenceEngine method getPresencesForStatus.
/**
* Convenience method.
* Constructs a Hash table object containing My identities mapped against the provided status.
* @param status Presence status to set for all identities
* @return The resulting Hash table, is null if no identities are present
*/
public Hashtable<String, String> getPresencesForStatus(OnlineStatus status) {
// Get cached identities from the presence engine
ArrayList<Identity> identities = EngineManager.getInstance().getIdentityEngine().getMyChattableIdentities();
if (identities == null) {
// No identities, just return null
return null;
}
Hashtable<String, String> presences = new Hashtable<String, String>();
String statusString = status.toString();
for (Identity identity : identities) {
presences.put(identity.mNetwork, statusString);
}
return presences;
}
use of com.vodafone360.people.datatypes.Identity in project 360-Engine-for-Android by 360.
the class PresenceEngine method initSetMyAvailabilityRequestAfterLogin.
/**
* Method used to set availability of me profile when user logs in.
* This is primarily used for reacting to login/connection state changes.
*/
private void initSetMyAvailabilityRequestAfterLogin() {
if (ConnectionManager.getInstance().getConnectionState() != STATE_CONNECTED || !isFirstTimeSyncComplete()) {
LogUtils.logD("PresenceEngine.initSetMyAvailabilityRequest():" + " return NO NETWORK CONNECTION or not ready");
return;
}
String meProfileUserId = Long.toString(PresenceDbUtils.getMeProfileUserId(mDbHelper));
Hashtable<String, String> availability = new Hashtable<String, String>();
ArrayList<Identity> identityList = EngineManager.getInstance().getIdentityEngine().getMyChattableIdentities();
if ((identityList.size() != 0)) {
for (int i = 0; i < identityList.size(); i++) {
Identity myIdentity = identityList.get(i);
availability.put(myIdentity.mNetwork, OnlineStatus.ONLINE.toString());
}
}
User meUser = new User(meProfileUserId, availability);
meUser.setLocalContactId(Long.valueOf(meProfileUserId));
updateMyPresenceInDatabase(meUser);
addUiRequestToQueue(ServiceUiRequest.SET_MY_AVAILABILITY, availability);
}
Aggregations