use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class ChatDbUtils method fillInContactDetails.
/**
* Remove hard code
*
* @param msg
* @param item
* @param databaseHelper
* @param incoming
*/
private static void fillInContactDetails(ChatMessage msg, TimelineSummaryItem item, DatabaseHelper databaseHelper, TimelineSummaryItem.Type incoming) {
item.mTimestamp = System.currentTimeMillis();
// here we set the time stamp back into the chat message
// in order to be able to remove it from the chat history by time stamp in case its delivery fails
msg.setTimeStamp(item.mTimestamp);
item.mType = ActivityItem.Type.MESSAGE_IM_CONVERSATION;
item.mDescription = msg.getBody();
item.mTitle = DateFormat.getDateInstance().format(new Date(item.mTimestamp));
// we store sender's localContactId for incoming msgs and recipient's
// localContactId for outgoing msgs
item.mLocalContactId = msg.getLocalContactId();
if (item.mLocalContactId != null && item.mLocalContactId != -1) {
ContactDetail cd = ContactDetailsTable.fetchDetail(item.mLocalContactId, DetailKeys.VCARD_NAME, databaseHelper.getReadableDatabase());
if (cd == null || cd.getName() == null) {
// if we don't get any details, we have to check the summary
// table because gtalk contacts
// without name will be otherwise show as unknown
ContactSummary contactSummary = new ContactSummary();
ServiceStatus error = ContactSummaryTable.fetchSummaryItem(item.mLocalContactId, contactSummary, databaseHelper.getReadableDatabase());
if (error == ServiceStatus.SUCCESS) {
item.mContactName = (contactSummary.formattedName != null) ? contactSummary.formattedName : ContactDetail.UNKNOWN_NAME;
} else {
item.mContactName = ContactDetail.UNKNOWN_NAME;
}
} else {
/**
* Get name from contact details. *
*/
VCardHelper.Name name = cd.getName();
item.mContactName = (name != null) ? name.toString() : ContactDetail.UNKNOWN_NAME;
}
}
item.mIncoming = incoming;
item.mContactNetwork = SocialNetwork.getSocialNetworkValue(msg.getNetworkId()).toString();
item.mNativeItemType = TimelineNativeTypes.ChatLog.ordinal();
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class ResponseQueue method addToResponseQueue.
/**
* Adds a response item to the queue.
*
* @param reqId The request ID to add the response for.
* @param data The response data to add to the queue.
* @param source The corresponding engine that fired off the request for the
* response.
*/
public void addToResponseQueue(final DecodedResponse response) {
synchronized (QueueManager.getInstance().lock) {
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.UNKNOWN_DATA_TYPE, response.mDataTypes);
if (status == ServiceStatus.ERROR_INVALID_SESSION) {
EngineManager em = EngineManager.getInstance();
if (em != null) {
LogUtils.logE("Logging out the current user because of invalide session");
em.getLoginEngine().logoutAndRemoveUser();
return;
}
}
synchronized (mResponses) {
mResponses.add(response);
}
Request request = RequestQueue.getInstance().removeRequest(response.mReqId);
if (request != null) {
// we suppose the response being handled by the same engine
// that issued the request with the given id
response.mSource = request.mEngineId;
}
mEngMgr = EngineManager.getInstance();
if (mEngMgr != null) {
mEngMgr.onCommsInMessage(response.mSource);
}
}
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class DatabaseHelper method syncDeleteContactList.
/**
* Function used by the contact sync engine to delete a list of contacts
* from the database.
*
* @param contactIdList The list of contact IDs received from the server (at
* least localId should be set)
* @param syncToServer true if the contacts need to be deleted from the
* server
* @param syncToNative true if the contacts need to be deleted from the
* native phonebook
* @return SUCCESS or a suitable error code
* @see #deleteContact(long)
*/
public ServiceStatus syncDeleteContactList(List<ContactsTable.ContactIdInfo> contactIdList, boolean syncToServer, boolean syncToNative) {
if (Settings.ENABLED_DATABASE_TRACE)
trace(false, "DatabaseHelper.syncDeleteContactList() syncToServer[" + syncToServer + "] syncToNative[" + syncToNative + "]");
if (!Settings.ENABLE_SERVER_CONTACT_SYNC) {
syncToServer = false;
}
if (!Settings.ENABLE_UPDATE_NATIVE_CONTACTS) {
syncToNative = false;
}
SQLiteDatabase writableDb = getWritableDatabase();
for (ContactsTable.ContactIdInfo contactIdInfo : contactIdList) {
try {
writableDb.beginTransaction();
if (syncToNative && contactIdInfo.mergedLocalId == null) {
if (!NativeChangeLogTable.addDeletedContactChange(contactIdInfo.localId, contactIdInfo.nativeId, writableDb)) {
return ServiceStatus.ERROR_DATABASE_CORRUPT;
}
}
if (syncToServer) {
if (!ContactChangeLogTable.addDeletedContactChange(contactIdInfo.localId, contactIdInfo.serverId, syncToServer, writableDb)) {
return ServiceStatus.ERROR_DATABASE_CORRUPT;
}
}
if (!ContactGroupsTable.deleteContact(contactIdInfo.localId, writableDb)) {
return ServiceStatus.ERROR_DATABASE_CORRUPT;
}
if (SyncMeDbUtils.getMeProfileLocalContactId(this) != null && SyncMeDbUtils.getMeProfileLocalContactId(this).longValue() == contactIdInfo.localId) {
ServiceStatus status = StateTable.modifyMeProfileID(null, writableDb);
if (ServiceStatus.SUCCESS != status) {
return status;
}
SyncMeDbUtils.setMeProfileId(null);
PresenceDbUtils.resetMeProfileIds();
}
ServiceStatus status = ContactSummaryTable.deleteContact(contactIdInfo.localId, writableDb);
if (ServiceStatus.SUCCESS != status) {
return status;
}
status = ContactDetailsTable.deleteDetailByContactId(contactIdInfo.localId, writableDb);
if (ServiceStatus.SUCCESS != status && ServiceStatus.ERROR_NOT_FOUND != status) {
return status;
}
status = ContactsTable.deleteContact(contactIdInfo.localId, writableDb);
if (ServiceStatus.SUCCESS != status) {
return status;
}
if (!deleteThumbnail(contactIdInfo.localId))
LogUtils.logE("Not able to delete thumbnail for: " + contactIdInfo.localId);
// timeline
ActivitiesTable.removeTimelineContactData(contactIdInfo.localId, writableDb);
writableDb.setTransactionSuccessful();
} finally {
writableDb.endTransaction();
}
}
return ServiceStatus.SUCCESS;
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class DatabaseHelper method deleteTimelineActivity.
/**
* Removes the selected timeline activity from the database.
*
* @param application The MainApplication
* @param timelineItem TimelineSummaryItem to be deleted
* @return SUCCESS or a suitable error code
*/
public ServiceStatus deleteTimelineActivity(MainApplication application, TimelineSummaryItem timelineItem, boolean isTimelineAll) {
if (Settings.ENABLED_DATABASE_TRACE)
trace(false, "DatabaseHelper.deleteTimelineActivity()");
ServiceStatus status = ServiceStatus.SUCCESS;
if (isTimelineAll) {
status = ActivitiesTable.deleteTimelineActivities(mContext, timelineItem, getWritableDatabase(), getReadableDatabase());
} else {
status = ActivitiesTable.deleteTimelineActivity(mContext, timelineItem, getWritableDatabase(), getReadableDatabase());
}
if (status == ServiceStatus.SUCCESS) {
// Update Notifications in the Notification Bar
IPeopleService peopleService = application.getServiceInterface();
long localContactId = 0L;
if (timelineItem.mLocalContactId != null) {
localContactId = timelineItem.mLocalContactId;
}
peopleService.updateChatNotification(localContactId);
}
fireDatabaseChangedEvent(DatabaseChangeType.ACTIVITIES, true);
return status;
}
use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.
the class DatabaseHelper method addContact.
/**
* Adds a contact to the database and fires an internal database change
* event.
*
* @param contact A {@link Contact} object which contains the details to be
* added
* @return SUCCESS or a suitable error code
* @see #deleteContact(long)
* @see #addContactDetail(ContactDetail)
* @see #modifyContactDetail(ContactDetail)
* @see #deleteContactDetail(long)
* @see #addContactToGroup(long, long)
* @see #deleteContactFromGroup(long, long)
*/
public ServiceStatus addContact(Contact contact) {
if (Settings.ENABLED_DATABASE_TRACE) {
trace(false, "DatabaseHelper.addContact() contactID[" + contact.contactID + "] nativeContactId[" + contact.nativeContactId + "]");
}
List<Contact> contactList = new ArrayList<Contact>();
contactList.add(contact);
ServiceStatus status = syncAddContactList(contactList, true, true);
if (ServiceStatus.SUCCESS == status) {
fireDatabaseChangedEvent(DatabaseChangeType.CONTACTS, false);
}
return status;
}
Aggregations