use of com.owncloud.android.lib.resources.status.GetRemoteStatusOperation in project android by owncloud.
the class GetServerInfoOperation method run.
/**
* Performs the operation
*
* @return Result of the operation. If successful, includes an instance of
* {@link ServerInfo} with the information retrieved from the server.
* Call {@link RemoteOperationResult#getData()}.get(0) to get it.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
// first: check the status of the server (including its version)
GetRemoteStatusOperation getStatus = new GetRemoteStatusOperation(mContext);
RemoteOperationResult result = getStatus.execute(client);
if (result.isSuccess()) {
// second: get authentication method required by the server
mResultData.mVersion = (OwnCloudVersion) (result.getData().get(0));
mResultData.mIsSslConn = (result.getCode() == ResultCode.OK_SSL);
mResultData.mBaseUrl = normalizeProtocolPrefix(mUrl, mResultData.mIsSslConn);
RemoteOperationResult detectAuthResult = detectAuthorizationMethod(client);
// third: merge results
if (detectAuthResult.isSuccess()) {
mResultData.mAuthMethod = (AuthenticationMethod) detectAuthResult.getData().get(0);
ArrayList<Object> data = new ArrayList<Object>();
data.add(mResultData);
result.setData(data);
} else {
result = detectAuthResult;
}
}
return result;
}
use of com.owncloud.android.lib.resources.status.GetRemoteStatusOperation in project android by owncloud.
the class SyncCapabilitiesOperation method run.
@Override
protected RemoteOperationResult<RemoteCapability> run(OwnCloudClient client) {
RemoteCapability capabilities = null;
OwnCloudVersion serverVersion = null;
// / Get current value for capabilities from server
GetRemoteCapabilitiesOperation getCapabilities = new GetRemoteCapabilitiesOperation();
RemoteOperationResult<RemoteCapability> result = getCapabilities.execute(client);
if (result.isSuccess()) {
// Read data from the result
if (result.getData() != null) {
capabilities = result.getData();
serverVersion = new OwnCloudVersion(capabilities.getVersionString());
}
} else {
Timber.w("Remote capabilities not available");
// server version is important; this fallback will try to get it from status.php
// if capabilities API is not available.
GetRemoteStatusOperation getStatus = new GetRemoteStatusOperation();
RemoteOperationResult<RemoteServerInfo> statusResult = getStatus.execute(client);
if (statusResult.isSuccess()) {
serverVersion = statusResult.getData().getOwnCloudVersion();
}
}
// / save data - capabilities in database
if (capabilities != null) {
getStorageManager().saveCapabilities(capabilities);
}
// and com.owncloud.android.lib.common.accounts.AccountUtils#getServerVersionForAccount(...)
if (serverVersion != null) {
AccountManager accountMngr = AccountManager.get(MainApp.Companion.getAppContext());
accountMngr.setUserData(getStorageManager().getAccount(), com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_VERSION, serverVersion.getVersion());
}
return result;
}
Aggregations