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;
}
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);
}
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;
}
Aggregations