Search in sources :

Example 1 with SyncMeEngine

use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.

the class EngineManager method createSyncMeEngine.

/**
     * Create instance of SyncMeEngine.
     */
private synchronized void createSyncMeEngine() {
    final MainApplication app = (MainApplication) mService.getApplication();
    mSyncMeEngine = new SyncMeEngine(mService, mUiEventCallback, app.getDatabase());
    addEngine(mSyncMeEngine);
}
Also used : SyncMeEngine(com.vodafone360.people.engine.meprofile.SyncMeEngine) MainApplication(com.vodafone360.people.MainApplication)

Example 2 with SyncMeEngine

use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.

the class SyncMeEngine method processPushEvent.

/**
     * This method process the "pc" push event.
     * @param resp Response - server response normally containing a "pc"
     *            PushEvent data type
     * @return boolean - TRUE if a push event was found in the response
     */
private boolean processPushEvent(final 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("SyncMeEngine processPushMessage():" + pushEvent.mMessageType);
    switch(pushEvent.mMessageType) {
        case PROFILE_CHANGE:
            addGetMeProfileContactRequest();
            break;
        default:
            break;
    }
    return true;
}
Also used : PushEvent(com.vodafone360.people.datatypes.PushEvent) BaseDataType(com.vodafone360.people.datatypes.BaseDataType)

Example 3 with SyncMeEngine

use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.

the class SyncMeEngine method processGetMyChangesResponse.

/**
     * Processes the response from a GetMyChanges request. The me profile data
     * will be merged in the local database if the response is successful.
     * Otherwise the processor will complete with a suitable error.
     * @param resp Response from server.
     */
private void processGetMyChangesResponse(final DecodedResponse resp) {
    LogUtils.logD("SyncMeEngine processGetMyChangesResponse()");
    ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
    if (status == ServiceStatus.SUCCESS) {
        ContactChanges changes = (ContactChanges) resp.mDataTypes.get(0);
        Contact currentMeProfile = new Contact();
        status = SyncMeDbUtils.fetchMeProfile(mDbHelper, currentMeProfile);
        switch(status) {
            case SUCCESS:
                SyncMeDbUtils.updateMeProfile(mDbHelper, currentMeProfile, changes.mUserProfile);
                break;
            case // this is the 1st time sync
            ERROR_NOT_FOUND:
                currentMeProfile.copy(changes.mUserProfile);
                status = SyncMeDbUtils.setMeProfile(mDbHelper, currentMeProfile);
                setFirstTimeMeSyncComplete(true);
                break;
            default:
                completeUiRequest(status);
                return;
        }
        final String url = fetchThumbnailUrlFromProfile(changes.mUserProfile);
        if (url != null) {
            downloadMeProfileThumbnail(url, currentMeProfile.localContactID);
        } else {
            completeUiRequest(status);
        }
        storeMeProfileRevisionInDb(changes.mCurrentServerVersion);
    } else {
        completeUiRequest(status);
    }
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus) ContactChanges(com.vodafone360.people.datatypes.ContactChanges) Contact(com.vodafone360.people.datatypes.Contact)

Example 4 with SyncMeEngine

use of com.vodafone360.people.engine.meprofile.SyncMeEngine in project 360-Engine-for-Android by 360.

the class SyncMeEngineTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    // delete the database
    getInstrumentation().getTargetContext().deleteDatabase(HelperClasses.getDatabaseName());
    // create an application instance
    mApplication = (MainApplication) Instrumentation.newApplication(MainApplication.class, getInstrumentation().getTargetContext());
    mApplication.onCreate();
    mEngineTester = new EngineTestFramework(this);
    mEngine = new SyncMeEngine(getInstrumentation().getTargetContext(), mEngineTester, mApplication.getDatabase());
    mEngineTester.setEngine(mEngine);
    Log.i(LOG_TAG, "**** setUp() end ****");
}
Also used : SyncMeEngine(com.vodafone360.people.engine.meprofile.SyncMeEngine)

Aggregations

SyncMeEngine (com.vodafone360.people.engine.meprofile.SyncMeEngine)2 MainApplication (com.vodafone360.people.MainApplication)1 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)1 Contact (com.vodafone360.people.datatypes.Contact)1 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)1 PushEvent (com.vodafone360.people.datatypes.PushEvent)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1