Search in sources :

Example 16 with Account

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

the class Auth method activate.

/**
     * Implementation of "auth/activate" API.
     * 
     * @param engine Handle to LoginEngine which handles requests using this
     *            API.
     * @param code Activation code for this account
     * @return Request ID generated for this request.
     * @return -1 when code is NULL.
     * @return -1 when LoginEngine.getSession() is NULL.
     * @throws NullPointerException when engine is NULL
     */
public static int activate(BaseEngine engine, String code) {
    if (engine == null) {
        throw new NullPointerException("Auth.activate() engine cannot be NULL");
    }
    if (LoginEngine.getSession() == null) {
        LogUtils.logE("Auth.activate() Invalid session, return -1");
        return -1;
    }
    if (code == null) {
        LogUtils.logE("Auth.activate() Code must not be NULL, return -1");
        return -1;
    }
    Request request = new Request(FUNCTION_ACTIVATE, Request.Type.STATUS, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData("code", code);
    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)

Example 17 with Account

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

the class LoginEngine method handleCreateSessionManualResponse.

/**
     * Called when a response to the GetSessionByCredentials API is received
     * (manual login). In case of success, tries to activate the account using
     * the activation code received by SMS.
     * 
     * @param data The received data
     */
private void handleCreateSessionManualResponse(List<BaseDataType> data) {
    LogUtils.logD("LoginEngine.handleCreateSessionManualResponse()");
    ServiceStatus errorStatus = getResponseStatus(BaseDataType.AUTH_SESSION_HOLDER_TYPE, data);
    if (errorStatus == ServiceStatus.SUCCESS && (data.size() > 0)) {
        setActivatedSession((AuthSessionHolder) data.get(0));
        startActivateAccount();
        return;
    }
    completeUiRequest(errorStatus, null);
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 18 with Account

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

the class NativeContactsApiTest method getContactIdsForAllAccounts.

/**
	 * Utility method to get contact ids for all existing accounts.
	 */
private long[] getContactIdsForAllAccounts() {
    Account[] accounts = mNabApi.getAccounts();
    List<Long> idsArray = new ArrayList<Long>();
    if (accounts != null) {
        final int NUM_ACCOUNTS = accounts.length;
        for (int i = 0; i < NUM_ACCOUNTS; i++) {
            Account account = accounts[i];
            if (account != null) {
                long[] ids = mNabApi.getContactIds(account);
                if (ids != null) {
                    final int NUM_IDS = ids.length;
                    for (int j = 0; j < NUM_IDS; j++) {
                        idsArray.add(Long.valueOf(ids[j]));
                    }
                }
            }
        }
    }
    long[] nullAccountIds = mNabApi.getContactIds(null);
    if (nullAccountIds != null) {
        final int NUM_IDS = nullAccountIds.length;
        for (int i = 0; i < NUM_IDS; i++) {
            idsArray.add(Long.valueOf(nullAccountIds[i]));
        }
    }
    final int idsCount = idsArray.size();
    if (idsCount > 0) {
        long[] ids = new long[idsCount];
        for (int i = 0; i < idsCount; i++) {
            ids[i] = idsArray.get(i);
        }
        return ids;
    }
    return null;
}
Also used : Account(com.vodafone360.people.engine.contactsync.NativeContactsApi.Account) ArrayList(java.util.ArrayList)

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