Considered servers without sharing support

This commit is contained in:
David A. Velasco 2014-02-07 08:59:11 +01:00
parent 0fde0084e2
commit dd7d44ed32
3 changed files with 31 additions and 6 deletions

View file

@ -100,6 +100,9 @@ public class SynchronizeFolderOperation extends RemoteOperation {
/** 'True' means that this operation is part of a full account synchronization */ /** 'True' means that this operation is part of a full account synchronization */
private boolean mSyncFullAccount; private boolean mSyncFullAccount;
/** 'True' means that Share resources bound to the files into the folder should be refreshed also */
private boolean mRefreshShares;
/** 'True' means that the remote folder changed from last synchronization and should be fetched */ /** 'True' means that the remote folder changed from last synchronization and should be fetched */
private boolean mRemoteFolderChanged; private boolean mRemoteFolderChanged;
@ -119,12 +122,14 @@ public class SynchronizeFolderOperation extends RemoteOperation {
public SynchronizeFolderOperation( OCFile folder, public SynchronizeFolderOperation( OCFile folder,
long currentSyncTime, long currentSyncTime,
boolean syncFullAccount, boolean syncFullAccount,
boolean refreshShares,
FileDataStorageManager dataStorageManager, FileDataStorageManager dataStorageManager,
Account account, Account account,
Context context ) { Context context ) {
mLocalFolder = folder; mLocalFolder = folder;
mCurrentSyncTime = currentSyncTime; mCurrentSyncTime = currentSyncTime;
mSyncFullAccount = syncFullAccount; mSyncFullAccount = syncFullAccount;
mRefreshShares = refreshShares;
mStorageManager = dataStorageManager; mStorageManager = dataStorageManager;
mAccount = account; mAccount = account;
mContext = context; mContext = context;
@ -180,8 +185,11 @@ public class SynchronizeFolderOperation extends RemoteOperation {
sendLocalBroadcast(EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result); sendLocalBroadcast(EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result);
} }
if (result.isSuccess()) { if (result.isSuccess() && mRefreshShares) {
result = refreshSharesForFolder(client); RemoteOperationResult shareResult = refreshSharesForFolder(client);
if (shareResult.getCode() != ResultCode.FILE_NOT_FOUND) {
result = shareResult;
} // else , keep the previous result ; being conservative for servers where Sharing API is supported, but disabled
} }
if (!mSyncFullAccount) { if (!mSyncFullAccount) {
@ -506,6 +514,7 @@ public class SynchronizeFolderOperation extends RemoteOperation {
* @param result * @param result
*/ */
private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) { private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) {
Log_OC.d(TAG, "Send broadcast " + event);
Intent intent = new Intent(event); Intent intent = new Intent(event);
intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, mAccount.name); intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, mAccount.name);
if (dirRemotePath != null) { if (dirRemotePath != null) {

View file

@ -30,6 +30,7 @@ import com.owncloud.android.R;
import com.owncloud.android.authentication.AuthenticatorActivity; import com.owncloud.android.authentication.AuthenticatorActivity;
import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.accounts.OwnCloudAccount;
import com.owncloud.android.lib.operations.common.RemoteOperationResult; import com.owncloud.android.lib.operations.common.RemoteOperationResult;
import com.owncloud.android.operations.SynchronizeFolderOperation; import com.owncloud.android.operations.SynchronizeFolderOperation;
import com.owncloud.android.operations.UpdateOCVersionOperation; import com.owncloud.android.operations.UpdateOCVersionOperation;
@ -40,6 +41,7 @@ import com.owncloud.android.utils.Log_OC;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountsException; import android.accounts.AccountsException;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
@ -107,6 +109,9 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
/** {@link SyncResult} instance to return to the system when the synchronization finish */ /** {@link SyncResult} instance to return to the system when the synchronization finish */
private SyncResult mSyncResult; private SyncResult mSyncResult;
/** 'True' means that the server supports the share API */
private boolean mIsSharedSupported;
/** /**
* Creates a {@link FileSyncAdapter} * Creates a {@link FileSyncAdapter}
@ -150,6 +155,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
this.setAccount(account); this.setAccount(account);
this.setContentProviderClient(providerClient); this.setContentProviderClient(providerClient);
this.setStorageManager(new FileDataStorageManager(account, providerClient)); this.setStorageManager(new FileDataStorageManager(account, providerClient));
AccountManager accountManager = getAccountManager();
mIsSharedSupported = Boolean.parseBoolean(accountManager.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_SHARE_API));
try { try {
this.initClientForCurrentAccount(); this.initClientForCurrentAccount();
} catch (IOException e) { } catch (IOException e) {
@ -254,13 +263,13 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
DataStorageManager dataStorageManager, DataStorageManager dataStorageManager,
Account account, Account account,
Context context ) { Context context ) {
} }
*/ */
// folder synchronization // folder synchronization
SynchronizeFolderOperation synchFolderOp = new SynchronizeFolderOperation( folder, SynchronizeFolderOperation synchFolderOp = new SynchronizeFolderOperation( folder,
mCurrentSyncTime, mCurrentSyncTime,
true, true,
mIsSharedSupported,
getStorageManager(), getStorageManager(),
getAccount(), getAccount(),
getContext() getContext()
@ -360,6 +369,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
* @param result Result of an individual {@ SynchronizeFolderOperation}, if completed; may be null. * @param result Result of an individual {@ SynchronizeFolderOperation}, if completed; may be null.
*/ */
private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) { private void sendLocalBroadcast(String event, String dirRemotePath, RemoteOperationResult result) {
Log_OC.d(TAG, "Send broadcast " + event);
Intent intent = new Intent(event); Intent intent = new Intent(event);
intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, getAccount().name); intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, getAccount().name);
if (dirRemotePath != null) { if (dirRemotePath != null) {

View file

@ -906,6 +906,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String event = intent.getAction(); String event = intent.getAction();
Log_OC.d(TAG, "Received broadcast " + event);
String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME); String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME);
String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncAdapter.EXTRA_RESULT); RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncAdapter.EXTRA_RESULT);
@ -913,7 +914,10 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
if (sameAccount) { if (sameAccount) {
if (!FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) { if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
mSyncInProgress = true;
} else {
OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath()); OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath());
OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByPath(getCurrentDir().getRemotePath()); OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByPath(getCurrentDir().getRemotePath());
@ -958,6 +962,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
} }
removeStickyBroadcast(intent); removeStickyBroadcast(intent);
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/);
} }
@ -1536,6 +1541,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
RemoteOperation synchFolderOp = new SynchronizeFolderOperation( folder, RemoteOperation synchFolderOp = new SynchronizeFolderOperation( folder,
currentSyncTime, currentSyncTime,
false, false,
getFileOperationsHelper().isSharedSupported(this),
getStorageManager(), getStorageManager(),
getAccount(), getAccount(),
getApplicationContext() getApplicationContext()