use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class ContactSummaryTable method addContact.
/**
* Adds contact summary information to the table for a new contact. If the
* contact has no name or no status, an alternative detail will be used such
* as telephone number or email address.
*
* @param contact The new contact
* @param writableDb Writable SQLite database
* @return SUCCESS or a suitable error code
*/
public static ServiceStatus addContact(Contact contact, SQLiteDatabase writableDb) {
if (Settings.ENABLED_DATABASE_TRACE) {
DatabaseHelper.trace(true, "ContactSummeryTable.addContact() contactID[" + contact.contactID + "]");
}
if (contact.localContactID == null) {
LogUtils.logE("ContactSummeryTable.addContact() Invalid parameters");
return ServiceStatus.ERROR_NOT_FOUND;
}
try {
final ContentValues values = new ContentValues();
values.put(Field.LOCALCONTACTID.toString(), contact.localContactID);
values.put(Field.NATIVEID.toString(), contact.nativeContactId);
values.put(Field.FRIENDOFMINE.toString(), contact.friendOfMine);
values.put(Field.SYNCTOPHONE.toString(), contact.synctophone);
ContactDetail altDetail = findAlternativeNameContactDetail(values, contact.details);
updateAltValues(values, altDetail);
addToPresenceMap(contact.localContactID);
if (writableDb.insertOrThrow(TABLE_NAME, null, values) < 0) {
LogUtils.logE("ContactSummeryTable.addContact() " + "Unable to insert new contact summary");
return ServiceStatus.ERROR_NOT_FOUND;
}
return ServiceStatus.SUCCESS;
} catch (SQLException e) {
LogUtils.logE("ContactSummeryTable.addContact() SQLException - " + "Unable to insert new contact summary", e);
return ServiceStatus.ERROR_DATABASE_CORRUPT;
}
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class GroupsTable method populateSystemGroups.
/**
* Populates the table if system groups that are specified in the resources.
*
* @param context The context for reading the app resources
* @param writableDb Writable SQLite database for updating the table
* @return SUCCESS or a suitable error code
*/
public static ServiceStatus populateSystemGroups(Context context, SQLiteDatabase writableDb) {
final List<GroupItem> groupList = new ArrayList<GroupItem>();
GroupItem all = new GroupItem();
all.mName = context.getString(R.string.ContactListActivity_group_all);
all.mIsReadOnly = true;
all.mId = GROUP_ALL;
groupList.add(all);
GroupItem online = new GroupItem();
online.mName = context.getString(R.string.ContactListActivity_group_online);
online.mIsReadOnly = true;
online.mId = GROUP_ONLINE;
groupList.add(online);
GroupItem phonebook = new GroupItem();
phonebook.mName = context.getString(R.string.ContactListActivity_group_phonebook);
phonebook.mIsReadOnly = true;
phonebook.mId = GROUP_PHONEBOOK;
groupList.add(phonebook);
return addGroupList(groupList, writableDb);
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class ContactSyncEngine method setFirstTimeSyncComplete.
/**
* Helper function to update the database when the state of the
* {@link #mFirstTimeSyncComplete} 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 setFirstTimeSyncComplete(boolean value) {
if (mFirstTimeSyncComplete == value) {
return ServiceStatus.SUCCESS;
}
PersistSettings setting = new PersistSettings();
setting.putFirstTimeSyncComplete(value);
ServiceStatus status = mDb.setOption(setting);
if (ServiceStatus.SUCCESS == status) {
synchronized (this) {
mFirstTimeSyncComplete = value;
}
}
return status;
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class ContactSyncEngine method setFirstTimeSyncStarted.
/**
* Helper function to update the database when the state of the
* {@link #mFirstTimeSyncStarted} 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(boolean value) {
if (mFirstTimeSyncStarted == value) {
return ServiceStatus.SUCCESS;
}
PersistSettings setting = new PersistSettings();
setting.putFirstTimeSyncStarted(value);
ServiceStatus status = mDb.setOption(setting);
if (ServiceStatus.SUCCESS == status) {
synchronized (this) {
mFirstTimeSyncStarted = value;
}
}
return status;
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class DownloadServerContacts method deleteContactList.
/**
* Deletes contacts from the local database based on changes received from
* the server (listed in the {@link #mDeleteContactList} list).
*
* @return true if > 0 contacts were deleted, false otherwise.
*/
private boolean deleteContactList() {
if (mDeleteContactList.size() == 0) {
return false;
}
LogUtils.logI("DownloadServerContacts.deleteContactList " + mDeleteContactList.size() + " contacts...");
long startTime = System.nanoTime();
ServiceStatus status = mDb.syncDeleteContactList(mDeleteContactList, false, true);
if (ServiceStatus.SUCCESS != status) {
complete(status);
return true;
}
markDbChanged();
long timeDiff = System.nanoTime() - startTime;
mDbSyncTime += timeDiff;
LogUtils.logI("DownloadServerContacts.deleteContactList - time = " + (timeDiff / NANOSECONDS_IN_MS) + "ms, total = " + (mDbSyncTime / NANOSECONDS_IN_MS) + "ms");
mDeleteContactList.clear();
return true;
}
Aggregations