Search in sources :

Example 1 with User

use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.

the class IdentityEngineTest 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 FETCH_IDENTITIES:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
            Identity id = new Identity();
            data.add(id);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        case GET_MY_IDENTITIES:
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine Get ids");
            Identity myId = new Identity();
            data.add(myId);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        case FETCH_IDENTITIES_FAIL:
            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 SET_IDENTITY_CAPABILTY:
            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.SET_IDENTITY_CAPABILITY_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case VALIDATE_ID_CREDENTIALS_SUCCESS:
            StatusMsg msg2 = new StatusMsg();
            msg2.mCode = "ok";
            msg2.mDryRun = false;
            msg2.mStatus = true;
            data.add(msg2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.VALIDATE_IDENTITY_CREDENTIALS_RESPONSE.ordinal()));
            mEng.onCommsInMessage();
            break;
        case VALIDATE_ID_CREDENTIALS_FAIL:
            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;
        case GET_CHATABLE_IDENTITIES:
        case FETCH_IDENTITIES_POPULATED:
            Identity id2 = new Identity();
            id2.mActive = true;
            id2.mAuthType = "auth";
            List<String> clist = new ArrayList<String>();
            clist.add("uk");
            clist.add("fr");
            id2.mCountryList = clist;
            id2.mCreated = new Long(0);
            id2.mDisplayName = "Facebook";
            // id2.mIcon2Mime = "jpeg";
            id2.mIconMime = "jpeg";
            try {
                id2.mIcon2Url = new URL("url2");
                id2.mIconUrl = new URL("url");
                id2.mNetworkUrl = new URL("network");
            } catch (Exception e) {
            }
            id2.mIdentityId = "fb";
            id2.mIdentityType = "type";
            id2.mName = "Facebook";
            id2.mNetwork = "Facebook";
            id2.mOrder = 0;
            id2.mPluginId = "";
            id2.mUpdated = new Long(0);
            id2.mUserId = 23;
            id2.mUserName = "user";
            data.add(id2);
            List<IdentityCapability> capList = new ArrayList<IdentityCapability>();
            IdentityCapability idcap = new IdentityCapability();
            idcap.mCapability = IdentityCapability.CapabilityID.sync_contacts;
            idcap.mDescription = "sync cont";
            idcap.mName = "sync cont";
            idcap.mValue = true;
            capList.add(idcap);
            id2.mCapabilities = capList;
            data.add(id2);
            respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal()));
            Log.d("TAG", "IdentityEngineTest.reportBackToEngine add to Q");
            mEng.onCommsInMessage();
            break;
        default:
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) StatusMsg(com.vodafone360.people.datatypes.StatusMsg) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) URL(java.net.URL) IdentityCapability(com.vodafone360.people.datatypes.IdentityCapability) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue) Identity(com.vodafone360.people.datatypes.Identity)

Example 2 with User

use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.

the class PresenceList method setValue.

private void setValue(Tags key, Object value) {
    LogUtils.logI("HessianDecoder.setValue() key[" + key + "] value[" + value + "]");
    switch(key) {
        case USER_ID:
            mUserId = (Long) value;
            break;
        case TYPE:
            mType = (String) value;
            break;
        case PAYLOAD:
            LogUtils.logW("HessianDecoder.setValue() PAYLOAD mType[" + mType + "]");
            @SuppressWarnings("unchecked") Hashtable<String, Object> mPayload = (Hashtable<String, Object>) value;
            Set<Map.Entry<String, Object>> set = mPayload.entrySet();
            for (Map.Entry<String, Object> obj : set) {
                @SuppressWarnings("unchecked") User mUser = new User(obj.getKey(), (Hashtable<String, String>) obj.getValue());
                if (users == null) {
                    users = new ArrayList<User>();
                }
                users.add(mUser);
            }
            break;
        default:
            LogUtils.logE("HessianDecoder.setValue() key[" + key + "] value[" + value + "]");
    }
}
Also used : User(com.vodafone360.people.engine.presence.User) Hashtable(java.util.Hashtable) Map(java.util.Map)

Example 3 with User

use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.

the class PushAvailabilityEvent method convertToList.

@SuppressWarnings("unchecked")
private static List<User> convertToList(Hashtable<String, Object> table) {
    ArrayList<User> users = new ArrayList<User>();
    for (Enumeration<String> en = table.keys(); en.hasMoreElements(); ) {
        String userId = en.nextElement();
        users.add(new User(userId, (Hashtable<String, String>) table.get(userId)));
    }
    return users;
}
Also used : User(com.vodafone360.people.engine.presence.User) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList)

