Search in sources :

Example 1 with RemoteCapability

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

Example 2 with RemoteCapability

use of com.owncloud.android.lib.resources.status.RemoteCapability in project android by owncloud.

the class RefreshFolderOperation method syncCapabilitiesAndGetServerVersion.

private OwnCloudVersion syncCapabilitiesAndGetServerVersion() {
    OwnCloudVersion serverVersion;
    SyncCapabilitiesOperation getCapabilities = new SyncCapabilitiesOperation();
    RemoteOperationResult<RemoteCapability> result = getCapabilities.execute(getStorageManager(), mContext);
    if (result.isSuccess()) {
        RemoteCapability capability = result.getData();
        serverVersion = new OwnCloudVersion(capability.getVersionString());
    } else {
        // get whatever was stored before for the version
        serverVersion = AccountUtils.getServerVersion(mAccount);
    }
    return serverVersion;
}
Also used : RemoteCapability(com.owncloud.android.lib.resources.status.RemoteCapability) OwnCloudVersion(com.owncloud.android.lib.resources.status.OwnCloudVersion)

Aggregations

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