use of com.owncloud.android.lib.resources.status.RemoteServerInfo 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