Search in sources :

Example 11 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class NativeExporterTest method testExportAccount.

/**
     * Tests that the export is performed on the correct account depending on the Android platform.
     */
public void testExportAccount() {
    final int NEW_CONTACTS_COUNT = 30;
    final NativeContactsApiMockup nativeMockup = new NativeContactsApiMockup();
    final PeopleContactsApiMockup peopleMockup = new PeopleContactsApiMockup(null);
    nativeMockup.feedAccount(NativeImporterTest.GMAIL_ACCOUNT_1);
    nativeMockup.feedAccount(NativeImporterTest.GMAIL_ACCOUNT_2);
    nativeMockup.feedAccount(NativeImporterTest.THIRD_PARTY_ACCOUNT);
    nativeMockup.feedAccount(NativeImporterTest.PEOPLE_ACCOUNT);
    // add new contacts syncable contact on People side
    feedPeopleContactsApiWithNewSyncableContacts(peopleMockup, NEW_CONTACTS_COUNT);
    long[] nativeIdsFromPeople = peopleMockup.getNativeContactsIds();
    // shall be null because our PeopleContactsApiMockup will add them once synced
    assertEquals(null, nativeIdsFromPeople);
    long[] localIds = peopleMockup.getNativeSyncableContactIds();
    assertEquals(NEW_CONTACTS_COUNT, localIds.length);
    long[] nativeIds = nativeMockup.getContactIds(null);
    assertEquals(null, nativeIds);
    // perform the export to native
    runNativeExporter(nativeMockup, peopleMockup);
    // check both sides are updated correctly
    nativeIdsFromPeople = peopleMockup.getNativeContactsIds();
    assertEquals(NEW_CONTACTS_COUNT, nativeIdsFromPeople.length);
    nativeIds = nativeMockup.getContactIds(null);
    assertEquals(NEW_CONTACTS_COUNT, nativeIds.length);
    localIds = peopleMockup.getNativeSyncableContactIds();
    assertEquals(null, localIds);
    if (VersionUtils.is2XPlatform()) {
        // on Android 2.X, the contacts shall be present in the People Account
        final Account[] accounts = { NativeImporterTest.PEOPLE_ACCOUNT };
        assertTrue(NativeImporterTest.compareNativeAndPeopleContactsList(nativeMockup, accounts, peopleMockup));
    } else {
        // on Android 1.X, the contacts shall be present in the "null" account
        assertTrue(NativeImporterTest.compareNativeAndPeopleContactsList(nativeMockup, null, peopleMockup));
    }
}
Also used : NativeContactsApiMockup(com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup) Account(com.vodafone360.people.engine.contactsync.NativeContactsApi.Account)

Example 12 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class Auth method getUsernameState.

/**
     * Implementation of "auth/getusernamestate" API.
     * 
     * @param engine Handle to LoginEngine which handles requests using this
     *            API.
     * @param username User name for this account.
     * @return Request id generated for this request.
     * @return -1 when username is NULL.
     * @throws NullPointerException when engine is NULL
     */
