use of com.vodafone360.people.datatypes.ContactDetail 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.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class Contacts method deleteContactDetails.
/**
* Implementation of contacts/deletecontactdetails API. Parameters are;
* [auth], Long contactid, List<ContactDetail> detaillist
*
* @param engine Handle to ContactSync engine
* @param contactid
* @param detaillist
* @return request id generated for this request.
*/
public static int deleteContactDetails(BaseEngine engine, Long contactid, List<ContactDetail> detaillist) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Contacts.deleteContactDetails() Invalid session, return -1");
return -1;
}
if (contactid == null) {
LogUtils.logE("Contacts.deleteContactDetails() contactidlist cannot be NULL");
return -1;
}
if (detaillist == null) {
LogUtils.logE("Contacts.deleteContactDetails() detaillist cannot be NULL");
return -1;
}
Request request = new Request(FUNCTION_DELETE_CONTACT_DETAILS, Request.Type.CONTACT_DETAIL_DELETE, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
request.addData("contactid", contactid);
request.addData("detaillist", ApiUtils.createVectorOfContactDetail(detaillist));
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class Contacts method setMe.
/**
* Implementation of contacts/setme API. Parameters are; [auth],
* List<ContactDetail> detaillist, String aboutme [opt]
*
* @param engine Handle to ContactSync engine
* @param detaillist List of ContactDetails for the Me profile.
* @param aboutme AboutMe string.
* @param gender - gender.
* @return request id generated for this request.
*/
public static int setMe(BaseEngine engine, List<ContactDetail> detaillist, String aboutme, Integer gender) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Contacts.SetMe() Invalid session, return -1");
return -1;
}
Request request = new Request(FUNCTION_SET_ME, Request.Type.CONTACT_CHANGES_OR_UPDATES, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_CONTACTS);
if (aboutme != null) {
request.addData("aboutme", aboutme);
}
if (detaillist != null) {
request.addData("detaillist", ApiUtils.createVectorOfContactDetail(detaillist));
}
if (gender != null) {
request.addData("gender", gender);
}
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class Identities method validateIdentityCredentials.
/**
* Implementation of identities/validateidentitycredentials API. Parameters
* are; [auth], Boolean dryrun [opt], String network [opt], String username,
* String password, String server [opt], String contactdetail [opt], Map
* identitycapabilitystatus [opt]
*
* @param engine handle to IdentitiesEngine
* @param dryrun Whether this is a dry-run request.
* @param network Name of network.
* @param username User-name.
* @param password Password.
* @param server
* @param contactdetail
* @param identitycapabilitystatus Capabilities for this identity/network.
* @return request id generated for this request
*/
public static int validateIdentityCredentials(BaseEngine engine, Boolean dryrun, String network, String username, String password, String server, String contactdetail, Map<String, Boolean> identitycapabilitystatus) {
if (LoginEngine.getSession() == null) {
LogUtils.logE("Identities.validateIdentityCredentials() Invalid session, return -1");
return -1;
}
if (network == null) {
LogUtils.logE("Identities.validateIdentityCredentials() network cannot be NULL");
return -1;
}
if (username == null) {
LogUtils.logE("Identities.validateIdentityCredentials() username cannot be NULL");
return -1;
}
if (password == null) {
LogUtils.logE("Identities.validateIdentityCredentials() password cannot be NULL");
return -1;
}
Request request = new Request(FUNCTION_VALIDATE_IDENTITY_CREDENTIALS, Request.Type.EXPECTING_STATUS_ONLY, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_IDENTITIES);
if (dryrun != null) {
request.addData("dryrun", dryrun);
}
request.addData("network", network);
request.addData("username", username);
request.addData("password", password);
if (server != null) {
request.addData("server", server);
}
if (contactdetail != null) {
request.addData("contactdetail", contactdetail);
}
if (identitycapabilitystatus != null) {
request.addData("identitycapabilitystatus", new Hashtable<String, Object>(identitycapabilitystatus));
}
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
use of com.vodafone360.people.datatypes.ContactDetail in project 360-Engine-for-Android by 360.
the class PeopleContactsApiTest method testUpdateGetNativeContactWithDelete.
/**
* Tests the updateNativeContact() method when a detail is deleted outside.
*/
public void testUpdateGetNativeContactWithDelete() {
final long NATIVE_ID = 15;
PeopleContactsApi pca = new PeopleContactsApi(mDatabaseHelper);
// the database is empty, it shall not return any ids
assertNull(pca.getNativeContactsIds());
// let's add a contact
ContactChange[] contact = filterContactChanges(ContactChangeHelper.randomContact(ContactChange.INVALID_ID, ContactChange.INVALID_ID, NATIVE_ID));
assertTrue(pca.addNativeContact(contact));
// check that it exists
long[] ids = pca.getNativeContactsIds();
assertEquals(1, ids.length);
assertEquals(NATIVE_ID, ids[0]);
// get the contact back
ContactChange[] savedContact = pca.getContact(NATIVE_ID);
assertNotNull(savedContact);
// let's add a detail
ContactChange addedDetail = new ContactChange(ContactChange.KEY_VCARD_PHONE, "+3300000", ContactChange.FLAG_HOME);
addedDetail.setNabContactId(NATIVE_ID);
addedDetail.setType(ContactChange.TYPE_ADD_DETAIL);
addedDetail.setInternalContactId(savedContact[0].getInternalContactId());
ContactChange[] updates = { addedDetail };
pca.updateNativeContact(updates);
// get the contact back
savedContact = pca.getContact(NATIVE_ID);
assertNotNull(savedContact);
assertEquals(contact.length + 1, savedContact.length);
// find the localId of the detail to delete
int index = findContactChangeIndex(savedContact, addedDetail);
assertTrue(index != -1);
addedDetail.setInternalDetailId(savedContact[index].getInternalDetailId());
// remove the detail as if coming from user or server (i.e. not yet synced to native)
ArrayList<ContactDetail> detailList = new ArrayList<ContactDetail>(1);
detailList.add(mDatabaseHelper.convertContactChange(addedDetail));
mDatabaseHelper.syncDeleteContactDetailList(detailList, false, true);
// get the contact back
savedContact = pca.getContact(NATIVE_ID);
assertNotNull(savedContact);
// the deleted detail shall be given
assertEquals(contact.length + 1, savedContact.length);
// check that one contact has the deleted flag
int deletedIndex = -1;
int deletedCount = 0;
for (int i = 0; i < savedContact.length; i++) {
if (savedContact[i].getType() == ContactChange.TYPE_DELETE_DETAIL) {
deletedIndex = i;
deletedCount++;
}
}
// there shall be only one deleted detail
assertEquals(1, deletedCount);
assertEquals(addedDetail.getInternalDetailId(), savedContact[deletedIndex].getInternalDetailId());
}
Aggregations