Search in sources :

Example 31 with User

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

the class PresenceList method createFromHashtable.

/**
 * //////////////////////////////ServiceMethods/////////////////////////////
 */
/**
 * Create PresenceList from Hashtable generated by Hessian-decoder
 *
 * @param hash Hashtable containing PresenceList parameters
 */
public void createFromHashtable(Hashtable<String, Object> hash) {
    LogUtils.logI("HessianDecoder.createFromHashtable() hash[" + hash.toString() + "]");
    Enumeration<String> e = hash.keys();
    while (e.hasMoreElements()) {
        String key = e.nextElement();
        LogUtils.logI("HessianDecoder.createFromHashtable() key[" + key + "] value[" + hash.get(key) + "]");
        Tags tag = Tags.findTag(key);
        if (tag != null) {
            setValue(tag, hash.get(key));
        }
    }
    LogUtils.logI("HessianDecoder.createFromHashtable() mUserId[" + mUserId + "] mType[" + mType + "] users[" + users + "]");
    if (users != null) {
        for (User mUser : users) {
            LogUtils.logI("HessianDecoder.createFromHashtable() getPayload[" + mUser.getPayload() + "]");
        }
    } else {
        LogUtils.logW("HessianDecoder.createFromHashtable() users is NULL");
    }
}
Also used : User(com.vodafone360.people.engine.presence.User)

Example 32 with User

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

the class MainApplication method removeUserData.

/**
 * Remove all user data from People client, this includes all account
 * information (downloaded contacts, login credentials etc.) and all cached
 * settings.
 */
public synchronized void removeUserData() {
    EngineManager mEngineManager = EngineManager.getInstance();
    if (mEngineManager != null) {
        // Resets all the engines, the call will block until every engines
        // have been reset.
        mEngineManager.resetAllEngines();
    }
    // Remove NAB Account at this point (does nothing on 1.X)
    NativeContactsApi.getInstance().removePeopleAccount();
    // the same action as in NetworkSettingsActivity onChecked()
    setInternetAvail(InternetAvail.ALWAYS_CONNECT, false);
    mDatabaseHelper.removeUserData();
    // Before clearing the Application cache, kick the widget update. Pref's
    // file contain the widget ID.
    WidgetUtils.kickWidgetUpdateNow(this);
    mApplicationCache.clearCachedData(this);
}
Also used : EngineManager(com.vodafone360.people.engine.EngineManager)

Example 33 with User

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

the class NowPlusActivitiesTest method test1.

@MediumTest
public void test1() {
    Log.i(LOG_TAG, "***** EXECUTING test1 *****");
    Log.i(LOG_TAG, "<description here>");
    Log.i(LOG_TAG, "Test 1a: Remove user data");
    mDatabase.removeUserData();
    mDatabase.fetchThumbnailUrlCount();
    ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
    if (ServiceStatus.SUCCESS != status) {
        throw (new RuntimeException("No database change event received after removing user data, error: " + status));
    }
    Log.i(LOG_TAG, "********************************");
    Log.i(LOG_TAG, "test1 has completed successfully");
    Log.i(LOG_TAG, "********************************");
    Log.i(LOG_TAG, "");
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 34 with User

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

the class ContactGroupsTableTest method testModyficationsContactsToGroups.

public void testModyficationsContactsToGroups() {
    Log.i(LOG_TAG, "testModyficationsContactsToGroups start");
    createTable();
    for (int i = 0; i < testTable.length; i++) {
        assertTrue("Failed adding contact to group at step " + i, ContactGroupsTable.addContactToGroup(testTable[i][0], testTable[i][1], mTestDatabase.getWritableDatabase()));
    }
    ArrayList<Long> list = getUniqueIdListFromTestTable();
    ArrayList<Long> groupList = null;
    Long ContactId = null;
    for (Long l : list) {
        groupList = getEntriesWithId(l);
        if (groupList.size() > 1) {
            ContactId = l;
            break;
        }
    }
    if (ContactId == null) {
        fail("Test data does not containg user with more than one group.");
    }
    Random r = new Random();
    r.setSeed(System.currentTimeMillis());
    groupList.add(r.nextLong());
    groupList.add(r.nextLong());
    Contact c = new Contact();
    c.localContactID = ContactId;
    c.groupList = groupList;
    ServiceStatus status = ContactGroupsTable.modifyContact(c, mTestDatabase.getWritableDatabase());
    if (status != ServiceStatus.SUCCESS) {
        fail("Faild on modifyContact");
    }
    ArrayList<Long> testList = new ArrayList<Long>();
    assertTrue("Failed fetchContactGroups after modifyContact", ContactGroupsTable.fetchContactGroups(ContactId, testList, mTestDatabase.getWritableDatabase()));
    if (!testList.containsAll(groupList) || !groupList.containsAll(testList)) {
        fail("List after modyfyContact are different");
    }
    Log.i(LOG_TAG, "testModyficationsContactsToGroups PASS");
}
Also used : Random(java.util.Random) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact)

Example 35 with User

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

the class PresenceList method toString.

// /**
// * This method is called by the Engine to update the presence list state
// and refresh user statuses
// * @param changes is a Hashtable<String - UserId, Hashtable -
// presenceStatus in communities>
// */
// @SuppressWarnings("unchecked")
// public void addUsers(List<User> changes) {
// if (changes != null) {
// for (User user: changes) {
// if (users.contains(user))
// users.remove(user);
// if (user.isOnline() != OnlineStatus.OFFLINE.ordinal())
// users.add(user);
// }
// }
// }
@Override
public String toString() {
    final StringBuffer sb = new StringBuffer("PresenceList - mUserId[");
    sb.append(mUserId);
    sb.append("] mType[");
    sb.append(mType);
    sb.append("] users[");
    if (users != null) {
        for (User user : users) {
            sb.append("[");
            sb.append(user.toString());
            sb.append("]");
        }
    }
    sb.append("]");
    return sb.toString();
}
Also used : User(com.vodafone360.people.engine.presence.User)

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