Search in sources :

Example 16 with Identity

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"));
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) Bundle(android.os.Bundle) Identity(com.vodafone360.people.datatypes.Identity) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 17 with Identity

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"));
    }
}
Also used : StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Bundle(android.os.Bundle) Suppress(android.test.suitebuilder.annotation.Suppress) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 18 with Identity

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;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Example 19 with Identity

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;
}
Also used : Hashtable(java.util.Hashtable) Identity(com.vodafone360.people.datatypes.Identity)

Example 20 with Identity

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);
}
Also used : Hashtable(java.util.Hashtable) Identity(com.vodafone360.people.datatypes.Identity)

Aggregations

Identity (com.vodafone360.people.datatypes.Identity)17 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)7 ServiceStatus (com.vodafone360.people.service.ServiceStatus)6 ArrayList (java.util.ArrayList)6 Bundle (android.os.Bundle)5 MediumTest (android.test.suitebuilder.annotation.MediumTest)4 DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)4 Hashtable (java.util.Hashtable)4 Suppress (android.test.suitebuilder.annotation.Suppress)3 IdentityCapability (com.vodafone360.people.datatypes.IdentityCapability)3 ServerError (com.vodafone360.people.datatypes.ServerError)3 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)3 QueueManager (com.vodafone360.people.service.io.QueueManager)3 Request (com.vodafone360.people.service.io.Request)3 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)2 IOException (java.io.IOException)2 URL (java.net.URL)2 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)1