use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.
the class NativeImporterTest method filterAccountsByType.
/**
* Filters the given array of accounts by the given type.
*
* @param accounts the array of accounts to filter
* @param type the type of accounts to filter
* @return an array containing the filtered accounts or null if none
*/
private static Account[] filterAccountsByType(Account[] accounts, String type) {
if (accounts != null) {
final int length = accounts.length;
final ArrayList<Account> matchingAccounts = new ArrayList<Account>(length);
// find the corresponding accounts
for (int i = 0; i < length; i++) {
final Account account = accounts[i];
if (type.equals(account.getType())) {
matchingAccounts.add(account);
}
}
if (matchingAccounts.size() > 0) {
accounts = new Account[matchingAccounts.size()];
matchingAccounts.toArray(accounts);
return accounts;
}
}
return null;
}
use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.
the class FetchSmsLogEvents method addSmsData.
/**
* Create TimelineSummaryItem from Native message-log item.
*
* @param id ID of item from Native log.
*/
private void addSmsData(int id) {
ActivityItem.Type type = nativeToNpTypeConvert(mSmsCursor.getInt(COLUMN_SMS_TYPE));
if (type == null) {
return;
}
TimelineSummaryItem item = new TimelineSummaryItem();
String address = null;
/* Francisco: Unknown contact SMS sending bug resolved here
* I am keeping previous case SN_MESSAGE_RECEIVED besides MESSAGE_SMS_RECEIVED just to be safe.
*/
if (type == ActivityItem.Type.SN_MESSAGE_RECEIVED || type == ActivityItem.Type.MESSAGE_SMS_RECEIVED) {
item.mIncoming = TimelineSummaryItem.Type.INCOMING;
} else {
item.mIncoming = TimelineSummaryItem.Type.OUTGOING;
}
item.mNativeItemId = id;
item.mNativeItemType = ActivitiesTable.TimelineNativeTypes.SmsLog.ordinal();
item.mType = type;
item.mTimestamp = mSmsCursor.getLong(COLUMN_SMS_DATE);
item.mTitle = DateFormat.getDateInstance().format(new Date(item.mTimestamp));
item.mNativeThreadId = mSmsCursor.getInt(COLUMN_SMS_THREAD_ID);
item.mDescription = null;
if (!mSmsCursor.isNull(COLUMN_SMS_SUBJECT)) {
item.mDescription = mSmsCursor.getString(COLUMN_SMS_SUBJECT);
}
if (item.mDescription == null || item.mDescription.length() == 0) {
if (!mSmsCursor.isNull(COLUMN_SMS_BODY)) {
item.mDescription = mSmsCursor.getString(COLUMN_SMS_BODY);
}
}
if (!mSmsCursor.isNull(COLUMN_SMS_ADDRESS)) {
address = mSmsCursor.getString(COLUMN_SMS_ADDRESS);
}
item.mContactName = address;
item.mContactAddress = address;
Contact c = new Contact();
ContactDetail phoneDetail = new ContactDetail();
ServiceStatus status = mDb.fetchContactInfo(address, c, phoneDetail);
if (ServiceStatus.SUCCESS == status) {
item.mLocalContactId = c.localContactID;
item.mContactId = c.contactID;
item.mUserId = c.userID;
item.mContactName = null;
for (ContactDetail d : c.details) {
switch(d.key) {
case VCARD_NAME:
final VCardHelper.Name name = d.getName();
if (name != null) {
item.mContactName = d.getName().toString();
}
break;
case VCARD_IMADDRESS:
item.mContactNetwork = d.alt;
break;
default:
// do nothing
break;
}
}
}
if (item.mContactId == null) {
LogUtils.logI("FetchSmsLogEvents.addSmsData: id " + item.mNativeItemId + ", time " + item.mTitle + ", description " + item.mDescription);
} else {
LogUtils.logI("FetchSmsLogEvents.addSmsData: id " + item.mNativeItemId + ", name = " + item.mContactName + ", time " + item.mTitle + ", description " + item.mDescription);
}
mSyncItemList.add(item);
}
use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.
the class MmsDecoder method getMmsData.
/**
* Get the MMS data for the message at current Cursor position and use it to
* populate a TimelineSummaryItem. We initially check if the MMS is an Inbox
* or sent item returning false if this is not the case.
*
* @param context Context.
* @param cr ContentResolver.
* @param mmsCursor Cursor pointing to MMS message entry in native message
* log.
* @param item TimeLineSummaryItem to populate using MMS message details
* @param db Handle to People database.
* @param maxDescLength maximum length of the description.
* @return true if we have created the TimelineSummaryItem false if we
* haven't (because the MMS is not of a valid type).
*/
protected static boolean getMmsData(Context context, ContentResolver cr, Cursor mmsCursor, TimelineSummaryItem item, DatabaseHelper db, int maxDescLength) {
int msgId = mmsCursor.getInt(COLUMN_MMS_ID);
Uri msgUri = MMS_CONTENT_URI.buildUpon().appendPath(Long.toString(msgId)).build();
ActivityItem.Type type = nativeToNpMessageType(mmsCursor.getInt(COLUMN_MSG_BOX));
if (type == null) {
return false;
}
String address = getToOrFrom(cr, type, msgUri);
String sub = mmsCursor.getString(COLUMN_SUBJECT);
int subcs = mmsCursor.getInt(COLUMN_SUBJECT_CS);
String subject = TextUtils.isEmpty(sub) ? "" : decodeString(subcs, getMmsBytes(sub));
item.mTimestamp = mmsCursor.getLong(COLUMN_DATE) * MS_IN_SECONDS;
item.mNativeItemId = msgId;
item.mNativeItemType = TimelineNativeTypes.MmsLog.ordinal();
item.mType = type;
item.mNativeThreadId = mmsCursor.getInt(COLUMN_MSG_THREAD_ID);
item.mContactAddress = address;
if (subject.length() > 0) {
if (subject.length() <= maxDescLength) {
item.mDescription = subject;
} else {
item.mDescription = subject.substring(0, maxDescLength) + ELLIPSIZE;
}
} else {
item.mDescription = getMmsText(cr, msgId, maxDescLength);
}
item.mTitle = DateFormat.getDateInstance().format(new Date(item.mTimestamp));
Contact c = new Contact();
ContactDetail phoneDetail = new ContactDetail();
ServiceStatus status = db.fetchContactInfo(address, c, phoneDetail);
if (ServiceStatus.SUCCESS == status) {
item.mContactId = c.contactID;
item.mLocalContactId = c.localContactID;
item.mUserId = c.userID;
item.mContactName = null;
for (ContactDetail d : c.details) {
switch(d.key) {
case VCARD_NAME:
final VCardHelper.Name name = d.getName();
if (name != null) {
item.mContactName = d.getName().toString();
}
break;
case VCARD_IMADDRESS:
item.mContactNetwork = d.alt;
break;
default:
// do nothing.
break;
}
}
} else {
item.mContactName = address;
}
return true;
}
use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.
the class ContactSyncEngine method processPushEvent.
/**
* Determines if a given response is a push message and processes in this
* case TODO: we need the check for Me Profile be migrated to he new engine
*
* @param resp Response to check and process
* @return true if the response was processed
*/
private boolean processPushEvent(DecodedResponse resp) {
if (resp.mDataTypes == null || resp.mDataTypes.size() == 0) {
return false;
}
BaseDataType dataType = resp.mDataTypes.get(0);
if ((dataType == null) || dataType.getType() != BaseDataType.PUSH_EVENT_DATA_TYPE) {
return false;
}
PushEvent pushEvent = (PushEvent) dataType;
LogUtils.logV("Push Event Type = " + pushEvent.mMessageType);
switch(pushEvent.mMessageType) {
case CONTACTS_CHANGE:
LogUtils.logI("ContactSyncEngine.processCommsResponse - Contacts changed push message received");
mServerSyncRequired = true;
// fetch the newest groups
EngineManager.getInstance().getGroupsEngine().addUiGetGroupsRequest();
mEventCallback.kickWorkerThread();
break;
case SYSTEM_NOTIFICATION:
LogUtils.logI("ContactSyncEngine.processCommsResponse - System notification push message received");
break;
default:
// do nothing.
break;
}
return true;
}
use of com.vodafone360.people.service.io.Request.Type in project 360-Engine-for-Android by 360.
the class ContactSyncEngine method processDbMessage.
/**
* Called when a database change event is received from the DatabaseHelper.
* Only internal database change events are processed, external change
* events are generated by the contact sync engine.
*
* @param msg The message indicating the type of event
*/
private void processDbMessage(Message message) {
final ServiceUiRequest event = ServiceUiRequest.getUiEvent(message.what);
switch(event) {
case DATABASE_CHANGED_EVENT:
if (message.arg1 == DatabaseHelper.DatabaseChangeType.CONTACTS.ordinal() && message.arg2 == 0) {
LogUtils.logV("ContactSyncEngine.processDbMessage - Contacts have changed");
// startMeProfileSyncTimer();
startServerContactSyncTimer(SERVER_CONTACT_SYNC_TIMEOUT_MS);
startUpdateNativeContactSyncTimer();
}
break;
default:
// Do nothing.
break;
}
}
Aggregations