public static int getUsernameState(BaseEngine engine, String username) {
    if (engine == null) {
        throw new NullPointerException("Auth.getUsernameState() engine cannot be NULL");
    }
    if (username == null) {
        LogUtils.logE("Auth.GetUsernameState() username must not be NULL, return -1");
        return -1;
    }
    Request request = new Request(FUNCTION_GET_USERNAME_STATE, Request.Type.TEXT_RESPONSE_ONLY, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData(USERNAME, username);
    QueueManager queue = QueueManager.getInstance();
    int requestId = queue.addRequest(request);
    queue.fireQueueStateChanged();
    return requestId;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Example 13 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class Auth method signupUserCrypted.

/**
     * Implementation of "auth/signupusercrypted" API. Encrypted signup to new
     * account.
     * 
     * @param engine Handle to LoginEngine which handles requests using this
     *            API.
     * @param fullname Full name of user
     * @param username Username chosen for new account
     * @param password Password chosen for new account
     * @param timestamp Current timestamp.
     * @param email Email address associated with this account.
     * @param birthDate Birthday of user signing up (there is a minimum age
     *            limit for users).
     * @param msisdn MSIDN for user.
     * @param acceptedTAndC Whether user has accepted terms and conditions.
     * @param countryCode String identifier identifying country.
     * @param timezone Timezone identifier.
     * @param language Lauguage identifier.
     * @param mobileOperatorId ID of mobile operator.
     * @param mobileModelId Mobile device ID.
     * @param sendConfirmationMail True if confirmation email to be sent to
     *            user.
     * @param sendConfirmationSms True if confirmation SMS to be sent to user.
     * @param subscribeToNewsletter True if user wishes to subscribe to
     *            newsletter.
     * @return Request ID generated for this request.
     * @throws NullPointerException when engine is NULL
     * @throws NullPointerException when acceptedTAndC is NULL
     * @throws NullPointerException when mobileOperatorId is NULL
     * @throws NullPointerException when mobileModelId is NULL
     * @throws NullPointerException when sendConfirmationMail is NULL
     * @throws NullPointerException when sendConfirmationSms is NULL
     * @throws NullPointerException when subscribeToNewsletter is NULL
     */
public static int signupUserCrypted(BaseEngine engine, String fullname, String username, byte[] password, long timestamp, String email, String birthDate, String msisdn, Boolean acceptedTAndC, String countryCode, String timezone, String language, Long mobileOperatorId, Long mobileModelId, Boolean sendConfirmationMail, Boolean sendConfirmationSms, Boolean subscribeToNewsletter) {
    if (engine == null) {
        throw new NullPointerException("Auth.signupUserCrypted() engine cannot be NULL");
    }
    if (acceptedTAndC == null) {
        throw new NullPointerException("Auth.signupUserCrypted() acceptedTAndC cannot be NULL");
    }
    if (mobileOperatorId == null) {
        throw new NullPointerException("Auth.signupUserCrypted() mobileOperatorId cannot be NULL");
    }
    if (mobileModelId == null) {
        throw new NullPointerException("Auth.signupUserCrypted() mobileModelId cannot be NULL");
    }
    if (sendConfirmationMail == null) {
        throw new NullPointerException("Auth.signupUserCrypted() sendConfirmationMail cannot be NULL");
    }
    if (sendConfirmationSms == null) {
        throw new NullPointerException("Auth.signupUserCrypted() sendConfirmationSms cannot be NULL");
    }
    if (subscribeToNewsletter == null) {
        throw new NullPointerException("Auth.signupUserCrypted() subscribeToNewsletter cannot be NULL");
    }
    String ts = "" + (System.currentTimeMillis() / 1000);
    Request request = new Request(FUNCTION_SIGNUP_USER_CRYPTED, Request.Type.SIGN_UP, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData(FULLNAME, fullname);
    request.addData(USERNAME, username);
    request.addData(PASSWORD, password);
    request.addData(EMAIL, email);
    request.addData(BIRTHDATE, birthDate);
    request.addData(MSISDN, msisdn);
    request.addData(ACCEPTED_T_AND_C, acceptedTAndC.toString());
    request.addData(COUNTY_CODE, countryCode);
    request.addData(TIMESTAMP, ts);
    request.addData(TIMEZONE, timezone);
    request.addData(LANGUAGE, language);
    request.addData(MOBILE_OPERATOR_ID, mobileOperatorId.toString());
    request.addData(MOBILE_MODE_ID, mobileModelId.toString());
    request.addData(SEND_CONFIRMATION_MAIL, sendConfirmationMail.toString());
    request.addData(SEND_CONFIRMAITON_SMS, sendConfirmationSms.toString());
    request.addData(SUBSCRIBE_TO_NEWSLETTER, subscribeToNewsletter.toString());
    QueueManager queue = QueueManager.getInstance();
    int requestId = queue.addRequest(request);
    queue.fireQueueStateChanged();
    return requestId;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Example 14 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class Auth method getSessionByCredentials.

/**
     * Implementation of "getsessionbycredentials" API. Used to login to an
     * existing VF360 account.
     * 
     * @param engine Handle to LoginEngine which handles requests using this
     *            API.
     * @param username User-name for account.
     * @param password Password for account.
     * @param more Additional login details or NULL.
     * @return Request ID generated for this request.
     * @throws NullPointerException when engine is NULL
     * @throws NullPointerException when username is NULL
     * @throws NullPointerException when password is NULL
     */
public static int getSessionByCredentials(BaseEngine engine, String username, String password, Map<String, List<String>> more) {
    if (engine == null) {
        throw new NullPointerException("Auth.getSessionByCredentials() engine cannot be NULL");
    }
    if (username == null) {
        throw new NullPointerException("Auth.getSessionByCredentials() username cannot be NULL");
    }
    if (password == null) {
        throw new NullPointerException("Auth.getSessionByCredentials() password cannot be NULL");
    }
    String ts = "" + (System.currentTimeMillis() / 1000);
    Request request = new Request(FUNCTION_GET_SESSION, Request.Type.SIGN_IN, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData("hash", AuthUtils.getMd5Hash(SettingsManager.getProperty(Settings.APP_SECRET_KEY).toLowerCase() + "&" + ts + "&" + username.toLowerCase() + "&" + password.toLowerCase()));
    request.addData(TIMESTAMP, ts);
    request.addData(USERNAME, username.toLowerCase());
    QueueManager queue = QueueManager.getInstance();
    int requestId = queue.addRequest(request);
    queue.fireQueueStateChanged();
    return requestId;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Example 15 with Account

use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.

the class Auth method requestActivationCode.

/**
     * Implementation of "auth/requestactivationcode" API.
     * 
     * @param engine Handle to LoginEngine which handles requests using this
     *            API.
     * @param username User-name for this account.
     * @param mobileNumber Mobile number for this activation code to be sent.
     * @return Request ID generated for this request.
     * @return -1 when username is NULL.
     * @throws NullPointerException when engine is NULL
     * @throws NullPointerException when mobileNumber is NULL
     */
public static int requestActivationCode(BaseEngine engine, String username, String mobileNumber) {
    if (engine == null) {
        throw new NullPointerException("Auth.requestActivationCode() engine cannot be NULL");
    }
    if (username == null) {
        LogUtils.logE("Auth.requestActivationCode() username must be specified");
        return -1;
    }
    if (mobileNumber == null) {
        throw new NullPointerException("Auth.requestActivationCode() mobileNumber cannot be NULL");
    }
    Request request = new Request(FUNCTION_REQUEST_ACTIVATION_CODE, Request.Type.STATUS, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData(USERNAME, username);
    request.addData(VALUE, mobileNumber);
    request.addData(FLAGS, ACTIVATE_MOBILE_CLIENT_FLAG);
    QueueManager queue = QueueManager.getInstance();
    int requestId = queue.addRequest(request);
    queue.fireQueueStateChanged();
    return requestId;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Aggregations

Account (com.vodafone360.people.engine.contactsync.NativeContactsApi.Account)7 QueueManager (com.vodafone360.people.service.io.QueueManager)5 Request (com.vodafone360.people.service.io.Request)5 ArrayList (java.util.ArrayList)3 MediumTest (android.test.suitebuilder.annotation.MediumTest)2 Suppress (android.test.suitebuilder.annotation.Suppress)2 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)2 ServiceStatus (com.vodafone360.people.service.ServiceStatus)2 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 RegistrationDetails (com.vodafone360.people.datatypes.RegistrationDetails)1 EngineManager (com.vodafone360.people.engine.EngineManager)1 IContactSyncCallback (com.vodafone360.people.engine.contactsync.IContactSyncCallback)1 NativeContactsApi (com.vodafone360.people.engine.contactsync.NativeContactsApi)1 NativeContactsApiMockup (com.vodafone360.people.tests.engine.contactsync.NativeImporterTest.NativeContactsApiMockup)1 DynamicArrayLong (com.vodafone360.people.utils.DynamicArrayLong)1