Search in sources :

Example 1 with RemoteServerInfo

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;
}
Also used : RemoteCapability(com.owncloud.android.lib.resources.status.RemoteCapability) GetRemoteStatusOperation(com.owncloud.android.lib.resources.status.GetRemoteStatusOperation) GetRemoteCapabilitiesOperation(com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation) AccountManager(android.accounts.AccountManager) OwnCloudVersion(com.owncloud.android.lib.resources.status.OwnCloudVersion) RemoteServerInfo(com.owncloud.android.lib.resources.status.RemoteServerInfo)

Aggregations

AccountManager (android.accounts.AccountManager)1 GetRemoteCapabilitiesOperation (com.owncloud.android.lib.resources.status.GetRemoteCapabilitiesOperation)1 GetRemoteStatusOperation (com.owncloud.android.lib.resources.status.GetRemoteStatusOperation)1 OwnCloudVersion (com.owncloud.android.lib.resources.status.OwnCloudVersion)1 RemoteCapability (com.owncloud.android.lib.resources.status.RemoteCapability)1 RemoteServerInfo (com.owncloud.android.lib.resources.status.RemoteServerInfo)1