use of com.vodafone360.people.database.DatabaseHelper 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.database.DatabaseHelper 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;
}
}
use of com.vodafone360.people.database.DatabaseHelper in project 360-Engine-for-Android by 360.
the class MainApplication method onCreate.
/**
* Called when the Application is created.
*/
@Override
public void onCreate() {
super.onCreate();
SettingsManager.loadProperties(this);
mDatabaseHelper = new DatabaseHelper(this);
mDatabaseHelper.start();
LoginPreferences.getCurrentLoginActivity(this);
/** Start the Service. **/
startService(new Intent(this, RemoteService.class));
}
use of com.vodafone360.people.database.DatabaseHelper in project 360-Engine-for-Android by 360.
the class DatabaseProvider method onCreate.
/***
* Create the DatabaseProvider.
*
* @return TRUE if creation was successful.
*/
@Override
public final boolean onCreate() {
mContext = getContext();
mDatabaseHelper = new DatabaseHelper(mContext);
return mDatabaseHelper != null;
}
use of com.vodafone360.people.database.DatabaseHelper in project 360-Engine-for-Android by 360.
the class ChatDbUtils method convertUserIds.
/***
* Set the user ID, network ID and local contact ID values in the given
* ChatMessage.
*
* The original msg.getUserId() is formatted <network>::<userId>, meaning
* if "::" is present the values are split, otherwise the original value is
* used.
*
* @param chatMessage ChatMessage to be altered.
* @param databaseHelper DatabaseHelper with a readable database.
*/
public static void convertUserIds(final ChatMessage chatMessage, final DatabaseHelper databaseHelper) {
/**
* Use original User ID, in case of NumberFormatException (see
* PAND-2356).
*/
final String originalUserId = chatMessage.getUserId();
int index = originalUserId.indexOf(COLUMNS);
if (index > -1) {
/** Parse a <networkId>::<userId> formatted user ID. **/
chatMessage.setUserId(originalUserId.substring(index + COLUMNS.length()));
String network = originalUserId.substring(0, index);
/** Parse the <networkId> component. **/
SocialNetwork sn = SocialNetwork.getValue(network);
if (sn != null) {
chatMessage.setNetworkId(sn.ordinal());
} else {
chatMessage.setNetworkId(SocialNetwork.INVALID.ordinal());
LogUtils.logE("ChatUtils.convertUserIds() Invalid Network ID [" + network + "] in [" + originalUserId + "]");
}
}
chatMessage.setLocalContactId(ContactDetailsTable.findLocalContactIdByKey(SocialNetwork.getSocialNetworkValue(chatMessage.getNetworkId()).toString(), chatMessage.getUserId(), ContactDetail.DetailKeys.VCARD_IMADDRESS, databaseHelper.getReadableDatabase()));
}
Aggregations