use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.
the class PeopleContactsApiTest method testGetNativeContactsIdsMerge.
/**
* Tests the getNativeContactsIds() method when a merge has to be performed.
*/
public void testGetNativeContactsIdsMerge() {
final long[] NATIVE_IDS = { 10, 85, 12, 103, 44, 38 };
final long[] DELETED_IDS = { NATIVE_IDS[0], NATIVE_IDS[5], NATIVE_IDS[3] };
PeopleContactsApi pca = new PeopleContactsApi(mDatabaseHelper);
// the database is empty, it shall not return any ids
assertNull(pca.getNativeContactsIds());
// let's add the contacts
for (int i = 0; i < NATIVE_IDS.length; i++) {
ContactChange[] contact = filterContactChanges(ContactChangeHelper.randomContact(ContactChange.INVALID_ID, ContactChange.INVALID_ID, NATIVE_IDS[i]));
assertTrue(pca.addNativeContact(contact));
}
// check that they exist and in the right order (ascending)
long[] ids = pca.getNativeContactsIds();
assertEquals(NATIVE_IDS.length, ids.length);
assertTrue(checkExistAndAscendingOrder(NATIVE_IDS, ids));
// delete them from CAB as it was coming from backend or user
// this has to be done without PeopleContactsApi wrapper as it does not support
// operations for Contacts not related to the native address book
List<ContactIdInfo> ciiList = new ArrayList<ContactIdInfo>(DELETED_IDS.length);
final SQLiteDatabase readableDb = mDatabaseHelper.getReadableDatabase();
try {
final SQLiteStatement nativeToLocalId = ContactsTable.fetchLocalFromNativeIdStatement(readableDb);
for (int i = 0; i < DELETED_IDS.length; i++) {
final ContactIdInfo cii = new ContactIdInfo();
cii.localId = ContactsTable.fetchLocalFromNativeId((int) DELETED_IDS[i], nativeToLocalId);
cii.nativeId = (int) DELETED_IDS[i];
ciiList.add(cii);
}
} finally {
readableDb.close();
}
mDatabaseHelper.syncDeleteContactList(ciiList, false, true);
// check the returned list of ids which should be similar as before
ids = pca.getNativeContactsIds();
assertEquals(NATIVE_IDS.length, ids.length);
assertTrue(checkExistAndAscendingOrder(NATIVE_IDS, ids));
// check that the deleted ids have the deleted flag
for (int i = 0; i < DELETED_IDS.length; i++) {
final ContactChange[] cc = pca.getContact(DELETED_IDS[i]);
assertEquals(cc[0].getType(), ContactChange.TYPE_DELETE_CONTACT);
}
}
use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.
the class SyncMeEngine method setFirstTimeSyncStarted.
/**
* Helper function to update the database when the state of the
* {@link #mFirstTimeMeSyncStarted} flag changes.
* @param value New value to the flag. True indicates that first time sync
* has been started. The flag is never set to false again by the
* engine, it will be only set to false when a remove user data
* is done (and the database is deleted).
* @return SUCCESS or a suitable error code if the database could not be
* updated.
*/
private ServiceStatus setFirstTimeSyncStarted(final boolean value) {
if (mFirstTimeSyncStarted == value) {
return ServiceStatus.SUCCESS;
}
PersistSettings setting = new PersistSettings();
setting.putFirstTimeMeSyncStarted(value);
ServiceStatus status = mDbHelper.setOption(setting);
if (ServiceStatus.SUCCESS == status) {
synchronized (this) {
mFirstTimeSyncStarted = value;
}
}
return status;
}
use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.
the class LoginEngine method handleNewPublicKeyResponse.
/**
* Called when a response to the server fetch public key request is
* received. Validates the response and stores the new public key details.
*
* @param mDataTypes Response data from server.
*/
private void handleNewPublicKeyResponse(List<BaseDataType> mDataTypes) {
LogUtils.logD("LoginEngine.handleNewPublicKeyResponse()");
ServiceStatus errorStatus = getResponseStatus(BaseDataType.PUBLIC_KEY_DETAILS_DATA_TYPE, mDataTypes);
if (errorStatus == ServiceStatus.SUCCESS) {
LogUtils.logD("LoginEngine.handleNewPublicKeyResponse() - Succesfully retrieved");
// AA
// 1. save to DB; save the flag that we aren't using default and
// have to use one from DB
// 2. start registration again
mPublicKey = (PublicKeyDetails) mDataTypes.get(0);
// done in startRegistrationProcessCrypted already
// mDb.modifyCredentialsAndPublicKey(mLoginDetails, mPublicKey);
startRegistrationProcessCrypted(mRegistrationDetails);
} else {
completeUiRequest(errorStatus, null);
}
}
use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.
the class SyncMeEngine method setFirstTimeMeSyncComplete.
/**
* Helper function to update the database when the state of the
* {@link #mFirstTimeMeSyncComplete} flag changes.
* @param value New value to the flag. True indicates that first time sync
* has been completed. The flag is never set to false again by
* the engine, it will be only set to false when a remove user
* data is done (and the database is deleted).
* @return SUCCESS or a suitable error code if the database could not be
* updated.
*/
private ServiceStatus setFirstTimeMeSyncComplete(final boolean value) {
if (mFirstTimeMeSyncComplete == value) {
return ServiceStatus.SUCCESS;
}
PersistSettings setting = new PersistSettings();
setting.putFirstTimeMeSyncComplete(value);
ServiceStatus status = mDbHelper.setOption(setting);
if (ServiceStatus.SUCCESS == status) {
synchronized (this) {
mFirstTimeMeSyncComplete = value;
}
}
return status;
}
use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.
the class TestModule method createFakeStatusEventList.
/**
* TODO: fill in the method properly
* @return
*/
public List<ActivityItem> createFakeStatusEventList() {
List<ActivityItem> activityList = new ArrayList<ActivityItem>();
for (int i = 0; i < TABLE_SIZE; i++) {
ActivityItem activityItem = new ActivityItem();
/** Unique identifier for the activity. This can be empty when setting
* a new activity (the id is generated on the server side) */
activityItem.activityId = System.currentTimeMillis();
/** Timestamp representing the time of the activity.
* This may not be related to creation/updated time. */
activityItem.time = System.currentTimeMillis();
/** local id for db */
// activityItem.mLocalId; set by DB insertion
// activityItem.mMoreInfo; //new Hashtable<ActivityItem, String>
/** The parent activity for 'grouped' or aggregated activities. This must be empty
* for normal activities that can be retrieved normally. Normally, a GetActivities
* without filter will not yield any 'grouped' or 'child' activities.
* To get activities that have a mParentActivity set, the 'children' filter must
* be used with a value of the parent Activity's id.*/
// activityItem.mParentActivity; // null
/** Indicates wether this activity 'groups' several child activities. When set,
* there must be child activities set that refer the main activity. Normally,
* a GetActivities without filter will not yield any 'grouped' or 'child' activities.
* To get activities that have a parentactivity set, the 'children' filter
* must be used with a value of the parent Activity's id.*/
// activityItem.mHasChildren = false;
/** Defines a binary preview for the activity. The preview can be a small thumbnail
* of the activity. The type of the binary data is defined into the previewmime field.*/
// keep null
// activityItem.mPreview = ByteBuffer.allocate(bytes.length);
// activityItem.mPreviewMime;
/** Defines an http url that the client can use to retrieve preview binary data.
* Can be used to embed the url into an IMG HTML tag.*/
// activityItem.mPreviewUrl
/** Name of the store type for this message. This field contains information about the
* originator network (local or external community activity).
* By default, should be set to local*/
activityItem.store = "local";
activityItem.title = generateRandomString();
activityItem.description = activityItem.description + activityItem.store;
/** Defines the type of the activity. */
activityItem.type = Type.CONTACT_RECEIVED_STATUS_UPDATE;
/** Defines an internal reference (if any) to the source of the activity.
* The format for the uri is "module:identifier".Some examples of valid uri are:
* contact:2737b322c9f6476ca152aa6cf3e5ac12 The activity is linked to some
* changes on a contact identified by id=2737b322c9f6476ca152aa6cf3e5ac12.
* file:virtual/flickr/2590004126 The activity is linked to some actions
* on a file identified by id=virtual/flickr/2590004126.
* message:9efd255359074dd9bd04cc1c8c4743e5 The activity is linked to a message
* identified by id=9efd255359074dd9bd04cc1c8c4743e5 */
activityItem.uri = "virtual/flickr/2590004126";
//can be 0 activityItem.mActivityFlags;
/** Miscellaneous flags.*/
activityItem.flagList = new ArrayList<Flag>();
activityItem.flagList.add(Flag.STATUS);
activityItem.activityFlags = 0x04;
/** Defines the contact information of the counter-parties in the activity.
* This field is not mandatory, because some activity types
* are not related to contacts, but required if known.. */
//keep it simple - empty activityItem.mContactList = ;
activityItem.visibility = new ArrayList<Visibility>();
activityItem.visibility.add(Visibility.ORIGINATOR);
//keep it 0 activityItem.mVisibilityFlags = 0;
activityList.add(activityItem);
}
return activityList;
}
Aggregations