Search in sources :

Example 1 with LoginEngine

use of com.vodafone360.people.engine.login.LoginEngine in project 360-Engine-for-Android by 360.

the class LoginEngineTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mApplication = (MainApplication) Instrumentation.newApplication(MainApplication.class, getInstrumentation().getTargetContext());
    mApplication.onCreate();
    mEngineTester = new EngineTestFramework(this);
    mEng = new LoginEngine(getInstrumentation().getTargetContext(), mEngineTester, mApplication.getDatabase());
    mEngineTester.setEngine(mEng);
    mState = LoginTestState.IDLE;
    mEng.addListener(this);
}
Also used : LoginEngine(com.vodafone360.people.engine.login.LoginEngine)

Example 2 with LoginEngine

use of com.vodafone360.people.engine.login.LoginEngine in project 360-Engine-for-Android by 360.

the class Presence method setMyAvailability.

/**
 * This method adds the request to setAvailability() on the RequestQueue.
 * @param status Hashtable<String, String> - the Hashtable of (networkName, statusName) pairs.
 * @return int - the request id of setAvailability() request that was added, or
 * -1 if session in the LoginEngine is null.
 */
public static int setMyAvailability(Hashtable<String, String> status) {
    if (LoginEngine.getSession() == null) {
        LogUtils.logE("Presence.setAvailability() No session, so return");
        return -1;
    }
    if (Settings.LOG_PRESENCE_PUSH_ON_LOGCAT) {
        LogUtils.logWithName(LogUtils.PRESENCE_INFO_TAG, "SET MY AVAILABILITY: " + status);
    }
    Request request = new Request(EMPTY, Request.Type.AVAILABILITY, EngineId.PRESENCE_ENGINE, true, Settings.API_REQUESTS_TIMEOUT_PRESENCE_SET_AVAILABILITY);
    request.addData("availability", status);
    int reqId = QueueManager.getInstance().addRequest(request);
    QueueManager.getInstance().fireQueueStateChanged();
    return reqId;
}
Also used : Request(com.vodafone360.people.service.io.Request)

Example 3 with LoginEngine

use of com.vodafone360.people.engine.login.LoginEngine in project 360-Engine-for-Android by 360.

the class UserDataProtection method processUserChanges.

/**
 * Requests to log out from 360 if the user has changed.
 */
public void processUserChanges() {
    LogUtils.logD("UserDataProtection.checkUserChanges()");
    final LoginEngine loginEngine = EngineManager.getInstance().getLoginEngine();
    if (hasUserChanged()) {
        if (loginEngine.isLoggedIn()) {
            // User has changed, log out
            LogUtils.logD("UserDataProtection.checkUserChanges() - User has changed! Request logout.");
            loginEngine.addUiRemoveUserDataRequest();
        } else {
            LoginPreferences.clearPreferencesFile(mContext);
        }
    }
}
Also used : LoginEngine(com.vodafone360.people.engine.login.LoginEngine)

Example 4 with LoginEngine

use of com.vodafone360.people.engine.login.LoginEngine 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)

Example 5 with LoginEngine

use of com.vodafone360.people.engine.login.LoginEngine in project 360-Engine-for-Android by 360.

the class Auth method getTermsAndConditions.

/**
 * Implementation of "auth/gettermsandconditions" API.
 *
 * @param engine Handle to LoginEngine which handles requests using this
 *            API.
 * @return request ID generated for this request.
 * @throws NullPointerException when engine is NULL
 */
public static int getTermsAndConditions(BaseEngine engine) {
    if (engine == null) {
        throw new NullPointerException("Auth.getPublicKey() engine cannot be NULL");
    }
    String localString = getLocalString();
    Request request = new Request(FUNCTION_GET_TERMS_AND_CONDITIONS, Request.Type.TEXT_RESPONSE_ONLY, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
    request.addData(LANGUAGE_CULTURE, localString);
    request.addData(FLAGS, "0");
    QueueManager queue = QueueManager.getInstance();
    int requestId = queue.addRequest(request);
    queue.fireQueueStateChanged();
    ApplicationCache.setTermsLanguage(localString);
    return requestId;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Aggregations

Request (com.vodafone360.people.service.io.Request)9 QueueManager (com.vodafone360.people.service.io.QueueManager)8 LoginEngine (com.vodafone360.people.engine.login.LoginEngine)3 MainApplication (com.vodafone360.people.MainApplication)1