Search in sources :

Example 51 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class LoginEngine method handleActivateAccountResponse.

/**
 * Called when a response to the Activate API is received (manual login or
 * sign-up). In case of success, moves to the logged in state and completes
 * the manual login or sign-up request.
 *
 * @param data The received data
 */
private void handleActivateAccountResponse(List<BaseDataType> data) {
    LogUtils.logD("LoginEngine.handleActivateAccountResponse()");
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.STATUS_MSG_DATA_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS) {
        LogUtils.logD("LoginEngine.handleActivateAccountResponse: ** Mobile number activated **");
        setRegistrationComplete(true);
        completeUiRequest(ServiceStatus.SUCCESS, null);
        return;
    }
    setActivatedSession(null);
    completeUiRequest(ServiceStatus.ERROR_ACCOUNT_ACTIVATION_FAILED, null);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 52 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class LoginEngine method handleServerSimpleTextResponse.

/**
 * Called when a response to the GetTermsAndConditions, GetPrivacyStatement
 * and GetUsernameState APIs are received. In case of success, completes the
 * request and passes the response data to the UI.
 *
 * @param data The received data
 */
private void handleServerSimpleTextResponse(List<BaseDataType> data, State type) {
    LogUtils.logV("LoginEngine.handleServerSimpleTextResponse()");
    ServiceStatus serviceStatus = getResponseStatus(BaseDataType.SIMPLE_TEXT_DATA_TYPE, data);
    String result = null;
    if (serviceStatus == ServiceStatus.SUCCESS) {
        result = ((SimpleText) data.get(0)).mValue.toString().replace(CARRIAGE_RETURN_CHARACTER, SPACE_CHARACTER);
        switch(type) {
            case FETCHING_TERMS_OF_SERVICE:
                LogUtils.logD("LoginEngine.handleServerSimpleTextResponse() Terms of Service");
                ApplicationCache.setTermsOfService(result, mContext);
                break;
            case FETCHING_PRIVACY_STATEMENT:
                LogUtils.logD("LoginEngine.handleServerSimpleTextResponse() Privacy Statemet");
                ApplicationCache.setPrivacyStatemet(result, mContext);
                break;
            case FETCHING_USERNAME_STATE:
                // TODO: Unused by UI.
                break;
        }
    }
    updateTermsState(serviceStatus, result);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 53 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class SyncMeDbUtils method processMyContactDetailsChanges.

/**
 * This method stores the getMyChanges() response to database - details part.
 * @param dbHelper DatabaseHelper - database.
 * @param currentMeProfile Contact - me profile contact.
 * @param profileChanges UserProfile - the contact changes.
 * @return ServiceStatus - SUCCESS if the contact changes have been successfully processed stored.
 */
private static String processMyContactDetailsChanges(final DatabaseHelper dbHelper, final Contact currentMeProfile, final UserProfile profileChanges) {
    String ret = null;
    final ArrayList<ContactDetail> modifiedDetailList = new ArrayList<ContactDetail>();
    final ArrayList<ContactDetail> addedDetailList = new ArrayList<ContactDetail>();
    final ArrayList<ContactDetail> deletedDetailList = new ArrayList<ContactDetail>();
    for (ContactDetail newDetail : profileChanges.details) {
        boolean found = false;
        for (int i = 0; i < currentMeProfile.details.size(); i++) {
            ContactDetail oldDetail = currentMeProfile.details.get(i);
            if (DatabaseHelper.doDetailsMatch(newDetail, oldDetail)) {
                found = true;
                if (newDetail.deleted != null && newDetail.deleted.booleanValue()) {
                    deletedDetailList.add(oldDetail);
                } else if (DatabaseHelper.hasDetailChanged(oldDetail, newDetail)) {
                    newDetail.localDetailID = oldDetail.localDetailID;
                    newDetail.localContactID = oldDetail.localContactID;
                    newDetail.nativeContactId = oldDetail.nativeContactId;
                    newDetail.nativeDetailId = oldDetail.nativeDetailId;
                    modifiedDetailList.add(newDetail);
                    if (newDetail.key == DetailKeys.PHOTO) {
                        dbHelper.markMeProfileAvatarChanged();
                        ret = newDetail.value;
                    }
                }
                break;
            }
        }
        // in the response or the deleted flag was false we have to add the new detail to the list
        if ((!found) && ((null == newDetail.deleted) || (!newDetail.deleted.booleanValue()))) {
            newDetail.localContactID = currentMeProfile.localContactID;
            newDetail.nativeContactId = currentMeProfile.nativeContactId;
            if (newDetail.key == DetailKeys.PHOTO) {
                dbHelper.markMeProfileAvatarChanged();
                ret = newDetail.value;
            }
            addedDetailList.add(newDetail);
        }
    }
    if (!addedDetailList.isEmpty()) {
        dbHelper.syncAddContactDetailList(addedDetailList, false, false);
    }
    if (!modifiedDetailList.isEmpty()) {
        dbHelper.syncModifyContactDetailList(modifiedDetailList, false, false);
    }
    if (!deletedDetailList.isEmpty()) {
        dbHelper.syncDeleteContactDetailList(deletedDetailList, false, false);
    }
    return ret;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) ArrayList(java.util.ArrayList)

Example 54 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class SyncMeDbUtils method setMeProfile.

/**
 * This method create a Me Profile contact in the database.
 * @param dbHelper DatabaseHelper - the database.
 * @param meProfile Contact - the Me Profile contact
 * @return ServiceStatus - ServiceStatus.SUCCESS when the new contact is
 *         successfully created.
 */
public static ServiceStatus setMeProfile(final DatabaseHelper dbHelper, Contact meProfile) {
    ServiceStatus status = ServiceStatus.ERROR_DATABASE_CORRUPT;
    // the contact didn't exist before
    if (sMeProfileLocalContactId == null) {
        List<Contact> contactList = new ArrayList<Contact>();
        contactList.add(meProfile);
        status = dbHelper.syncAddContactList(contactList, false, false);
        if (ServiceStatus.SUCCESS == status) {
            sMeProfileLocalContactId = meProfile.localContactID;
            status = StateTable.modifyMeProfileID(sMeProfileLocalContactId, dbHelper.getWritableDatabase());
            PresenceDbUtils.resetMeProfileIds();
            if (ServiceStatus.SUCCESS != status) {
                List<ContactsTable.ContactIdInfo> idList = new ArrayList<ContactsTable.ContactIdInfo>();
                ContactsTable.ContactIdInfo contactIdInfo = new ContactsTable.ContactIdInfo();
                contactIdInfo.localId = meProfile.localContactID;
                contactIdInfo.serverId = meProfile.contactID;
                contactIdInfo.nativeId = meProfile.nativeContactId;
                idList.add(contactIdInfo);
                dbHelper.syncDeleteContactList(idList, false, false);
            }
        }
    }
    return status;
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) ContactsTable(com.vodafone360.people.database.tables.ContactsTable) ArrayList(java.util.ArrayList) Contact(com.vodafone360.people.datatypes.Contact)

Example 55 with ServiceStatus

use of com.vodafone360.people.service.ServiceStatus in project 360-Engine-for-Android by 360.

the class NowPlusActivitiesTableTest method testFetchStatusEventList.

/**
 * This method checks that status events are present in the table
 */
public void testFetchStatusEventList() {
    Log.i(LOG_TAG, "***** testFetchStatusEventList: create table *****");
    SQLiteDatabase writableDataBase = mTestDatabase.getWritableDatabase();
    ActivitiesTable.create(writableDataBase);
    List<ActivityItem> activitiesList = mTestModule.createFakeStatusEventList();
    ServiceStatus status = ActivitiesTable.addActivities(activitiesList, writableDataBase, mContext);
    assertEquals("Activities not added to the table", ServiceStatus.SUCCESS, status);
    Log.i(LOG_TAG, "***** testFetchStatusEventList: activities added *****");
    // check if the records are there
    List<Long> activitiesIds = new ArrayList<Long>();
    for (ActivityItem item : activitiesList) {
        activitiesIds.add(item.activityId);
    }
    SQLiteDatabase readableDataBase = mTestDatabase.getReadableDatabase();
    List<Long> actualDBIds = new ArrayList<Long>();
    Cursor c = ActivitiesTable.fetchStatusEventList(YESTERDAY_TIME_MILLIS, readableDataBase);
    while (c.moveToNext()) {
        ActivityItem ai = new ActivityItem();
        ActivityContact ac = new ActivityContact();
        ActivitiesTable.getQueryData(c, ai, ac);
        if (ac.mContactId != null) {
            ai.contactList = new ArrayList<ActivityContact>();
            ai.contactList.add(ac);
        }
        actualDBIds.add(ai.activityId);
    }
    c.close();
    compareActivityIds(activitiesIds, actualDBIds);
    Log.i(LOG_TAG, "***** fetchStatusEventlist SUCCEEDED *****");
}
Also used : ActivityContact(com.vodafone360.people.datatypes.ActivityContact) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ServiceStatus(com.vodafone360.people.service.ServiceStatus) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)190 Contact (com.vodafone360.people.datatypes.Contact)71 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)63 MediumTest (android.test.suitebuilder.annotation.MediumTest)62 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)43 ArrayList (java.util.ArrayList)43 Suppress (android.test.suitebuilder.annotation.Suppress)40 Cursor (android.database.Cursor)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)17 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)16 Bundle (android.os.Bundle)12 ContentValues (android.content.ContentValues)11 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)11 SQLException (android.database.SQLException)9 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)9 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)9 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)9 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)8 LoginDetails (com.vodafone360.people.datatypes.LoginDetails)8 PersistSettings (com.vodafone360.people.service.PersistSettings)8