Example 4 with User

use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.

the class NowPlusContactSummaryTest method testSetAllUsersOffline.

public void testSetAllUsersOffline() {
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
    final Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    contact.nativeContactId = new Integer(11);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Fetching a ContactSummary from ContactSummaryTable");
    final ContactSummary contactSummary = new ContactSummary();
    final ServiceStatus serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
    assertEquals(ServiceStatus.SUCCESS, serviceStatus);
    compareContactWithContactSummary(contact, contactSummary);
    // create a new user
    Hashtable<String, String> status = new Hashtable<String, String>();
    status.put("google", "online");
    status.put("microsoft", "online");
    status.put("mobile", "online");
    status.put("pc", "online");
    User user = new User("any", status);
    user.setLocalContactId(contactSummary.localContactID);
    // set him online
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.updateOnlineStatus(user));
    // fetch again
    final ContactSummary contactSummary2 = new ContactSummary();
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.fetchSummaryItem(user.getLocalContactId(), contactSummary2, mTestDatabase.getReadableDatabase()));
    // check if he's online
    assertEquals(OnlineStatus.ONLINE, contactSummary2.onlineStatus);
    // set offline
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.setOfflineStatus());
    // fetch again
    final ContactSummary contactSummary3 = new ContactSummary();
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.fetchSummaryItem(user.getLocalContactId(), contactSummary3, mTestDatabase.getReadableDatabase()));
    // check if it's offline
    assertEquals(OnlineStatus.OFFLINE, contactSummary3.onlineStatus);
}
Also used : ContactSummary(com.vodafone360.people.datatypes.ContactSummary) User(com.vodafone360.people.engine.presence.User) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Hashtable(java.util.Hashtable) Contact(com.vodafone360.people.datatypes.Contact)

Example 5 with User

use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.

the class NowPlusContactSummaryTest method testUpdateOnlineStatus.

public void testUpdateOnlineStatus() {
    Log.i(LOG_TAG, "***** EXECUTING testUpdateOnlineStatus() *****");
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Add a contact to ContactSummaryTable");
    final Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    contact.nativeContactId = new Integer(11);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
    Log.i(LOG_TAG, "Fetching a ContactSummary from ContactSummaryTable");
    final ContactSummary contactSummary = new ContactSummary();
    final ServiceStatus serviceStatus = ContactSummaryTable.fetchSummaryItem(contact.localContactID, contactSummary, mTestDatabase.getReadableDatabase());
    assertEquals(ServiceStatus.SUCCESS, serviceStatus);
    compareContactWithContactSummary(contact, contactSummary);
    // create a new user
    Hashtable<String, String> status = new Hashtable<String, String>();
    status.put("google", "online");
    status.put("microsoft", "online");
    status.put("mobile", "online");
    status.put("pc", "online");
    User user = new User("any", status);
    user.setLocalContactId(contactSummary.localContactID);
    // set him online
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.updateOnlineStatus(user));
    // fetch again
    final ContactSummary contactSummary2 = new ContactSummary();
    assertEquals(ServiceStatus.SUCCESS, ContactSummaryTable.fetchSummaryItem(user.getLocalContactId(), contactSummary2, mTestDatabase.getReadableDatabase()));
    // check if he's online
    assertEquals(OnlineStatus.ONLINE, contactSummary2.onlineStatus);
}
Also used : ContactSummary(com.vodafone360.people.datatypes.ContactSummary) User(com.vodafone360.people.engine.presence.User) ServiceStatus(com.vodafone360.people.service.ServiceStatus) Hashtable(java.util.Hashtable) Contact(com.vodafone360.people.datatypes.Contact)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)22 Contact (com.vodafone360.people.datatypes.Contact)12 ArrayList (java.util.ArrayList)12 User (com.vodafone360.people.engine.presence.User)11 Hashtable (java.util.Hashtable)9 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)7 Request (com.vodafone360.people.service.io.Request)7 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 PersistSettings (com.vodafone360.people.service.PersistSettings)6 QueueManager (com.vodafone360.people.service.io.QueueManager)6 SmallTest (android.test.suitebuilder.annotation.SmallTest)4 Identity (com.vodafone360.people.datatypes.Identity)4 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)3 RegistrationDetails (com.vodafone360.people.datatypes.RegistrationDetails)3 NetworkPresence (com.vodafone360.people.engine.presence.NetworkPresence)3 Cursor (android.database.Cursor)2 SQLiteStatement (android.database.sqlite.SQLiteStatement)2 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)2 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)2 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)2